13 Commits
v0.5 ... v0.5.1

Author SHA1 Message Date
Abdel
2c47765a5e Update README.md 2023-06-12 22:50:59 -04:00
Abdel
687b2a248a Update README.md 2023-05-11 08:53:39 -04:00
abdelkader
71b5b7580a Merge branch 'master' of https://github.com/abdelkader/vCardEditor 2023-05-08 21:56:13 -04:00
abdelkader
7a4c8e9d42 fix minor fusions commit 2023-05-08 21:54:33 -04:00
abdelkader
1233425972 refactor 2023-05-08 21:43:23 -04:00
abdelkader
2885f5f5cc fusion 2023-05-08 19:57:21 -04:00
abdelkader
89c06504ee 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
2023-05-08 19:53:12 -04:00
Abdel
adac378b13 Update README.md 2023-05-05 17:56:07 -04:00
abdelkader
74b5400a34 Added vcard copy to clipboard 2023-05-04 21:22:37 -04:00
abdelkader
7ffb330559 corrected failed tests 2023-05-04 18:30:07 -04:00
abdelkader
3b1cfcd36b added a release file 2023-05-04 15:28:42 -04:00
Abdel
8cf9ce829c Update README.md 2023-05-04 14:36:39 -04:00
Abdel
071c967e08 Update README.md
added the screenshot
2023-05-04 14:34:35 -04:00
24 changed files with 933 additions and 193 deletions

View File

@@ -1,51 +1,35 @@
[![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
## vCard Editor
A Simple vcf file Editor. You can export easily edit (modify, delete) entries of a vcf file with this simple tool.
The software is still in **early stage**.
<p align="center"><img src="https://user-images.githubusercontent.com/169070/236289228-106c1489-e01d-400c-968e-92d3e2be74ab.png" width="800"></p>
## ✅ Features
- [x] No need to install anything. Just head to the release section and download the last release version.
- [x] Add/Export images
## Installation
🔧 No need to install anything. Just head to the release section and download the last release version.
## Screenshots
![vcardeditorv0_5](https://user-images.githubusercontent.com/169070/236289228-106c1489-e01d-400c-968e-92d3e2be74ab.png)
## Acknowledgements
## 📚 Tech Stack
- 🧰 [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.
- refactoring and bugs fixed
#### 0.2
- Updated the vCard library to https://github.com/acastroy/Thought.vCards
- Replaced Moq with nsubstitute (Test mocking library).
## Contributing
Contributions are always welcome!
- 🧰 [SortableBindingList](http://timvw.be/2008/08/02/presenting-the-sortablebindinglistt-take-two/)
- 🧰 [Custom TabControl](https://github.com/r-aghaei/TabControlWithCloseButtonAndAddButton)
## 📑 Release notes
Check release text file for history.
## 👷 Contributing
Contributions are always welcome! Check ths projet or ths issue page for ideas.

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

@@ -7,7 +7,6 @@ using vCardEditor.Repository;
using vCardEditor.Model;
using System.Linq;
using System.IO;
using System.Drawing;
using System.Collections.Generic;
namespace VCFEditor.Presenter
@@ -22,6 +21,7 @@ namespace VCFEditor.Presenter
_view = view;
_repository = repository;
_view.LoadForm += _view_LoadForm;
_view.AddContact += AddContact;
_view.NewFileOpened += NewFileOpened;
_view.BeforeOpeningNewFile += BeforeOpeningNewFile;
@@ -37,10 +37,28 @@ namespace VCFEditor.Presenter
_view.AddressAdded += _view_AddressAdded;
_view.AddressModified += _view_AddressModified;
_view.AddressRemoved += _view_AddressRemoved;
_view.CopyTextToClipboardEvent += _view_CopyTextToClipboardEvent;
}
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_LoadForm(object sender, EventArg<FormState> e)
{
e.Data = ConfigRepository.Instance.FormState;
}
private void _view_AddressRemoved(object sender, EventArg<int> e)
{
var contact = _repository.Contacts[_view.SelectedContactIndex];
@@ -81,10 +99,7 @@ namespace VCFEditor.Presenter
string imageFile = _view.DisplaySaveDialog(newPath);
_repository.SaveImageToDisk(imageFile, image);
}
}
}
private void ModifyImage(object sender, EventArg<string> e)
@@ -92,7 +107,6 @@ namespace VCFEditor.Presenter
if (!string.IsNullOrEmpty(e.Data) )
{
vCardPhoto photo = new vCardPhoto(e.Data);
_repository.ModifyImage(_view.SelectedContactIndex, photo);
}
else
@@ -102,8 +116,16 @@ namespace VCFEditor.Presenter
void CloseForm(object sender, EventArg<bool> e)
{
if (_repository.dirty && _view.AskMessage("Exit without saving?", "Exit"))
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)
{

17
vCardEditor/Releases.txt Normal file
View File

@@ -0,0 +1,17 @@
0.5
A reworked control for adding/modifying or removing addresses.
0.4
Import images/export images.
refactoring and bugs fixed
0.3
Added address section.
refactoring and bugs fixed
0.2
Updated the vCard library to https://github.com/acastroy/Thought.vCards
Replaced Moq with nsubstitute (Test mocking library).
0.1
Intial release

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)
@@ -221,10 +221,10 @@ namespace vCardEditor.View.Customs
private void ClearTabs()
{
//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 dataGridViewCellStyle1 = 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();
@@ -77,11 +80,16 @@ namespace vCardEditor.View
this.PhotoBox = new System.Windows.Forms.PictureBox();
this.bsContacts = new System.Windows.Forms.BindingSource(this.components);
this.gbNameList = new System.Windows.Forms.GroupBox();
this.btnClearFilter = new System.Windows.Forms.Button();
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.btnClearFilter = new System.Windows.Forms.Button();
this.textBoxFilter = new System.Windows.Forms.TextBox();
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,67 +582,50 @@ 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.Image = ((System.Drawing.Image)(resources.GetObject("btnClearFilter.Image")));
this.btnClearFilter.Location = new System.Drawing.Point(268, 17);
this.btnClearFilter.Margin = new System.Windows.Forms.Padding(4);
this.btnClearFilter.Name = "btnClearFilter";
this.btnClearFilter.Size = new System.Drawing.Size(37, 27);
this.btnClearFilter.TabIndex = 1;
this.btnClearFilter.UseVisualStyleBackColor = true;
this.btnClearFilter.Click += new System.EventHandler(this.btnClearFilter_Click);
//
// textBoxFilter
//
this.textBoxFilter.Location = new System.Drawing.Point(4, 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.TabIndex = 0;
this.textBoxFilter.TextChanged += new System.EventHandler(this.textBoxFilter_TextChanged);
//
// dgContacts
//
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)));
dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
this.dgContacts.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1;
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 +637,95 @@ 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;
//
// 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(357, 17);
this.btnClearFilter.Margin = new System.Windows.Forms.Padding(4);
this.btnClearFilter.Name = "btnClearFilter";
this.btnClearFilter.Size = new System.Drawing.Size(37, 27);
this.btnClearFilter.TabIndex = 1;
this.btnClearFilter.UseVisualStyleBackColor = true;
this.btnClearFilter.Click += new System.EventHandler(this.btnClearFilter_Click);
//
// textBoxFilter
//
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(341, 22);
this.textBoxFilter.TabIndex = 0;
this.textBoxFilter.TextChanged += new System.EventHandler(this.textBoxFilter_TextChanged);
//
// 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";
@@ -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

@@ -304,6 +304,18 @@
<metadata name="bsContacts.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>486, 17</value>
</metadata>
<metadata name="Column1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<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>
<data name="btnClearFilter.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
@@ -321,11 +333,8 @@
TkSuQmCC
</value>
</data>
<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">
<value>True</value>
<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>

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>
@@ -202,6 +215,7 @@
<Content Include="assests\Close.png" />
<Content Include="assests\icons8-close-16.png" />
<Content Include="assests\vCard.ico" />
<Content Include="Releases.txt" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">

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>();