first draft of adding column

added a split container
save position and location of winform
save also visible columns
Added vcard copy to clipboard
corrected failed tests
This commit is contained in:
abdelkader
2023-05-04 18:30:07 -04:00
parent 3b1cfcd36b
commit 89c06504ee
22 changed files with 877 additions and 134 deletions

View File

@@ -0,0 +1,9 @@
namespace vCardEditor.Model
{
public enum Columns
{
Name = 0,
FamilyName,
Cellular,
}
}

View File

@@ -15,6 +15,22 @@ namespace VCFEditor.Model
NotifyPropertyChanged("Name");
}
}
[DisplayName("F.Name")]
public string FamilyName
{
get => card.FamilyName;
}
[DisplayName("Cellular")]
public string Cellular
{
get {
if (card.Phones.GetFirstChoice(vCardPhoneTypes.Cellular) != null)
return card.Phones.GetFirstChoice(vCardPhoneTypes.Cellular).FullNumber;
return string.Empty;
}
}
[Browsable(false)]

View File

@@ -0,0 +1,19 @@
using System.Collections.Generic;
namespace vCardEditor.Model
{
public struct FormState
{
public List<Columns> Columns { get; set; }
public int X { get; set; }
public int Y { get; set; }
public int Height { get; set; }
public int Width { get; set; }
public int splitterPosition { get; set; }
}
}

View File

@@ -22,6 +22,7 @@ namespace VCFEditor.Presenter
_view = view;
_repository = repository;
_view.LoadForm += _view_LoadForm;
_view.AddContact += AddContact;
_view.NewFileOpened += NewFileOpened;
_view.BeforeOpeningNewFile += BeforeOpeningNewFile;
@@ -37,8 +38,26 @@ namespace VCFEditor.Presenter
_view.AddressAdded += _view_AddressAdded;
_view.AddressModified += _view_AddressModified;
_view.AddressRemoved += _view_AddressRemoved;
_view.CopyTextToClipboardEvent += _view_CopyTextToClipboardEvent;
}
private void _view_LoadForm(object sender, EventArg<FormState> e)
{
e.Data = ConfigRepository.Instance.FormState;
}
private void _view_CopyTextToClipboardEvent(object sender, EventArgs e)
{
if (_view.SelectedContactIndex < 0)
return;
var contact = _repository.Contacts[_view.SelectedContactIndex];
string SerializedCard = _repository.GenerateStringFromVCard(contact.card);
_view.SendTextToClipBoard(SerializedCard);
_view.DisplayMessage("vCard copied to clipboard!", "Information");
}
private void _view_AddressRemoved(object sender, EventArg<int> e)
@@ -104,6 +123,14 @@ namespace VCFEditor.Presenter
{
if (_repository.dirty && _view.AskMessage("Exit without saving?", "Exit"))
e.Data = true;
if (!e.Data)
{
var state = _view.GetFormState();
ConfigRepository.Instance.FormState = state;
ConfigRepository.Instance.SaveConfig();
}
}
public void BeforeLeavingContact(object sender, EventArg<vCard> e)
{

View File

@@ -39,6 +39,9 @@ namespace vCardEditor.Repository
[Browsable(false)]
public FixedList Paths { get; set;}
[Browsable(false)]
public FormState FormState;
private ConfigRepository() { }

View File

@@ -6,6 +6,7 @@ using Thought.vCards;
using VCFEditor.Model;
using System.ComponentModel;
using vCardEditor.Repository;
using vCardEditor.View;
namespace VCFEditor.Repository
{
@@ -21,14 +22,14 @@ namespace VCFEditor.Repository
/// <summary>
/// Keep a copy of contact list when filtering
/// </summary>
private BindingList<Contact> OriginalContactList = null;
private BindingList<Contact> _contacts;
public BindingList<Contact> Contacts
private SortableBindingList<Contact> OriginalContactList = null;
private SortableBindingList<Contact> _contacts;
public SortableBindingList<Contact> Contacts
{
get
{
if (_contacts == null)
_contacts = new BindingList<Contact>();
_contacts = new SortableBindingList<Contact>();
return _contacts;
}
set
@@ -42,7 +43,7 @@ namespace VCFEditor.Repository
_fileHandler = fileHandler;
}
public BindingList<Contact> LoadContacts(string fileName)
public SortableBindingList<Contact> LoadContacts(string fileName)
{
Contacts.Clear();
@@ -167,11 +168,11 @@ namespace VCFEditor.Repository
return stream;
}
public BindingList<Contact> FilterContacts(string filter)
public SortableBindingList<Contact> FilterContacts(string filter)
{
var list = OriginalContactList.Where(i => (i.Name.IndexOf(filter, StringComparison.OrdinalIgnoreCase) >= 0) &&
!i.isDeleted);
Contacts = new BindingList<Contact>(list.ToList());
Contacts = new SortableBindingList<Contact>(list.ToList());
return Contacts;
}
@@ -329,7 +330,7 @@ namespace VCFEditor.Repository
}
}
private string GenerateStringFromVCard(vCard card)
public string GenerateStringFromVCard(vCard card)
{
vCardStandardWriter writer = new vCardStandardWriter();
TextWriter tw = new StringWriter();

View File

@@ -5,6 +5,7 @@ using System.Text;
using Thought.vCards;
using VCFEditor.Model;
using System.ComponentModel;
using vCardEditor.View;
namespace VCFEditor.Repository
{
@@ -12,9 +13,9 @@ namespace VCFEditor.Repository
{
bool dirty { get; }
string fileName { get; set; }
BindingList<Contact> Contacts { get; set; }
BindingList<Contact> LoadContacts(string fileName);
BindingList<Contact> FilterContacts(string p);
SortableBindingList<Contact> Contacts { get; set; }
SortableBindingList<Contact> LoadContacts(string fileName);
SortableBindingList<Contact> FilterContacts(string p);
void SaveContactsToFile(string fileName);
void DeleteContact();
void SetDirtyFlag(int index);
@@ -23,5 +24,7 @@ namespace VCFEditor.Repository
void ModifyImage(int index, vCardPhoto photo);
string GetExtension(string path);
void SaveImageToDisk(string imageFile, vCardPhoto image);
string GenerateStringFromVCard(vCard card);
}
}

View File

@@ -54,7 +54,7 @@
this.tableLayoutPanel.Controls.Add(this.okButton, 1, 5);
this.tableLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel.Location = new System.Drawing.Point(12, 11);
this.tableLayoutPanel.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.tableLayoutPanel.Margin = new System.Windows.Forms.Padding(4);
this.tableLayoutPanel.Name = "tableLayoutPanel";
this.tableLayoutPanel.RowCount = 6;
this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F));
@@ -73,7 +73,7 @@
//
this.logoPictureBox.Image = ((System.Drawing.Image)(resources.GetObject("logoPictureBox.Image")));
this.logoPictureBox.Location = new System.Drawing.Point(4, 4);
this.logoPictureBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.logoPictureBox.Margin = new System.Windows.Forms.Padding(4);
this.logoPictureBox.Name = "logoPictureBox";
this.tableLayoutPanel.SetRowSpan(this.logoPictureBox, 6);
this.logoPictureBox.Size = new System.Drawing.Size(145, 121);
@@ -148,7 +148,7 @@
this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.okButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.okButton.Location = new System.Drawing.Point(452, 295);
this.okButton.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.okButton.Margin = new System.Windows.Forms.Padding(4);
this.okButton.Name = "okButton";
this.okButton.Size = new System.Drawing.Size(100, 27);
this.okButton.TabIndex = 24;
@@ -162,7 +162,7 @@
this.ClientSize = new System.Drawing.Size(580, 348);
this.Controls.Add(this.tableLayoutPanel);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.Margin = new System.Windows.Forms.Padding(4);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "AboutDialog";

View File

@@ -35,33 +35,33 @@
//
// btnClose
//
this.btnClose.DialogResult = System.Windows.Forms.DialogResult.OK;
this.btnClose.Location = new System.Drawing.Point(337, 427);
this.btnClose.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.btnClose.Margin = new System.Windows.Forms.Padding(4);
this.btnClose.Name = "btnClose";
this.btnClose.Size = new System.Drawing.Size(100, 28);
this.btnClose.TabIndex = 0;
this.btnClose.Text = "Close";
this.btnClose.UseVisualStyleBackColor = true;
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
//
// pgConfig
//
this.pgConfig.Location = new System.Drawing.Point(16, 15);
this.pgConfig.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.pgConfig.Margin = new System.Windows.Forms.Padding(4);
this.pgConfig.Name = "pgConfig";
this.pgConfig.Size = new System.Drawing.Size(421, 405);
this.pgConfig.TabIndex = 1;
//
// btnCancel
//
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnCancel.Location = new System.Drawing.Point(229, 427);
this.btnCancel.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.btnCancel.Margin = new System.Windows.Forms.Padding(4);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(100, 28);
this.btnCancel.TabIndex = 0;
this.btnCancel.Text = "Cancel";
this.btnCancel.UseVisualStyleBackColor = true;
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// ConfigDialog
//
@@ -71,7 +71,7 @@
this.Controls.Add(this.pgConfig);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnClose);
this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.Margin = new System.Windows.Forms.Padding(4);
this.Name = "ConfigDialog";
this.Text = "Configuration Dialog";
this.ResumeLayout(false);

View File

@@ -10,19 +10,8 @@ namespace vCardEditor.View
public ConfigDialog()
{
InitializeComponent();
ConfigRepository conf = ConfigRepository.Instance;//.Clone();
ConfigRepository conf = ConfigRepository.Instance;//
pgConfig.SelectedObject = conf;
}
private void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
}
}

View File

@@ -61,7 +61,6 @@ namespace vCardEditor.View.Customs
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;
@@ -187,6 +186,7 @@ namespace vCardEditor.View.Customs
{
foreach (var item in card.DeliveryAddresses)
AddtabForAddress(item);
SelectedIndex = 0;
}
private void AddtabForAddress(vCardDeliveryAddress da)
@@ -224,7 +224,7 @@ namespace vCardEditor.View.Customs
//Remove every tab (except "+"). We don't call Clear() as it doesn't free memory.
while (TabCount > 1)
TabPages[TabCount - 1].Dispose();
TabPages[0].Dispose();
}
}
}

View File

@@ -0,0 +1,119 @@

namespace vCardEditor.View.Customs
{
partial class ColumnsDialog
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.cbFamilyName = new System.Windows.Forms.CheckBox();
this.cbCellular = new System.Windows.Forms.CheckBox();
this.cbName = new System.Windows.Forms.CheckBox();
this.btnCancel = new System.Windows.Forms.Button();
this.btnOK = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// cbFamilyName
//
this.cbFamilyName.AutoSize = true;
this.cbFamilyName.Location = new System.Drawing.Point(12, 39);
this.cbFamilyName.Name = "cbFamilyName";
this.cbFamilyName.Size = new System.Drawing.Size(107, 21);
this.cbFamilyName.TabIndex = 5;
this.cbFamilyName.Text = "FamilyName";
this.cbFamilyName.UseVisualStyleBackColor = true;
//
// cbCellular
//
this.cbCellular.AutoSize = true;
this.cbCellular.Location = new System.Drawing.Point(12, 66);
this.cbCellular.Name = "cbCellular";
this.cbCellular.Size = new System.Drawing.Size(77, 21);
this.cbCellular.TabIndex = 4;
this.cbCellular.Text = "Cellular";
this.cbCellular.UseVisualStyleBackColor = true;
//
// cbName
//
this.cbName.AutoSize = true;
this.cbName.Checked = true;
this.cbName.CheckState = System.Windows.Forms.CheckState.Checked;
this.cbName.Enabled = false;
this.cbName.Location = new System.Drawing.Point(12, 12);
this.cbName.Name = "cbName";
this.cbName.Size = new System.Drawing.Size(67, 21);
this.cbName.TabIndex = 3;
this.cbName.Text = "Name";
this.cbName.UseVisualStyleBackColor = true;
//
// btnCancel
//
this.btnCancel.CausesValidation = false;
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnCancel.Location = new System.Drawing.Point(190, 119);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(75, 23);
this.btnCancel.TabIndex = 10;
this.btnCancel.Text = "Cancel";
this.btnCancel.UseVisualStyleBackColor = true;
//
// btnOK
//
this.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK;
this.btnOK.Location = new System.Drawing.Point(109, 119);
this.btnOK.Name = "btnOK";
this.btnOK.Size = new System.Drawing.Size(75, 23);
this.btnOK.TabIndex = 9;
this.btnOK.Text = "OK";
this.btnOK.UseVisualStyleBackColor = true;
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
//
// ColumnsDialog
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(277, 149);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnOK);
this.Controls.Add(this.cbFamilyName);
this.Controls.Add(this.cbCellular);
this.Controls.Add(this.cbName);
this.Name = "ColumnsDialog";
this.Text = "Columns...";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.CheckBox cbFamilyName;
private System.Windows.Forms.CheckBox cbCellular;
private System.Windows.Forms.CheckBox cbName;
private System.Windows.Forms.Button btnCancel;
private System.Windows.Forms.Button btnOK;
}
}

View File

@@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Windows.Forms;
using vCardEditor.Model;
namespace vCardEditor.View.Customs
{
public partial class ColumnsDialog : Form
{
private readonly List<CheckBox> _checkBoxes;
public List<Columns> Columns { get; }
public ColumnsDialog(List<Columns> columns)
{
InitializeComponent();
_checkBoxes = Controls.OfType<CheckBox>().ToList();
Columns = columns;
foreach (var item in columns)
{
switch (item)
{
case Model.Columns.FamilyName:
cbFamilyName.Checked = true;
break;
case Model.Columns.Cellular:
cbCellular.Checked = true;
break;
}
}
}
private void btnOK_Click(object sender, EventArgs e)
{
Columns.Clear();
var total = _checkBoxes
.Where(checkBox => checkBox.Checked);
foreach (var item in total)
{
var enumType = (Columns)Enum.Parse(typeof(Columns), item.Text, true);
Columns.Add(enumType);
}
}
}
}

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -2,15 +2,14 @@
using System.Collections.Generic;
using Thought.vCards;
using VCFEditor.Model;
using System.ComponentModel;
using System.Windows.Forms;
using vCardEditor.Model;
using vCardEditor.View;
namespace VCFEditor.View
{
public interface IMainView
{
event EventHandler<EventArg<FormState>> LoadForm;
event EventHandler AddContact;
event EventHandler DeleteContact;
event EventHandler BeforeOpeningNewFile;
@@ -26,9 +25,10 @@ namespace VCFEditor.View
event EventHandler<EventArg<List<vCardDeliveryAddressTypes>>> AddressAdded;
event EventHandler<EventArg<List<vCardDeliveryAddressTypes>>> AddressModified;
event EventHandler<EventArg<int>> AddressRemoved;
event EventHandler CopyTextToClipboardEvent;
int SelectedContactIndex { get; }
void DisplayContacts(BindingList<Contact> contacts);
void DisplayContacts(SortableBindingList<Contact> contacts);
void DisplayContactDetail(vCard card, string FileName);
void ClearContactDetail();
bool AskMessage(string msg, string caption);
@@ -36,5 +36,9 @@ namespace VCFEditor.View
string DisplayOpenDialog(string filter);
string DisplaySaveDialog(string filename);
void UpdateMRUMenu(FixedList MRUList);
void SendTextToClipBoard(string text);
FormState GetFormState();
}
}

View File

@@ -0,0 +1,48 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Reflection;
namespace vCardEditor.View.Libs
{
public class PropertyComparer<T> : IComparer<T>
{
private readonly IComparer comparer;
private PropertyDescriptor propertyDescriptor;
private int reverse;
public PropertyComparer(PropertyDescriptor property, ListSortDirection direction)
{
this.propertyDescriptor = property;
Type comparerForPropertyType = typeof(Comparer<>).MakeGenericType(property.PropertyType);
this.comparer = (IComparer)comparerForPropertyType.InvokeMember("Default", BindingFlags.Static | BindingFlags.GetProperty | BindingFlags.Public, null, null, null);
this.SetListSortDirection(direction);
}
#region IComparer<T> Members
public int Compare(T x, T y)
{
return this.reverse * this.comparer.Compare(this.propertyDescriptor.GetValue(x), this.propertyDescriptor.GetValue(y));
}
#endregion
private void SetPropertyDescriptor(PropertyDescriptor descriptor)
{
this.propertyDescriptor = descriptor;
}
private void SetListSortDirection(ListSortDirection direction)
{
this.reverse = direction == ListSortDirection.Ascending ? 1 : -1;
}
public void SetPropertyAndDirection(PropertyDescriptor descriptor, ListSortDirection direction)
{
this.SetPropertyDescriptor(descriptor);
this.SetListSortDirection(direction);
}
}
}

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 dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = 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();
@@ -43,10 +43,13 @@ namespace vCardEditor.View
this.miQuit = new System.Windows.Forms.ToolStripMenuItem();
this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.copyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.miAbout = new System.Windows.Forms.ToolStripMenuItem();
this.toolsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.imagesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.exportToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.clearToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.countToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.miAbout = new System.Windows.Forms.ToolStripMenuItem();
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
this.toolStrip1 = new System.Windows.Forms.ToolStrip();
this.tbsNew = new System.Windows.Forms.ToolStripButton();
@@ -81,7 +84,12 @@ namespace vCardEditor.View
this.textBoxFilter = new System.Windows.Forms.TextBox();
this.dgContacts = new System.Windows.Forms.DataGridView();
this.Column1 = new System.Windows.Forms.DataGridViewCheckBoxColumn();
this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.FormattedName = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.FamilyName = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Cellular = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.modifiyColumnsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.tbcAddress = new vCardEditor.View.Customs.AddressTabControl();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.FormattedTitleValue = new vCardEditor.View.StateTextBox();
@@ -105,6 +113,11 @@ namespace vCardEditor.View
((System.ComponentModel.ISupportInitialize)(this.bsContacts)).BeginInit();
this.gbNameList.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dgContacts)).BeginInit();
this.contextMenuStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
this.tbcAddress.SuspendLayout();
this.SuspendLayout();
//
@@ -114,11 +127,11 @@ namespace vCardEditor.View
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.fileToolStripMenuItem,
this.editToolStripMenuItem,
this.helpToolStripMenuItem,
this.toolsToolStripMenuItem});
this.toolsToolStripMenuItem,
this.helpToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(1145, 30);
this.menuStrip1.Size = new System.Drawing.Size(1197, 30);
this.menuStrip1.TabIndex = 0;
this.menuStrip1.Text = "menuStrip1";
//
@@ -190,6 +203,43 @@ namespace vCardEditor.View
this.copyToolStripMenuItem.Name = "copyToolStripMenuItem";
this.copyToolStripMenuItem.Size = new System.Drawing.Size(126, 26);
this.copyToolStripMenuItem.Text = "Copy";
this.copyToolStripMenuItem.Click += new System.EventHandler(this.copyToolStripMenuItem_Click);
//
// toolsToolStripMenuItem
//
this.toolsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.imagesToolStripMenuItem});
this.toolsToolStripMenuItem.Name = "toolsToolStripMenuItem";
this.toolsToolStripMenuItem.Size = new System.Drawing.Size(58, 26);
this.toolsToolStripMenuItem.Text = "Tools";
//
// imagesToolStripMenuItem
//
this.imagesToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.exportToolStripMenuItem,
this.clearToolStripMenuItem,
this.countToolStripMenuItem});
this.imagesToolStripMenuItem.Name = "imagesToolStripMenuItem";
this.imagesToolStripMenuItem.Size = new System.Drawing.Size(140, 26);
this.imagesToolStripMenuItem.Text = "Images";
//
// exportToolStripMenuItem
//
this.exportToolStripMenuItem.Name = "exportToolStripMenuItem";
this.exportToolStripMenuItem.Size = new System.Drawing.Size(135, 26);
this.exportToolStripMenuItem.Text = "Export";
//
// clearToolStripMenuItem
//
this.clearToolStripMenuItem.Name = "clearToolStripMenuItem";
this.clearToolStripMenuItem.Size = new System.Drawing.Size(135, 26);
this.clearToolStripMenuItem.Text = "Clear";
//
// countToolStripMenuItem
//
this.countToolStripMenuItem.Name = "countToolStripMenuItem";
this.countToolStripMenuItem.Size = new System.Drawing.Size(135, 26);
this.countToolStripMenuItem.Text = "Count";
//
// helpToolStripMenuItem
//
@@ -208,27 +258,13 @@ namespace vCardEditor.View
this.miAbout.Text = "&About";
this.miAbout.Click += new System.EventHandler(this.tbsAbout_Click);
//
// toolsToolStripMenuItem
//
this.toolsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.imagesToolStripMenuItem});
this.toolsToolStripMenuItem.Name = "toolsToolStripMenuItem";
this.toolsToolStripMenuItem.Size = new System.Drawing.Size(58, 26);
this.toolsToolStripMenuItem.Text = "Tools";
//
// imagesToolStripMenuItem
//
this.imagesToolStripMenuItem.Name = "imagesToolStripMenuItem";
this.imagesToolStripMenuItem.Size = new System.Drawing.Size(140, 26);
this.imagesToolStripMenuItem.Text = "Images";
//
// statusStrip1
//
this.statusStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
this.statusStrip1.Location = new System.Drawing.Point(0, 582);
this.statusStrip1.Location = new System.Drawing.Point(0, 624);
this.statusStrip1.Name = "statusStrip1";
this.statusStrip1.Padding = new System.Windows.Forms.Padding(1, 0, 19, 0);
this.statusStrip1.Size = new System.Drawing.Size(1145, 22);
this.statusStrip1.Size = new System.Drawing.Size(1197, 22);
this.statusStrip1.TabIndex = 1;
this.statusStrip1.Text = "statusStrip1";
//
@@ -245,7 +281,7 @@ namespace vCardEditor.View
this.toolStripSeparator});
this.toolStrip1.Location = new System.Drawing.Point(0, 30);
this.toolStrip1.Name = "toolStrip1";
this.toolStrip1.Size = new System.Drawing.Size(1145, 31);
this.toolStrip1.Size = new System.Drawing.Size(1197, 31);
this.toolStrip1.TabIndex = 1;
this.toolStrip1.Text = "toolStrip1";
//
@@ -330,12 +366,12 @@ namespace vCardEditor.View
this.CellularPhoneLabel.Name = "CellularPhoneLabel";
this.CellularPhoneLabel.Size = new System.Drawing.Size(60, 23);
this.CellularPhoneLabel.TabIndex = 2;
this.CellularPhoneLabel.Text = "Mobile:";
this.CellularPhoneLabel.Text = "Cellular:";
this.CellularPhoneLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// WorkPhoneLabel
//
this.WorkPhoneLabel.Location = new System.Drawing.Point(16, 91);
this.WorkPhoneLabel.Location = new System.Drawing.Point(11, 86);
this.WorkPhoneLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.WorkPhoneLabel.Name = "WorkPhoneLabel";
this.WorkPhoneLabel.Size = new System.Drawing.Size(60, 23);
@@ -345,9 +381,6 @@ namespace vCardEditor.View
//
// gbContactDetail
//
this.gbContactDetail.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.gbContactDetail.Controls.Add(this.btnExportImage);
this.gbContactDetail.Controls.Add(this.btnRemoveImage);
this.gbContactDetail.Controls.Add(this.groupBox4);
@@ -355,18 +388,20 @@ namespace vCardEditor.View
this.gbContactDetail.Controls.Add(this.groupBox2);
this.gbContactDetail.Controls.Add(this.groupBox1);
this.gbContactDetail.Controls.Add(this.PhotoBox);
this.gbContactDetail.Dock = System.Windows.Forms.DockStyle.Fill;
this.gbContactDetail.Enabled = false;
this.gbContactDetail.Location = new System.Drawing.Point(333, 64);
this.gbContactDetail.Location = new System.Drawing.Point(0, 0);
this.gbContactDetail.Margin = new System.Windows.Forms.Padding(4);
this.gbContactDetail.Name = "gbContactDetail";
this.gbContactDetail.Padding = new System.Windows.Forms.Padding(4);
this.gbContactDetail.Size = new System.Drawing.Size(796, 510);
this.gbContactDetail.Size = new System.Drawing.Size(796, 563);
this.gbContactDetail.TabIndex = 3;
this.gbContactDetail.TabStop = false;
this.gbContactDetail.Text = "Contact Detail :";
//
// btnExportImage
//
this.btnExportImage.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnExportImage.BackColor = System.Drawing.SystemColors.Window;
this.btnExportImage.Image = ((System.Drawing.Image)(resources.GetObject("btnExportImage.Image")));
this.btnExportImage.Location = new System.Drawing.Point(744, 170);
@@ -378,6 +413,7 @@ namespace vCardEditor.View
//
// btnRemoveImage
//
this.btnRemoveImage.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnRemoveImage.BackColor = System.Drawing.SystemColors.Window;
this.btnRemoveImage.Image = ((System.Drawing.Image)(resources.GetObject("btnRemoveImage.Image")));
this.btnRemoveImage.Location = new System.Drawing.Point(768, 170);
@@ -393,11 +429,11 @@ namespace vCardEditor.View
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox4.Controls.Add(this.tbcAddress);
this.groupBox4.Location = new System.Drawing.Point(24, 190);
this.groupBox4.Location = new System.Drawing.Point(8, 190);
this.groupBox4.Margin = new System.Windows.Forms.Padding(4);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Padding = new System.Windows.Forms.Padding(4);
this.groupBox4.Size = new System.Drawing.Size(764, 182);
this.groupBox4.Size = new System.Drawing.Size(780, 228);
this.groupBox4.TabIndex = 1;
this.groupBox4.TabStop = false;
this.groupBox4.Text = "Address:";
@@ -416,11 +452,11 @@ namespace vCardEditor.View
this.groupBox3.Controls.Add(this.label1);
this.groupBox3.Controls.Add(this.FormattedNameValue);
this.groupBox3.Controls.Add(this.FormattedNameLabel);
this.groupBox3.Location = new System.Drawing.Point(24, 41);
this.groupBox3.Location = new System.Drawing.Point(8, 23);
this.groupBox3.Margin = new System.Windows.Forms.Padding(4);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Padding = new System.Windows.Forms.Padding(4);
this.groupBox3.Size = new System.Drawing.Size(571, 142);
this.groupBox3.Size = new System.Drawing.Size(571, 159);
this.groupBox3.TabIndex = 0;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "Name";
@@ -477,17 +513,16 @@ namespace vCardEditor.View
//
// groupBox2
//
this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.groupBox2.Controls.Add(this.EmailAddressLabel);
this.groupBox2.Controls.Add(this.EmailAddressValue);
this.groupBox2.Controls.Add(this.PersonalWebSiteLabel);
this.groupBox2.Controls.Add(this.PersonalWebSiteValue);
this.groupBox2.Location = new System.Drawing.Point(348, 373);
this.groupBox2.Location = new System.Drawing.Point(360, 426);
this.groupBox2.Margin = new System.Windows.Forms.Padding(4);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Padding = new System.Windows.Forms.Padding(4);
this.groupBox2.Size = new System.Drawing.Size(440, 129);
this.groupBox2.Size = new System.Drawing.Size(420, 129);
this.groupBox2.TabIndex = 3;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Web : ";
@@ -522,11 +557,11 @@ namespace vCardEditor.View
this.groupBox1.Controls.Add(this.WorkPhoneValue);
this.groupBox1.Controls.Add(this.CellularPhoneLabel);
this.groupBox1.Controls.Add(this.CellularPhoneValue);
this.groupBox1.Location = new System.Drawing.Point(29, 373);
this.groupBox1.Location = new System.Drawing.Point(8, 426);
this.groupBox1.Margin = new System.Windows.Forms.Padding(4);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Padding = new System.Windows.Forms.Padding(4);
this.groupBox1.Size = new System.Drawing.Size(377, 129);
this.groupBox1.Size = new System.Drawing.Size(344, 129);
this.groupBox1.TabIndex = 2;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Phones : ";
@@ -547,25 +582,25 @@ namespace vCardEditor.View
//
// gbNameList
//
this.gbNameList.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.gbNameList.Controls.Add(this.dgContacts);
this.gbNameList.Controls.Add(this.btnClearFilter);
this.gbNameList.Controls.Add(this.textBoxFilter);
this.gbNameList.Controls.Add(this.dgContacts);
this.gbNameList.Dock = System.Windows.Forms.DockStyle.Fill;
this.gbNameList.Enabled = false;
this.gbNameList.Location = new System.Drawing.Point(17, 64);
this.gbNameList.Location = new System.Drawing.Point(0, 0);
this.gbNameList.Margin = new System.Windows.Forms.Padding(4);
this.gbNameList.Name = "gbNameList";
this.gbNameList.Padding = new System.Windows.Forms.Padding(4);
this.gbNameList.Size = new System.Drawing.Size(308, 510);
this.gbNameList.Size = new System.Drawing.Size(397, 563);
this.gbNameList.TabIndex = 2;
this.gbNameList.TabStop = false;
this.gbNameList.Text = "Name List :";
//
// btnClearFilter
//
this.btnClearFilter.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnClearFilter.Image = ((System.Drawing.Image)(resources.GetObject("btnClearFilter.Image")));
this.btnClearFilter.Location = new System.Drawing.Point(268, 17);
this.btnClearFilter.Location = new System.Drawing.Point(357, 17);
this.btnClearFilter.Margin = new System.Windows.Forms.Padding(4);
this.btnClearFilter.Name = "btnClearFilter";
this.btnClearFilter.Size = new System.Drawing.Size(37, 27);
@@ -575,10 +610,12 @@ namespace vCardEditor.View
//
// textBoxFilter
//
this.textBoxFilter.Location = new System.Drawing.Point(4, 18);
this.textBoxFilter.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.textBoxFilter.Location = new System.Drawing.Point(8, 18);
this.textBoxFilter.Margin = new System.Windows.Forms.Padding(4);
this.textBoxFilter.Name = "textBoxFilter";
this.textBoxFilter.Size = new System.Drawing.Size(256, 22);
this.textBoxFilter.Size = new System.Drawing.Size(341, 22);
this.textBoxFilter.TabIndex = 0;
this.textBoxFilter.TextChanged += new System.EventHandler(this.textBoxFilter_TextChanged);
//
@@ -587,27 +624,31 @@ namespace vCardEditor.View
this.dgContacts.AllowUserToAddRows = false;
this.dgContacts.AllowUserToDeleteRows = false;
this.dgContacts.AllowUserToResizeRows = false;
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)));
dataGridViewCellStyle4.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
this.dgContacts.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle4;
this.dgContacts.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.dgContacts.AutoGenerateColumns = false;
this.dgContacts.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.dgContacts.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.None;
this.dgContacts.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgContacts.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.Column1,
this.Column2});
this.FormattedName,
this.FamilyName,
this.Cellular});
this.dgContacts.DataSource = this.bsContacts;
this.dgContacts.Location = new System.Drawing.Point(4, 50);
this.dgContacts.Location = new System.Drawing.Point(8, 47);
this.dgContacts.Margin = new System.Windows.Forms.Padding(4);
this.dgContacts.MultiSelect = false;
this.dgContacts.Name = "dgContacts";
this.dgContacts.RowHeadersVisible = false;
this.dgContacts.RowHeadersWidth = 51;
this.dgContacts.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.dgContacts.Size = new System.Drawing.Size(300, 455);
this.dgContacts.Size = new System.Drawing.Size(389, 508);
this.dgContacts.TabIndex = 2;
this.dgContacts.CellContextMenuStripNeeded += new System.Windows.Forms.DataGridViewCellContextMenuStripNeededEventHandler(this.dgContacts_CellContextMenuStripNeeded);
this.dgContacts.RowLeave += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgContacts_RowLeave);
this.dgContacts.SelectionChanged += new System.EventHandler(this.dgContacts_SelectionChanged);
//
@@ -619,17 +660,72 @@ namespace vCardEditor.View
this.Column1.Name = "Column1";
this.Column1.Width = 50;
//
// Column2
// FormattedName
//
this.Column2.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.Column2.DataPropertyName = "Name";
this.Column2.HeaderText = "Name";
this.Column2.MinimumWidth = 6;
this.Column2.Name = "Column2";
this.Column2.ReadOnly = true;
this.FormattedName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.FormattedName.DataPropertyName = "Name";
this.FormattedName.HeaderText = "Name";
this.FormattedName.MinimumWidth = 6;
this.FormattedName.Name = "FormattedName";
this.FormattedName.ReadOnly = true;
//
// FamilyName
//
this.FamilyName.DataPropertyName = "FamilyName";
this.FamilyName.HeaderText = "FamilyName";
this.FamilyName.MinimumWidth = 6;
this.FamilyName.Name = "FamilyName";
this.FamilyName.ReadOnly = true;
this.FamilyName.Visible = false;
this.FamilyName.Width = 125;
//
// Cellular
//
this.Cellular.DataPropertyName = "Cellular";
this.Cellular.HeaderText = "Cellular";
this.Cellular.MinimumWidth = 6;
this.Cellular.Name = "Cellular";
this.Cellular.ReadOnly = true;
this.Cellular.Visible = false;
this.Cellular.Width = 125;
//
// contextMenuStrip1
//
this.contextMenuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.modifiyColumnsToolStripMenuItem});
this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(191, 28);
//
// modifiyColumnsToolStripMenuItem
//
this.modifiyColumnsToolStripMenuItem.Name = "modifiyColumnsToolStripMenuItem";
this.modifiyColumnsToolStripMenuItem.Size = new System.Drawing.Size(190, 24);
this.modifiyColumnsToolStripMenuItem.Text = "Modifiy Columns";
this.modifiyColumnsToolStripMenuItem.Click += new System.EventHandler(this.modifiyColumnsToolStripMenuItem_Click);
//
// splitContainer1
//
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer1.Location = new System.Drawing.Point(0, 61);
this.splitContainer1.Name = "splitContainer1";
//
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.Controls.Add(this.gbNameList);
//
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.gbContactDetail);
this.splitContainer1.Size = new System.Drawing.Size(1197, 563);
this.splitContainer1.SplitterDistance = 397;
this.splitContainer1.TabIndex = 4;
//
// tbcAddress
//
this.tbcAddress.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tbcAddress.Controls.Add(this.tabPage1);
this.tbcAddress.DrawMode = System.Windows.Forms.TabDrawMode.OwnerDrawFixed;
this.tbcAddress.Location = new System.Drawing.Point(17, 23);
@@ -638,7 +734,7 @@ namespace vCardEditor.View
this.tbcAddress.Padding = new System.Drawing.Point(12, 4);
this.tbcAddress.SelectedIndex = 0;
this.tbcAddress.ShowToolTips = true;
this.tbcAddress.Size = new System.Drawing.Size(739, 144);
this.tbcAddress.Size = new System.Drawing.Size(755, 190);
this.tbcAddress.TabIndex = 0;
//
// tabPage1
@@ -647,7 +743,7 @@ namespace vCardEditor.View
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.Size = new System.Drawing.Size(747, 159);
this.tabPage1.TabIndex = 0;
this.tabPage1.Text = " ";
//
@@ -677,8 +773,6 @@ namespace vCardEditor.View
//
// middleNameValue
//
this.middleNameValue.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.middleNameValue.Location = new System.Drawing.Point(237, 53);
this.middleNameValue.Margin = new System.Windows.Forms.Padding(4);
this.middleNameValue.Name = "middleNameValue";
@@ -720,7 +814,7 @@ namespace vCardEditor.View
this.EmailAddressValue.Margin = new System.Windows.Forms.Padding(4);
this.EmailAddressValue.Name = "EmailAddressValue";
this.EmailAddressValue.oldText = null;
this.EmailAddressValue.Size = new System.Drawing.Size(360, 22);
this.EmailAddressValue.Size = new System.Drawing.Size(340, 22);
this.EmailAddressValue.TabIndex = 1;
this.EmailAddressValue.LostFocus += new System.EventHandler(this.Value_TextChanged);
this.EmailAddressValue.Validated += new System.EventHandler(this.Value_TextChanged);
@@ -733,7 +827,7 @@ namespace vCardEditor.View
this.PersonalWebSiteValue.Margin = new System.Windows.Forms.Padding(4);
this.PersonalWebSiteValue.Name = "PersonalWebSiteValue";
this.PersonalWebSiteValue.oldText = null;
this.PersonalWebSiteValue.Size = new System.Drawing.Size(360, 22);
this.PersonalWebSiteValue.Size = new System.Drawing.Size(340, 22);
this.PersonalWebSiteValue.TabIndex = 3;
this.PersonalWebSiteValue.LostFocus += new System.EventHandler(this.Value_TextChanged);
this.PersonalWebSiteValue.Validated += new System.EventHandler(this.Value_TextChanged);
@@ -746,7 +840,7 @@ namespace vCardEditor.View
this.HomePhoneValue.Margin = new System.Windows.Forms.Padding(4);
this.HomePhoneValue.Name = "HomePhoneValue";
this.HomePhoneValue.oldText = null;
this.HomePhoneValue.Size = new System.Drawing.Size(229, 22);
this.HomePhoneValue.Size = new System.Drawing.Size(252, 22);
this.HomePhoneValue.TabIndex = 1;
this.HomePhoneValue.LostFocus += new System.EventHandler(this.Value_TextChanged);
this.HomePhoneValue.Validated += new System.EventHandler(this.Value_TextChanged);
@@ -759,7 +853,7 @@ namespace vCardEditor.View
this.WorkPhoneValue.Margin = new System.Windows.Forms.Padding(4);
this.WorkPhoneValue.Name = "WorkPhoneValue";
this.WorkPhoneValue.oldText = null;
this.WorkPhoneValue.Size = new System.Drawing.Size(229, 22);
this.WorkPhoneValue.Size = new System.Drawing.Size(252, 22);
this.WorkPhoneValue.TabIndex = 5;
this.WorkPhoneValue.LostFocus += new System.EventHandler(this.Value_TextChanged);
this.WorkPhoneValue.Validated += new System.EventHandler(this.Value_TextChanged);
@@ -772,7 +866,7 @@ namespace vCardEditor.View
this.CellularPhoneValue.Margin = new System.Windows.Forms.Padding(4);
this.CellularPhoneValue.Name = "CellularPhoneValue";
this.CellularPhoneValue.oldText = null;
this.CellularPhoneValue.Size = new System.Drawing.Size(229, 22);
this.CellularPhoneValue.Size = new System.Drawing.Size(252, 22);
this.CellularPhoneValue.TabIndex = 3;
this.CellularPhoneValue.LostFocus += new System.EventHandler(this.Value_TextChanged);
this.CellularPhoneValue.Validated += new System.EventHandler(this.Value_TextChanged);
@@ -782,9 +876,8 @@ namespace vCardEditor.View
this.AllowDrop = true;
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1145, 604);
this.Controls.Add(this.gbNameList);
this.Controls.Add(this.gbContactDetail);
this.ClientSize = new System.Drawing.Size(1197, 646);
this.Controls.Add(this.splitContainer1);
this.Controls.Add(this.toolStrip1);
this.Controls.Add(this.statusStrip1);
this.Controls.Add(this.menuStrip1);
@@ -794,6 +887,7 @@ namespace vCardEditor.View
this.Name = "MainForm";
this.Text = "vCard Editor";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing);
this.Load += new System.EventHandler(this.MainForm_Load);
this.DragDrop += new System.Windows.Forms.DragEventHandler(this.MainForm_DragDrop);
this.DragEnter += new System.Windows.Forms.DragEventHandler(this.MainForm_DragEnter);
this.menuStrip1.ResumeLayout(false);
@@ -813,6 +907,11 @@ namespace vCardEditor.View
this.gbNameList.ResumeLayout(false);
this.gbNameList.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.dgContacts)).EndInit();
this.contextMenuStrip1.ResumeLayout(false);
this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
this.splitContainer1.ResumeLayout(false);
this.tbcAddress.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
@@ -847,8 +946,6 @@ namespace vCardEditor.View
private System.Windows.Forms.GroupBox gbNameList;
private System.Windows.Forms.TextBox textBoxFilter;
private System.Windows.Forms.DataGridView dgContacts;
private System.Windows.Forms.DataGridViewCheckBoxColumn Column1;
private System.Windows.Forms.DataGridViewTextBoxColumn Column2;
private System.Windows.Forms.Button btnClearFilter;
internal System.Windows.Forms.PictureBox PhotoBox;
private System.Windows.Forms.ToolStripMenuItem recentFilesMenuItem;
@@ -882,5 +979,15 @@ namespace vCardEditor.View
private System.Windows.Forms.ToolStripMenuItem imagesToolStripMenuItem;
private AddressTabControl tbcAddress;
private System.Windows.Forms.TabPage tabPage1;
private System.Windows.Forms.ToolStripMenuItem exportToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem clearToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem countToolStripMenuItem;
private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
private System.Windows.Forms.ToolStripMenuItem modifiyColumnsToolStripMenuItem;
private System.Windows.Forms.DataGridViewCheckBoxColumn Column1;
private System.Windows.Forms.DataGridViewTextBoxColumn FormattedName;
private System.Windows.Forms.DataGridViewTextBoxColumn FamilyName;
private System.Windows.Forms.DataGridViewTextBoxColumn Cellular;
private System.Windows.Forms.SplitContainer splitContainer1;
}
}

View File

@@ -9,11 +9,13 @@ using vCardEditor.Repository;
using vCardEditor.Model;
using System.Drawing;
using System.Collections.Generic;
using vCardEditor.View.Customs;
namespace vCardEditor.View
{
public partial class MainForm : Form, IMainView
{
public event EventHandler<EventArg<FormState>> LoadForm;
public event EventHandler AddContact;
public event EventHandler SaveContactsSelected;
public event EventHandler BeforeOpeningNewFile;
@@ -29,6 +31,7 @@ namespace vCardEditor.View
public event EventHandler<EventArg<List<vCardDeliveryAddressTypes>>> AddressModified;
public event EventHandler<EventArg<int>> AddressRemoved;
public event EventHandler ExportImage;
public event EventHandler CopyTextToClipboardEvent;
ComponentResourceManager resources;
@@ -61,7 +64,7 @@ namespace vCardEditor.View
NewFileOpened?.Invoke(sender, new EventArg<string>(string.Empty));
}
public void DisplayContacts(BindingList<Contact> contacts)
public void DisplayContacts(SortableBindingList<Contact> contacts)
{
if (contacts != null)
bsContacts.DataSource = contacts;
@@ -324,7 +327,6 @@ namespace vCardEditor.View
e.Cancel = evt.Data;
ConfigRepository.Instance.SaveConfig();
}
public bool AskMessage(string msg, string caption)
@@ -407,5 +409,113 @@ namespace vCardEditor.View
{
ExportImage?.Invoke(sender, e);
}
private void copyToolStripMenuItem_Click(object sender, EventArgs e)
{
CopyTextToClipboardEvent?.Invoke(sender, e);
}
public void SendTextToClipBoard(string text)
{
Clipboard.SetText(text);
}
private void dgContacts_CellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs e)
{
if (e.RowIndex == -1)
{
e.ContextMenuStrip = contextMenuStrip1;
}
}
private void modifiyColumnsToolStripMenuItem_Click(object sender, EventArgs e)
{
List<Columns> Columns = GetListColumnsForDataGrid();
var dialog = new ColumnsDialog(Columns);
if (dialog.ShowDialog() == DialogResult.OK)
{
ToggleAllColumnsToInvisible();
ToggleOnlySelected(dialog.Columns);
}
}
private List<Columns> GetListColumnsForDataGrid()
{
List<Columns> Columns = new List<Columns>();
for (int i = 2; i < dgContacts.Columns.Count; i++)
{
if (dgContacts.Columns[i].Visible)
{
var name = dgContacts.Columns[i].Name;
var enumType = (Columns)Enum.Parse(typeof(Columns), name, true);
Columns.Add(enumType);
}
}
return Columns;
}
private void ToggleOnlySelected(List<Columns> columns)
{
foreach (var item in columns)
{
switch (item)
{
case Columns.FamilyName:
dgContacts.Columns["FamilyName"].Visible = true;
break;
case Columns.Cellular:
dgContacts.Columns["Cellular"].Visible = true;
break;
}
}
}
private void ToggleAllColumnsToInvisible()
{
for (int i = 2; i < dgContacts.Columns.Count; i++)
{
dgContacts.Columns[i].Visible = false;
}
}
public FormState GetFormState()
{
return new FormState
{
Columns = GetListColumnsForDataGrid(),
X = Location.X,
Y = Location.Y,
Height = Size.Height,
Width = Size.Width,
splitterPosition = splitContainer1.SplitterDistance
};
}
private void MainForm_Load(object sender, EventArgs e)
{
var evt = new EventArg<FormState>(new FormState());
LoadForm?.Invoke(sender, evt);
//TODO: Better way to check if state was serialised!
var state = evt.Data;
if (state.Width != 0 && state.Height != 0)
{
Size = new Size(state.Width, state.Height);
Location = new Point(state.X , state.Y);
splitContainer1.SplitterDistance = state.splitterPosition;
if (state.Columns != null)
{
ToggleOnlySelected(state.Columns);
}
}
}
}
}

View File

@@ -324,9 +324,18 @@
<metadata name="Column1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column2.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<metadata name="FormattedName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="FamilyName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Cellular.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>618, 17</value>
</metadata>
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
AAABAAkAAAAAAAEAIAAHLwAAlgAAAICAAAABACAAKAgBAJ0vAABgYAAAAQAgAKiUAADFNwEASEgAAAEA

View File

@@ -0,0 +1,98 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using vCardEditor.View.Libs;
namespace vCardEditor.View
{
public class SortableBindingList<T> : BindingList<T>
{
private readonly Dictionary<Type, PropertyComparer<T>> comparers;
private bool isSorted;
private ListSortDirection listSortDirection;
private PropertyDescriptor propertyDescriptor;
public SortableBindingList()
: base(new List<T>())
{
this.comparers = new Dictionary<Type, PropertyComparer<T>>();
}
public SortableBindingList(IEnumerable<T> enumeration)
: base(new List<T>(enumeration))
{
this.comparers = new Dictionary<Type, PropertyComparer<T>>();
}
protected override bool SupportsSortingCore
{
get { return true; }
}
protected override bool IsSortedCore
{
get { return this.isSorted; }
}
protected override PropertyDescriptor SortPropertyCore
{
get { return this.propertyDescriptor; }
}
protected override ListSortDirection SortDirectionCore
{
get { return this.listSortDirection; }
}
protected override bool SupportsSearchingCore
{
get { return true; }
}
protected override void ApplySortCore(PropertyDescriptor property, ListSortDirection direction)
{
List<T> itemsList = (List<T>)this.Items;
Type propertyType = property.PropertyType;
PropertyComparer<T> comparer;
if (!this.comparers.TryGetValue(propertyType, out comparer))
{
comparer = new PropertyComparer<T>(property, direction);
this.comparers.Add(propertyType, comparer);
}
comparer.SetPropertyAndDirection(property, direction);
itemsList.Sort(comparer);
this.propertyDescriptor = property;
this.listSortDirection = direction;
this.isSorted = true;
this.OnListChanged(new ListChangedEventArgs(ListChangedType.Reset, -1));
}
protected override void RemoveSortCore()
{
this.isSorted = false;
this.propertyDescriptor = base.SortPropertyCore;
this.listSortDirection = base.SortDirectionCore;
this.OnListChanged(new ListChangedEventArgs(ListChangedType.Reset, -1));
}
protected override int FindCore(PropertyDescriptor property, object key)
{
int count = this.Count;
for (int i = 0; i < count; ++i)
{
T element = this[i];
if (property.GetValue(element).Equals(key))
{
return i;
}
}
return -1;
}
}
}

View File

@@ -66,8 +66,10 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Model\Columns.cs" />
<Compile Include="Model\FixedList.cs" />
<Compile Include="Model\ObjectCopier.cs" />
<Compile Include="Model\FormState.cs" />
<Compile Include="Repository\ConfigRepository.cs" />
<Compile Include="Repository\ContactRepository.cs" />
<Compile Include="Repository\FileHandler.cs" />
@@ -148,14 +150,22 @@
<Compile Include="View\Customs\AddressTabControl.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="View\Customs\ColumnsDialog.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="View\Customs\ColumnsDialog.Designer.cs">
<DependentUpon>ColumnsDialog.cs</DependentUpon>
</Compile>
<Compile Include="View\EventArgs.cs" />
<Compile Include="View\IMainView.cs" />
<Compile Include="View\Libs\PropertyComparer.cs" />
<Compile Include="View\MainForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="View\MainForm.Designer.cs">
<DependentUpon>MainForm.cs</DependentUpon>
</Compile>
<Compile Include="View\SortableBindingList.cs" />
<Compile Include="View\StateTextBox.cs">
<SubType>Component</SubType>
</Compile>
@@ -182,6 +192,9 @@
<EmbeddedResource Include="View\Customs\AddressBox.resx">
<DependentUpon>AddressBox.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="View\Customs\ColumnsDialog.resx">
<DependentUpon>ColumnsDialog.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="View\MainForm.resx">
<DependentUpon>MainForm.cs</DependentUpon>
</EmbeddedResource>

View File

@@ -1,16 +1,11 @@
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using VCFEditor;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using VCFEditor.View;
using VCFEditor.Presenter;
using VCFEditor.Model;
using System.ComponentModel;
using VCFEditor.Repository;
using vCardEditor.Repository;
using NSubstitute;
using vCardEditor.View;
namespace vCardEditor_Test
{
@@ -25,9 +20,7 @@ namespace vCardEditor_Test
fileHandler.ReadAllLines(Arg.Any<string>()).Returns(Entries.vcfOneEntry);
var repo = Substitute.For<ContactRepository>(fileHandler);
var view = Substitute.For<IMainView>();
var presenter = new MainPresenter(view, repo);
_ = new MainPresenter(view, repo);
view.NewFileOpened += Raise.EventWith(new EventArg<string>("filename.aaa"));
view.Received().DisplayMessage(Arg.Any<string>(), Arg.Any<string>());
@@ -41,14 +34,15 @@ namespace vCardEditor_Test
var fileHandler = Substitute.For<IFileHandler>();
fileHandler.ReadAllLines(Arg.Any<string>()).Returns(Entries.vcfOneEntry);
var repo = Substitute.For<ContactRepository>(fileHandler);
repo.GetExtension(Arg.Any<string>()).Returns(".vcf");
var view = Substitute.For<IMainView>();
var presenter = new MainPresenter(view, repo);
view.NewFileOpened += Raise.EventWith(new EventArg<string>("filename.vcf"));
view.Received().DisplayContacts(Arg.Is<BindingList<Contact>>(x=>x.Count == 1));
view.Received().DisplayContacts(Arg.Is<BindingList<Contact>>(x => x[0].card.FormattedName == "Jean Dupont1"));
view.Received().DisplayContacts(Arg.Is<SortableBindingList<Contact>>(x=>x.Count == 1));
view.Received().DisplayContacts(Arg.Is<SortableBindingList<Contact>>(x => x[0].card.FormattedName == "Jean Dupont1"));
}
@@ -60,6 +54,7 @@ namespace vCardEditor_Test
var fileHandler = Substitute.For<IFileHandler>();
fileHandler.ReadAllLines(Arg.Any<string>()).Returns(Entries.vcfThreeEntry);
var repo = Substitute.For<ContactRepository>(fileHandler);
repo.GetExtension(Arg.Any<string>()).Returns(".vcf");
var view = Substitute.For<IMainView>();
view.AskMessage(Arg.Any<string>(), Arg.Any<string>()).Returns(true);
@@ -79,6 +74,7 @@ namespace vCardEditor_Test
var fileHandler = Substitute.For<IFileHandler>();
fileHandler.ReadAllLines(Arg.Any<string>()).Returns(Entries.vcfThreeEntry);
var repo = Substitute.For<ContactRepository>(fileHandler);
repo.GetExtension(Arg.Any<string>()).Returns(".vcf");
var view = Substitute.For<IMainView>();
@@ -97,6 +93,7 @@ namespace vCardEditor_Test
fileHandler.ReadAllLines(Arg.Any<string>()).Returns(Entries.vcfThreeEntry);
fileHandler.FileExist("aaa.vcf.old0").Returns(true);
var repo = Substitute.For<ContactRepository>(fileHandler);
repo.GetExtension(Arg.Any<string>()).Returns(".vcf");
var view = Substitute.For<IMainView>();
@@ -115,6 +112,7 @@ namespace vCardEditor_Test
var fileHandler = Substitute.For<IFileHandler>();
fileHandler.ReadAllLines(Arg.Any<string>()).Returns(Entries.vcfThreeEntry);
var repo = Substitute.For<ContactRepository>(fileHandler);
repo.GetExtension(Arg.Any<string>()).Returns(".vcf");
var view = Substitute.For<IMainView>();