9 Commits

Author SHA1 Message Date
Abdel
618e341e02 Update README.md 2023-05-04 13:59:19 -04:00
abdelkader
6427542051 possibility to modify address type 2023-05-04 13:52:10 -04:00
abdelkader
dc9fa3143a Merge branch 'master' of https://github.com/abdelkader/vCardEditor 2023-05-03 21:12:50 -04:00
Abdel
f4ede0585b Merge pull request #28 from abdelkader/abdelkader-patch-1
Update README.md
2023-04-30 12:04:34 -04:00
Abdel
83cda3c073 Update README.md 2023-04-30 12:03:30 -04:00
Abdel
8d9070f483 Update README.md 2023-04-19 17:27:07 -04:00
Abdel
4b33a2425d Update README.md 2023-04-19 17:22:17 -04:00
Abdel
fa7f2c85d2 Update README.md 2023-04-19 15:15:57 -04:00
Abdel
a40ffaca58 Update README.md 2023-04-19 15:05:43 -04:00
10 changed files with 113 additions and 84 deletions

View File

@@ -1,3 +1,8 @@
[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/B0B2KV8WP)
<p align="center">
<a href="https://github.com/abdelkader/vCardEditor/releases/latest/download/vCardEditor.exe"><img src="https://camo.githubusercontent.com/d83fa798b621f1e112646fcc4aa74fff1ff6a8b22f5fc1da5ed8f79ddb4a51cb/68747470733a2f2f62616467656e2e6e65742f6769746875622f72656c656173652f4e61657265656e2f5374726170646f776e2e6a73" alt="Latest release" data-canonical-src="https://badgen.net/github/release/Naereen/Strapdown.js" style="max-width: 100%;"></a>
</p>
# vCard Editor
@@ -5,25 +10,31 @@ A Simple vcf file Editor. You can export easily edit (modify, delete) entries of
The software is still in **early stage**.
## Installation
No need to install anything. Just head to the release section and download the last release version.
🔧 No need to install anything. Just head to the release section and download the last release version.
## Screenshots
![App Screenshot](https://user-images.githubusercontent.com/474542/151180600-cf169628-0761-49a9-a63d-05f751c6a9bb.png)
![vcardeditorv0_5](https://user-images.githubusercontent.com/169070/236289228-106c1489-e01d-400c-968e-92d3e2be74ab.png)
## Acknowledgements
- [Wonderful library of parsing and generating vcf format](https://github.com/drlongnecker/Thought.vCards)
- [MVP pattern from this example](https://github.com/lennykean/NoteCards)
- 🧰 [Wonderful library of parsing and generating vcf format](https://github.com/drlongnecker/Thought.vCards)
- 📖 [MVP pattern from this example](https://github.com/lennykean/NoteCards)
## Release notes
#### 0.4
- Import images
- refactoring and bugs fixed
#### 0.3
- Added address section.

View File

@@ -35,10 +35,11 @@ namespace VCFEditor.Presenter
_view.ModifyImage += ModifyImage;
_view.ExportImage += ExportImage;
_view.AddressAdded += _view_AddressAdded;
_view.AddressModified += _view_AddressModified;
_view.AddressRemoved += _view_AddressRemoved;
}
}
private void _view_AddressRemoved(object sender, EventArg<int> e)
{
@@ -56,6 +57,14 @@ namespace VCFEditor.Presenter
contact.card.DeliveryAddresses.Add(new vCardDeliveryAddress( e.Data));
}
private void _view_AddressModified(object sender, EventArg<List<vCardDeliveryAddressTypes>> e)
{
var contact = _repository.Contacts[_view.SelectedContactIndex];
_repository.SetDirtyFlag(_view.SelectedContactIndex);
contact.card.DeliveryAddresses.Clear();
contact.card.DeliveryAddresses.Add(new vCardDeliveryAddress(e.Data));
}
private void ExportImage(object sender, EventArgs e)
{
@@ -78,8 +87,6 @@ namespace VCFEditor.Presenter
}
private void ModifyImage(object sender, EventArg<string> e)
{
if (!string.IsNullOrEmpty(e.Data) )
@@ -143,7 +150,6 @@ namespace VCFEditor.Presenter
}
}
public void NewFileOpened(object sender, EventArg<string> e)
{
BeforeOpeningNewFile(sender, e);
@@ -175,7 +181,6 @@ namespace VCFEditor.Presenter
}
public void ChangeContactSelected(object sender, EventArgs e)
{
if (_view.SelectedContactIndex > -1)
@@ -192,6 +197,5 @@ namespace VCFEditor.Presenter
}
}
}

View File

@@ -1,7 +1,7 @@

namespace vCardEditor.View.Customs
{
partial class AddAddress
partial class AddAddressDialog
{
/// <summary>
/// Required designer variable.

View File

@@ -11,12 +11,12 @@ using Thought.vCards;
namespace vCardEditor.View.Customs
{
public partial class AddAddress : Form
public partial class AddAddressDialog : Form
{
public List<vCardDeliveryAddressTypes> Addresses { get;}
private readonly List<CheckBox> _checkBoxes;
public AddAddress()
public AddAddressDialog()
{
InitializeComponent();
@@ -24,10 +24,10 @@ namespace vCardEditor.View.Customs
Addresses = new List<vCardDeliveryAddressTypes>();
}
public AddAddress(List<vCardDeliveryAddressTypes> addressCollection)
public AddAddressDialog(List<vCardDeliveryAddressTypes> addressCollection)
{
InitializeComponent();
Addresses = addressCollection;
_checkBoxes = Controls.OfType<CheckBox>().ToList();
foreach (var item in addressCollection)
@@ -73,8 +73,6 @@ namespace vCardEditor.View.Customs
return;
}
foreach (var item in total)
{
var enumType = (vCardDeliveryAddressTypes)Enum.Parse(typeof(vCardDeliveryAddressTypes), item.Text, true);

View File

@@ -10,12 +10,10 @@ namespace vCardEditor.View.Customs
{
class AddressTabControl : TabControl
{
public event EventHandler TextChangedEvent;
public event EventHandler<EventArg<List<vCardDeliveryAddressTypes>>> AddTab;
public event EventHandler<EventArg<int>> RemoveTab;
//public event EventHandler<EventArg<TabPage>> ModifyTab;
public event EventHandler<EventArg<List<vCardDeliveryAddressTypes>>> ModifyTab;
public AddressTabControl()
{
@@ -26,10 +24,8 @@ namespace vCardEditor.View.Customs
DrawItem += tbcAddress_DrawItem;
MouseDown += tbcAddress_MouseDown;
Selecting += tbcAddress_Selecting;
HandleCreated += tabControl1_HandleCreated;
HandleCreated += tbcAddress_HandleCreated;
MouseDoubleClick += AddressTabControl_MouseDoubleClick;
}
@@ -42,6 +38,7 @@ namespace vCardEditor.View.Customs
for (int i = 0; i < TabCount - 1; i++)
{
if (TabPages[i].Controls.Count == 0) continue;
AddressBox adr = TabPages[i].Controls[0] as AddressBox;
card.DeliveryAddresses.Add(adr.getDeliveryAddress());
}
@@ -49,30 +46,35 @@ namespace vCardEditor.View.Customs
private void AddressTabControl_MouseDoubleClick(object sender, MouseEventArgs e)
{
//NOT IMPLEMENTED
//TabPage checkTab;
//for (int i = 0; i < TabPages.Count; ++i)
//{
// if (GetTabRect(i).Contains(e.Location))
// {
// var AddressBox = TabPages[i].Controls[0] as AddressBox;
TabPage SlectedTab;
for (int i = 0; i < TabPages.Count - 1; ++i)
{
if (GetTabRect(i).Contains(e.Location))
{
var AddressBox = TabPages[i].Controls[0] as AddressBox;
var diag = new AddAddressDialog(AddressBox.AddressType);
if (diag.ShowDialog() == DialogResult.OK)
{
SlectedTab = TabPages[i];
SelectedTab.Text = GetTabTitle(diag.Addresses);
SelectedTab.ToolTipText = string.Join(",", diag.Addresses.ConvertAll(f => f.ToString()));
//_card.DeliveryAddresses[i].AddressType = diag.Addresses;
ModifyTab?.Invoke(sender, new EventArg<List<vCardDeliveryAddressTypes>>(diag.Addresses));
}
break;
}
}
// var diag = new AddAddress(AddressBox.AddressType);
// diag.ShowDialog();
// //if (diag.ShowDialog() == DialogResult.OK)
// // _card.DeliveryAddresses[i].AddressType = diag.Addresses;
// //ModifyTab?.Invoke(sender, new EventArg<TabPage>(checkTab));
// break;
// }
//}
}
[DllImport("user32.dll")]
private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wp, IntPtr lp);
private const int TCM_SETMINTABWIDTH = 0x1300 + 49;
private void tabControl1_HandleCreated(object sender, EventArgs e)
private void tbcAddress_HandleCreated(object sender, EventArgs e)
{
SendMessage(Handle, TCM_SETMINTABWIDTH, IntPtr.Zero, (IntPtr)16);
}
@@ -90,15 +92,16 @@ namespace vCardEditor.View.Customs
var lastIndex = TabCount - 1;
if (GetTabRect(lastIndex).Contains(e.Location))
{
var diag = new AddAddress();
var diag = new AddAddressDialog();
if (diag.ShowDialog() == DialogResult.OK)
{
vCardDeliveryAddress da = new vCardDeliveryAddress();
da.AddressType = diag.Addresses;
AddtabForAddress(da);
AddTab?.Invoke(sender, new EventArg<List<vCardDeliveryAddressTypes>>(diag.Addresses));
SelectedIndex = TabCount - 1;
}
SelectedIndex = TabCount - 1;
}
else
{
@@ -114,23 +117,20 @@ namespace vCardEditor.View.Customs
if (imageRect.Contains(e.Location))
{
var result = MessageBox.Show("Remove tab?", "Asking", MessageBoxButtons.YesNo);
if (result == DialogResult.Yes)
if (MessageBox.Show("Remove tab?", "Asking", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
TabPages.RemoveAt(i);
TabPages.RemoveAt(i);
SelectedIndex = 0;
RemoveTab?.Invoke(sender, new EventArg<int>(i));
}
}
return;
}
}
}
}
}
}
}
private void tbcAddress_DrawItem(object sender, DrawItemEventArgs e)
{
@@ -187,21 +187,15 @@ namespace vCardEditor.View.Customs
{
foreach (var item in card.DeliveryAddresses)
AddtabForAddress(item);
//Page for the "+" sign
TabPages.Add(new TabPage(" "));
}
}
private void AddtabForAddress(vCardDeliveryAddress da)
{
var title = da.AddressType[0].ToString();
if (da.AddressType.Count > 1)
title += "...";
string title = GetTabTitle(da.AddressType);
var page = new TabPage($" {title} ");
TabPages.Add(page);
TabPages.Insert(TabCount - 1, page);
var ab = new AddressBox(da.Street, da.City, da.Region, da.Country,
da.PostalCode, da.ExtendedAddress, da.PostOfficeBox, da.AddressType);
@@ -212,12 +206,24 @@ namespace vCardEditor.View.Customs
}
private string GetTabTitle(List<vCardDeliveryAddressTypes> addressTypes)
{
var title = string.Empty;
if (addressTypes.Count > 0)
{
title = addressTypes[0].ToString();
if (addressTypes.Count > 1)
title += "...";
}
return title;
}
private void ClearTabs()
{
//Remove every tab. We don't call Clear() as it doesn't free memory.
while (TabCount > 0)
//Remove every tab (except "+"). We don't call Clear() as it doesn't free memory.
while (TabCount > 1)
TabPages[TabCount - 1].Dispose();
}
}

View File

@@ -24,9 +24,9 @@ namespace VCFEditor.View
event EventHandler<EventArg<string>> ModifyImage;
event EventHandler ExportImage;
event EventHandler<EventArg<List<vCardDeliveryAddressTypes>>> AddressAdded;
event EventHandler<EventArg<List<vCardDeliveryAddressTypes>>> AddressModified;
event EventHandler<EventArg<int>> AddressRemoved;
int SelectedContactIndex { get; }
void DisplayContacts(BindingList<Contact> contacts);
void DisplayContactDetail(vCard card, string FileName);

View File

@@ -32,7 +32,7 @@ namespace vCardEditor.View
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.miSave = new System.Windows.Forms.ToolStripMenuItem();
@@ -83,6 +83,7 @@ namespace vCardEditor.View
this.Column1 = new System.Windows.Forms.DataGridViewCheckBoxColumn();
this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.tbcAddress = new vCardEditor.View.Customs.AddressTabControl();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.FormattedTitleValue = new vCardEditor.View.StateTextBox();
this.lastNameValue = new vCardEditor.View.StateTextBox();
this.middleNameValue = new vCardEditor.View.StateTextBox();
@@ -104,6 +105,7 @@ namespace vCardEditor.View
((System.ComponentModel.ISupportInitialize)(this.bsContacts)).BeginInit();
this.gbNameList.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dgContacts)).BeginInit();
this.tbcAddress.SuspendLayout();
this.SuspendLayout();
//
// menuStrip1
@@ -585,8 +587,8 @@ namespace vCardEditor.View
this.dgContacts.AllowUserToAddRows = false;
this.dgContacts.AllowUserToDeleteRows = false;
this.dgContacts.AllowUserToResizeRows = false;
dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
this.dgContacts.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1;
dataGridViewCellStyle2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
this.dgContacts.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle2;
this.dgContacts.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.dgContacts.AutoGenerateColumns = false;
@@ -628,6 +630,8 @@ namespace vCardEditor.View
//
// tbcAddress
//
this.tbcAddress.Controls.Add(this.tabPage1);
this.tbcAddress.DrawMode = System.Windows.Forms.TabDrawMode.OwnerDrawFixed;
this.tbcAddress.Location = new System.Drawing.Point(17, 23);
this.tbcAddress.Margin = new System.Windows.Forms.Padding(4);
this.tbcAddress.Name = "tbcAddress";
@@ -637,6 +641,16 @@ namespace vCardEditor.View
this.tbcAddress.Size = new System.Drawing.Size(739, 144);
this.tbcAddress.TabIndex = 0;
//
// tabPage1
//
this.tabPage1.BackColor = System.Drawing.SystemColors.Control;
this.tabPage1.Location = new System.Drawing.Point(4, 27);
this.tabPage1.Name = "tabPage1";
this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
this.tabPage1.Size = new System.Drawing.Size(731, 113);
this.tabPage1.TabIndex = 0;
this.tabPage1.Text = " ";
//
// FormattedTitleValue
//
this.FormattedTitleValue.Location = new System.Drawing.Point(45, 21);
@@ -799,6 +813,7 @@ namespace vCardEditor.View
this.gbNameList.ResumeLayout(false);
this.gbNameList.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.dgContacts)).EndInit();
this.tbcAddress.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
@@ -866,5 +881,6 @@ namespace vCardEditor.View
private System.Windows.Forms.ToolStripMenuItem toolsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem imagesToolStripMenuItem;
private AddressTabControl tbcAddress;
private System.Windows.Forms.TabPage tabPage1;
}
}

View File

@@ -26,6 +26,7 @@ namespace vCardEditor.View
public event EventHandler<EventArg<bool>> CloseForm;
public event EventHandler<EventArg<string>> ModifyImage;
public event EventHandler<EventArg<List<vCardDeliveryAddressTypes>>> AddressAdded;
public event EventHandler<EventArg<List<vCardDeliveryAddressTypes>>> AddressModified;
public event EventHandler<EventArg<int>> AddressRemoved;
public event EventHandler ExportImage;
@@ -50,6 +51,7 @@ namespace vCardEditor.View
resources = new ComponentResourceManager(typeof(MainForm));
tbcAddress.AddTab += (sender, e) => AddressAdded?.Invoke(sender, e);
tbcAddress.RemoveTab += (sender, e) => AddressRemoved?.Invoke(sender, e);
tbcAddress.ModifyTab += (sender, e) => AddressModified?.Invoke(sender, e);
tbcAddress.TextChangedEvent += (sender, e) => TextBoxValueChanged?.Invoke(sender, e);
BuildMRUMenu();
@@ -59,8 +61,6 @@ namespace vCardEditor.View
NewFileOpened?.Invoke(sender, new EventArg<string>(string.Empty));
}
public void DisplayContacts(BindingList<Contact> contacts)
{
if (contacts != null)
@@ -144,8 +144,6 @@ namespace vCardEditor.View
}
private void SetSummaryValue(StateTextBox valueLabel, string value)
{
if (valueLabel == null)
@@ -235,10 +233,7 @@ namespace vCardEditor.View
textBoxFilter.Text = string.Empty;
}
/// <summary>
/// Generate a vcard from differents fields on the form.
/// </summary>
/// <returns></returns>
private vCard GetvCardFromWindow()
{
vCard card = new vCard
@@ -262,9 +257,8 @@ namespace vCardEditor.View
card.EmailAddresses.Add(new vCardEmailAddress(this.EmailAddressValue.Text));
if (!string.IsNullOrEmpty(this.PersonalWebSiteValue.Text))
card.Websites.Add(new vCardWebsite(this.PersonalWebSiteValue.Text));
tbcAddress.getDeliveryAddress(card);
return card;

View File

@@ -133,11 +133,11 @@
<Compile Include="View\ConfigDialog.Designer.cs">
<DependentUpon>ConfigDialog.cs</DependentUpon>
</Compile>
<Compile Include="View\Customs\AddAddress.cs">
<Compile Include="View\Customs\AddAddressDialog.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="View\Customs\AddAddress.Designer.cs">
<DependentUpon>AddAddress.cs</DependentUpon>
<Compile Include="View\Customs\AddAddressDialog.Designer.cs">
<DependentUpon>AddAddressDialog.cs</DependentUpon>
</Compile>
<Compile Include="View\Customs\AddressBox.cs">
<SubType>UserControl</SubType>
@@ -176,8 +176,8 @@
<EmbeddedResource Include="View\ConfigDialog.resx">
<DependentUpon>ConfigDialog.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="View\Customs\AddAddress.resx">
<DependentUpon>AddAddress.cs</DependentUpon>
<EmbeddedResource Include="View\Customs\AddAddressDialog.resx">
<DependentUpon>AddAddressDialog.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="View\Customs\AddressBox.resx">
<DependentUpon>AddressBox.cs</DependentUpon>