mirror of
https://github.com/abdelkader/vCardEditor
synced 2025-12-12 08:27:19 +07:00
FixedList to maintain MRU. Added simple config dialog
This commit is contained in:
@@ -1,3 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
</configuration>
|
||||
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.ComponentModel;
|
||||
using Thought.vCards;
|
||||
|
||||
namespace VCFEditor.Model
|
||||
|
||||
53
vCardEditor/Model/FixedList.cs
Normal file
53
vCardEditor/Model/FixedList.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace vCardEditor.Model
|
||||
{
|
||||
[Serializable]
|
||||
public class FixedList
|
||||
{
|
||||
public List<string> _innerList { get; set; }
|
||||
|
||||
private int _size;
|
||||
public int Size
|
||||
{
|
||||
get { return _size; }
|
||||
set { _size = value; }
|
||||
}
|
||||
public FixedList() : this(5)
|
||||
{
|
||||
|
||||
}
|
||||
public FixedList(int size)
|
||||
{
|
||||
this._size = size;
|
||||
this._innerList = new List<string>(size);
|
||||
}
|
||||
|
||||
public void Enqueue(string elem)
|
||||
{
|
||||
_innerList.Insert(_innerList.Count, elem);
|
||||
|
||||
if (_innerList.Count > _size)
|
||||
_innerList.RemoveAt(0);
|
||||
}
|
||||
|
||||
public string this[int index]
|
||||
{
|
||||
get { return _innerList[index]; }
|
||||
set { _innerList[index] = value; }
|
||||
}
|
||||
|
||||
public bool Contains(string elem)
|
||||
{
|
||||
return _innerList.Any(x => string.Compare(x, elem, StringComparison.OrdinalIgnoreCase) == 0);
|
||||
}
|
||||
|
||||
public bool IsEmpty()
|
||||
{
|
||||
return (this._innerList.Count == 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
40
vCardEditor/Model/ObjectCopier.cs
Normal file
40
vCardEditor/Model/ObjectCopier.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
|
||||
|
||||
namespace vCardEditor.Model
|
||||
{
|
||||
public static class ObjectCopier
|
||||
{
|
||||
/// <summary>
|
||||
/// Perform a deep Copy of the object.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of object being copied.</typeparam>
|
||||
/// <param name="source">The object instance to copy.</param>
|
||||
/// <returns>The copied object.</returns>
|
||||
public static T Clone<T>(this T source)
|
||||
{
|
||||
if (!typeof(T).IsSerializable)
|
||||
{
|
||||
throw new ArgumentException("The type must be serializable.", "source");
|
||||
}
|
||||
|
||||
// Don't serialize a null object, simply return the default for that object
|
||||
if (Object.ReferenceEquals(source, null))
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
|
||||
IFormatter formatter = new BinaryFormatter();
|
||||
Stream stream = new MemoryStream();
|
||||
using (stream)
|
||||
{
|
||||
formatter.Serialize(stream, source);
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
return (T)formatter.Deserialize(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ using vCardEditor.View;
|
||||
using VCFEditor.Repository;
|
||||
using System.Windows.Forms;
|
||||
using vCardEditor.Repository;
|
||||
using vCardEditor.Model;
|
||||
|
||||
|
||||
namespace VCFEditor.Presenter
|
||||
@@ -78,18 +79,17 @@ namespace VCFEditor.Presenter
|
||||
string path = e.Data;
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
_repository.LoadContacts(path);
|
||||
_view.DisplayContacts(_repository.Contacts);
|
||||
FixedList MRUList = ConfigRepository.Instance.Paths;
|
||||
|
||||
List<string> MRUList = ConfigRepository.Instance.Paths;
|
||||
|
||||
if (!MRUList.Any(x => string.Compare(x, path, StringComparison.OrdinalIgnoreCase) == 0))
|
||||
if (!MRUList.Contains(path))
|
||||
{
|
||||
MRUList.Add(path);
|
||||
MRUList.Enqueue(path);
|
||||
// ConfigRepository.Instance.Paths.Clear();
|
||||
_view.UpdateMRUMenu(MRUList);
|
||||
}
|
||||
|
||||
|
||||
_repository.LoadContacts(path);
|
||||
_view.DisplayContacts(_repository.Contacts);
|
||||
}
|
||||
|
||||
|
||||
@@ -103,7 +103,10 @@ namespace VCFEditor.Presenter
|
||||
vCard card = _repository.Contacts[index].card;
|
||||
|
||||
if (card != null)
|
||||
{
|
||||
_repository.Contacts[index].isDirty = false;
|
||||
_view.DisplayContactDetail(card, _repository.fileName);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml.Serialization;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
using System.ComponentModel;
|
||||
using vCardEditor.Model;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace vCardEditor.Repository
|
||||
{
|
||||
[XmlRoot("Config")]
|
||||
[Serializable]
|
||||
public class ConfigRepository
|
||||
{
|
||||
private static string ConfigFileName
|
||||
@@ -29,12 +30,18 @@ namespace vCardEditor.Repository
|
||||
}
|
||||
}
|
||||
|
||||
public bool OverWrite;
|
||||
[XmlArrayItemAttribute("Folder")]
|
||||
public List<string> Paths;
|
||||
[Description("Overwrite the file when saving")]
|
||||
public bool OverWrite { get; set; }
|
||||
[Description("Maximum entries for MRU ")]
|
||||
public int Maximum { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
public FixedList Paths { get; set;}
|
||||
|
||||
private ConfigRepository() { }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// save config file
|
||||
/// </summary>
|
||||
@@ -66,17 +73,22 @@ namespace vCardEditor.Repository
|
||||
|
||||
XmlSerializer deserializer = new XmlSerializer(typeof(ConfigRepository));
|
||||
using (TextReader reader = new StreamReader(ConfigFileName))
|
||||
{
|
||||
obj = (ConfigRepository)deserializer.Deserialize(reader);
|
||||
obj.Paths.Size = obj.Maximum;
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
obj = new ConfigRepository();
|
||||
obj.Paths = new List<string>();
|
||||
obj.Paths = new FixedList(5);
|
||||
}
|
||||
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,6 +90,9 @@ namespace VCFEditor.Repository
|
||||
if (string.IsNullOrEmpty(fileName))
|
||||
fileName = this.fileName;
|
||||
|
||||
//Take a copy...
|
||||
if (!ConfigRepository.Instance.OverWrite)
|
||||
File.Move(fileName, fileName + ".old");
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
foreach (var entry in Contacts)
|
||||
|
||||
83
vCardEditor/View/ConfigDialog.Designer.cs
generated
Normal file
83
vCardEditor/View/ConfigDialog.Designer.cs
generated
Normal file
@@ -0,0 +1,83 @@
|
||||
namespace vCardEditor.View
|
||||
{
|
||||
partial class ConfigDialog
|
||||
{
|
||||
/// <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.btnClose = new System.Windows.Forms.Button();
|
||||
this.pgConfig = new System.Windows.Forms.PropertyGrid();
|
||||
this.btnCancel = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// btnClose
|
||||
//
|
||||
this.btnClose.Location = new System.Drawing.Point(253, 347);
|
||||
this.btnClose.Name = "btnClose";
|
||||
this.btnClose.Size = new System.Drawing.Size(75, 23);
|
||||
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(12, 12);
|
||||
this.pgConfig.Name = "pgConfig";
|
||||
this.pgConfig.Size = new System.Drawing.Size(316, 329);
|
||||
this.pgConfig.TabIndex = 1;
|
||||
//
|
||||
// btnCancel
|
||||
//
|
||||
this.btnCancel.Location = new System.Drawing.Point(172, 347);
|
||||
this.btnCancel.Name = "btnCancel";
|
||||
this.btnCancel.Size = new System.Drawing.Size(75, 23);
|
||||
this.btnCancel.TabIndex = 0;
|
||||
this.btnCancel.Text = "Cancel";
|
||||
this.btnCancel.UseVisualStyleBackColor = true;
|
||||
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
|
||||
//
|
||||
// ConfigDialog
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(337, 382);
|
||||
this.Controls.Add(this.pgConfig);
|
||||
this.Controls.Add(this.btnCancel);
|
||||
this.Controls.Add(this.btnClose);
|
||||
this.Name = "ConfigDialog";
|
||||
this.Text = "ConfigDialog";
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button btnClose;
|
||||
private System.Windows.Forms.PropertyGrid pgConfig;
|
||||
private System.Windows.Forms.Button btnCancel;
|
||||
}
|
||||
}
|
||||
28
vCardEditor/View/ConfigDialog.cs
Normal file
28
vCardEditor/View/ConfigDialog.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using vCardEditor.Repository;
|
||||
using vCardEditor.Model;
|
||||
|
||||
namespace vCardEditor.View
|
||||
{
|
||||
public partial class ConfigDialog : Form
|
||||
{
|
||||
public ConfigDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
ConfigRepository conf = ConfigRepository.Instance;//.Clone();
|
||||
pgConfig.SelectedObject = conf;
|
||||
}
|
||||
|
||||
private void btnClose_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void btnCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
120
vCardEditor/View/ConfigDialog.resx
Normal file
120
vCardEditor/View/ConfigDialog.resx
Normal 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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@@ -4,6 +4,7 @@ using Thought.vCards;
|
||||
using VCFEditor.Model;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
using vCardEditor.Model;
|
||||
|
||||
namespace VCFEditor.View
|
||||
{
|
||||
@@ -24,6 +25,6 @@ namespace VCFEditor.View
|
||||
void DisplayContacts(BindingList<Contact> contacts);
|
||||
void DisplayContactDetail(vCard card, string FileName);
|
||||
bool AskMessage(string msg, string caption);
|
||||
void UpdateMRUMenu(List<string> MRUList);
|
||||
void UpdateMRUMenu(FixedList MRUList);
|
||||
}
|
||||
}
|
||||
|
||||
150
vCardEditor/View/MainForm.Designer.cs
generated
150
vCardEditor/View/MainForm.Designer.cs
generated
@@ -53,8 +53,14 @@
|
||||
this.PersonalWebSiteLabel = new System.Windows.Forms.Label();
|
||||
this.WorkPhoneLabel = new System.Windows.Forms.Label();
|
||||
this.gbContactDetail = new System.Windows.Forms.GroupBox();
|
||||
this.EmailAddressValue = new vCardEditor.View.StateTextBox();
|
||||
this.EmailAddressLabel = new System.Windows.Forms.Label();
|
||||
this.WorkPhoneValue = new vCardEditor.View.StateTextBox();
|
||||
this.PersonalWebSiteValue = new vCardEditor.View.StateTextBox();
|
||||
this.PhotoBox = new System.Windows.Forms.PictureBox();
|
||||
this.CellularPhoneValue = new vCardEditor.View.StateTextBox();
|
||||
this.HomePhoneValue = new vCardEditor.View.StateTextBox();
|
||||
this.FormattedNameValue = new vCardEditor.View.StateTextBox();
|
||||
this.bsContacts = new System.Windows.Forms.BindingSource(this.components);
|
||||
this.gbNameList = new System.Windows.Forms.GroupBox();
|
||||
this.btnClearFilter = new System.Windows.Forms.Button();
|
||||
@@ -62,12 +68,7 @@
|
||||
this.dgContacts = new System.Windows.Forms.DataGridView();
|
||||
this.Column1 = new System.Windows.Forms.DataGridViewCheckBoxColumn();
|
||||
this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.EmailAddressValue = new vCardEditor.View.StateTextBox();
|
||||
this.WorkPhoneValue = new vCardEditor.View.StateTextBox();
|
||||
this.PersonalWebSiteValue = new vCardEditor.View.StateTextBox();
|
||||
this.CellularPhoneValue = new vCardEditor.View.StateTextBox();
|
||||
this.HomePhoneValue = new vCardEditor.View.StateTextBox();
|
||||
this.FormattedNameValue = new vCardEditor.View.StateTextBox();
|
||||
this.miConfig = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.menuStrip1.SuspendLayout();
|
||||
this.toolStrip1.SuspendLayout();
|
||||
this.gbContactDetail.SuspendLayout();
|
||||
@@ -93,6 +94,7 @@
|
||||
this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.miOpen,
|
||||
this.toolStripMenuItem1,
|
||||
this.miConfig,
|
||||
this.recentFilesMenuItem,
|
||||
this.miQuit});
|
||||
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
|
||||
@@ -287,6 +289,17 @@
|
||||
this.gbContactDetail.TabStop = false;
|
||||
this.gbContactDetail.Text = "Contact Detail :";
|
||||
//
|
||||
// EmailAddressValue
|
||||
//
|
||||
this.EmailAddressValue.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.EmailAddressValue.Location = new System.Drawing.Point(123, 99);
|
||||
this.EmailAddressValue.Name = "EmailAddressValue";
|
||||
this.EmailAddressValue.Size = new System.Drawing.Size(272, 20);
|
||||
this.EmailAddressValue.TabIndex = 59;
|
||||
this.EmailAddressValue.LostFocus += new System.EventHandler(this.Value_TextChanged);
|
||||
this.EmailAddressValue.Validated += new System.EventHandler(this.Value_TextChanged);
|
||||
//
|
||||
// EmailAddressLabel
|
||||
//
|
||||
this.EmailAddressLabel.Location = new System.Drawing.Point(-7, 100);
|
||||
@@ -296,6 +309,28 @@
|
||||
this.EmailAddressLabel.Text = "Email Address:";
|
||||
this.EmailAddressLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
//
|
||||
// WorkPhoneValue
|
||||
//
|
||||
this.WorkPhoneValue.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.WorkPhoneValue.Location = new System.Drawing.Point(123, 124);
|
||||
this.WorkPhoneValue.Name = "WorkPhoneValue";
|
||||
this.WorkPhoneValue.Size = new System.Drawing.Size(272, 20);
|
||||
this.WorkPhoneValue.TabIndex = 57;
|
||||
this.WorkPhoneValue.LostFocus += new System.EventHandler(this.Value_TextChanged);
|
||||
this.WorkPhoneValue.Validated += new System.EventHandler(this.Value_TextChanged);
|
||||
//
|
||||
// PersonalWebSiteValue
|
||||
//
|
||||
this.PersonalWebSiteValue.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.PersonalWebSiteValue.Location = new System.Drawing.Point(123, 149);
|
||||
this.PersonalWebSiteValue.Name = "PersonalWebSiteValue";
|
||||
this.PersonalWebSiteValue.Size = new System.Drawing.Size(272, 20);
|
||||
this.PersonalWebSiteValue.TabIndex = 56;
|
||||
this.PersonalWebSiteValue.LostFocus += new System.EventHandler(this.Value_TextChanged);
|
||||
this.PersonalWebSiteValue.Validated += new System.EventHandler(this.Value_TextChanged);
|
||||
//
|
||||
// PhotoBox
|
||||
//
|
||||
this.PhotoBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
@@ -307,6 +342,39 @@
|
||||
this.PhotoBox.TabIndex = 53;
|
||||
this.PhotoBox.TabStop = false;
|
||||
//
|
||||
// CellularPhoneValue
|
||||
//
|
||||
this.CellularPhoneValue.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.CellularPhoneValue.Location = new System.Drawing.Point(123, 74);
|
||||
this.CellularPhoneValue.Name = "CellularPhoneValue";
|
||||
this.CellularPhoneValue.Size = new System.Drawing.Size(272, 20);
|
||||
this.CellularPhoneValue.TabIndex = 47;
|
||||
this.CellularPhoneValue.LostFocus += new System.EventHandler(this.Value_TextChanged);
|
||||
this.CellularPhoneValue.Validated += new System.EventHandler(this.Value_TextChanged);
|
||||
//
|
||||
// HomePhoneValue
|
||||
//
|
||||
this.HomePhoneValue.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.HomePhoneValue.Location = new System.Drawing.Point(123, 49);
|
||||
this.HomePhoneValue.Name = "HomePhoneValue";
|
||||
this.HomePhoneValue.Size = new System.Drawing.Size(272, 20);
|
||||
this.HomePhoneValue.TabIndex = 45;
|
||||
this.HomePhoneValue.LostFocus += new System.EventHandler(this.Value_TextChanged);
|
||||
this.HomePhoneValue.Validated += new System.EventHandler(this.Value_TextChanged);
|
||||
//
|
||||
// FormattedNameValue
|
||||
//
|
||||
this.FormattedNameValue.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.FormattedNameValue.Location = new System.Drawing.Point(123, 24);
|
||||
this.FormattedNameValue.Name = "FormattedNameValue";
|
||||
this.FormattedNameValue.Size = new System.Drawing.Size(272, 20);
|
||||
this.FormattedNameValue.TabIndex = 44;
|
||||
this.FormattedNameValue.LostFocus += new System.EventHandler(this.Value_TextChanged);
|
||||
this.FormattedNameValue.Validated += new System.EventHandler(this.Value_TextChanged);
|
||||
//
|
||||
// gbNameList
|
||||
//
|
||||
this.gbNameList.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
@@ -382,71 +450,12 @@
|
||||
this.Column2.Name = "Column2";
|
||||
this.Column2.ReadOnly = true;
|
||||
//
|
||||
// EmailAddressValue
|
||||
// miConfig
|
||||
//
|
||||
this.EmailAddressValue.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.EmailAddressValue.Location = new System.Drawing.Point(123, 99);
|
||||
this.EmailAddressValue.Name = "EmailAddressValue";
|
||||
this.EmailAddressValue.Size = new System.Drawing.Size(272, 20);
|
||||
this.EmailAddressValue.TabIndex = 59;
|
||||
this.EmailAddressValue.LostFocus += new System.EventHandler(this.Value_TextChanged);
|
||||
this.EmailAddressValue.Validated += new System.EventHandler(this.Value_TextChanged);
|
||||
//
|
||||
// WorkPhoneValue
|
||||
//
|
||||
this.WorkPhoneValue.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.WorkPhoneValue.Location = new System.Drawing.Point(123, 124);
|
||||
this.WorkPhoneValue.Name = "WorkPhoneValue";
|
||||
this.WorkPhoneValue.Size = new System.Drawing.Size(272, 20);
|
||||
this.WorkPhoneValue.TabIndex = 57;
|
||||
this.WorkPhoneValue.LostFocus += new System.EventHandler(this.Value_TextChanged);
|
||||
this.WorkPhoneValue.Validated += new System.EventHandler(this.Value_TextChanged);
|
||||
//
|
||||
// PersonalWebSiteValue
|
||||
//
|
||||
this.PersonalWebSiteValue.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.PersonalWebSiteValue.Location = new System.Drawing.Point(123, 149);
|
||||
this.PersonalWebSiteValue.Name = "PersonalWebSiteValue";
|
||||
this.PersonalWebSiteValue.Size = new System.Drawing.Size(272, 20);
|
||||
this.PersonalWebSiteValue.TabIndex = 56;
|
||||
this.PersonalWebSiteValue.LostFocus += new System.EventHandler(this.Value_TextChanged);
|
||||
this.PersonalWebSiteValue.Validated += new System.EventHandler(this.Value_TextChanged);
|
||||
//
|
||||
// CellularPhoneValue
|
||||
//
|
||||
this.CellularPhoneValue.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.CellularPhoneValue.Location = new System.Drawing.Point(123, 74);
|
||||
this.CellularPhoneValue.Name = "CellularPhoneValue";
|
||||
this.CellularPhoneValue.Size = new System.Drawing.Size(272, 20);
|
||||
this.CellularPhoneValue.TabIndex = 47;
|
||||
this.CellularPhoneValue.LostFocus += new System.EventHandler(this.Value_TextChanged);
|
||||
this.CellularPhoneValue.Validated += new System.EventHandler(this.Value_TextChanged);
|
||||
//
|
||||
// HomePhoneValue
|
||||
//
|
||||
this.HomePhoneValue.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.HomePhoneValue.Location = new System.Drawing.Point(123, 49);
|
||||
this.HomePhoneValue.Name = "HomePhoneValue";
|
||||
this.HomePhoneValue.Size = new System.Drawing.Size(272, 20);
|
||||
this.HomePhoneValue.TabIndex = 45;
|
||||
this.HomePhoneValue.LostFocus += new System.EventHandler(this.Value_TextChanged);
|
||||
this.HomePhoneValue.Validated += new System.EventHandler(this.Value_TextChanged);
|
||||
//
|
||||
// FormattedNameValue
|
||||
//
|
||||
this.FormattedNameValue.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.FormattedNameValue.Location = new System.Drawing.Point(123, 24);
|
||||
this.FormattedNameValue.Name = "FormattedNameValue";
|
||||
this.FormattedNameValue.Size = new System.Drawing.Size(272, 20);
|
||||
this.FormattedNameValue.TabIndex = 44;
|
||||
this.FormattedNameValue.LostFocus += new System.EventHandler(this.Value_TextChanged);
|
||||
this.FormattedNameValue.Validated += new System.EventHandler(this.Value_TextChanged);
|
||||
this.miConfig.Name = "miConfig";
|
||||
this.miConfig.Size = new System.Drawing.Size(152, 22);
|
||||
this.miConfig.Text = "Preference";
|
||||
this.miConfig.Click += new System.EventHandler(this.miConfig_Click);
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
@@ -521,5 +530,6 @@
|
||||
internal System.Windows.Forms.PictureBox PhotoBox;
|
||||
private System.Windows.Forms.ToolStripMenuItem recentFilesMenuItem;
|
||||
internal StateTextBox FormattedNameValue;
|
||||
private System.Windows.Forms.ToolStripMenuItem miConfig;
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ using VCFEditor.View;
|
||||
using VCFEditor.Model;
|
||||
using Thought.vCards;
|
||||
using vCardEditor.Repository;
|
||||
using vCardEditor.Model;
|
||||
|
||||
namespace vCardEditor.View
|
||||
{
|
||||
@@ -139,23 +140,24 @@ namespace vCardEditor.View
|
||||
}
|
||||
|
||||
#region helper methods to populate textboxes.
|
||||
private void SetSummaryValue(TextBox valueLabel, string value)
|
||||
private void SetSummaryValue(StateTextBox valueLabel, string value)
|
||||
{
|
||||
if (valueLabel == null)
|
||||
throw new ArgumentNullException("valueLabel");
|
||||
|
||||
//Clear textbox if value is empty!
|
||||
valueLabel.Text = value;
|
||||
valueLabel.oldText = value;
|
||||
}
|
||||
|
||||
private void SetSummaryValue(TextBox valueLabel, vCardEmailAddress email)
|
||||
private void SetSummaryValue(StateTextBox valueLabel, vCardEmailAddress email)
|
||||
{
|
||||
valueLabel.Text = string.Empty;
|
||||
if (email != null)
|
||||
SetSummaryValue(valueLabel, email.Address);
|
||||
}
|
||||
|
||||
private void SetSummaryValue(TextBox valueLabel, vCardPhone phone)
|
||||
private void SetSummaryValue(StateTextBox valueLabel, vCardPhone phone)
|
||||
{
|
||||
valueLabel.Text = string.Empty;
|
||||
if (phone != null)
|
||||
@@ -163,7 +165,7 @@ namespace vCardEditor.View
|
||||
|
||||
}
|
||||
|
||||
private void SetSummaryValue(TextBox valueLabel, vCardWebsite webSite)
|
||||
private void SetSummaryValue(StateTextBox valueLabel, vCardWebsite webSite)
|
||||
{
|
||||
valueLabel.Text = string.Empty;
|
||||
if (webSite != null)
|
||||
@@ -298,15 +300,16 @@ namespace vCardEditor.View
|
||||
|
||||
}
|
||||
|
||||
public void UpdateMRUMenu(List<string> MRUList)
|
||||
public void UpdateMRUMenu(FixedList MRUList)
|
||||
{
|
||||
//No need to go further if no menu entry to load!
|
||||
if (MRUList == null || MRUList.Count == 0)
|
||||
if (MRUList == null || MRUList.IsEmpty())
|
||||
return;
|
||||
|
||||
recentFilesMenuItem.DropDownItems.Clear();
|
||||
foreach (string item in MRUList)
|
||||
recentFilesMenuItem.DropDownItems.Add(item);
|
||||
for (int i = 0; i < MRUList._innerList.Count; i++)
|
||||
recentFilesMenuItem.DropDownItems.Add(MRUList[i]);
|
||||
|
||||
}
|
||||
|
||||
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
|
||||
@@ -335,6 +338,12 @@ namespace vCardEditor.View
|
||||
return result;
|
||||
}
|
||||
|
||||
private void miConfig_Click(object sender, EventArgs e)
|
||||
{
|
||||
ConfigDialog dialog = new ConfigDialog();
|
||||
dialog.ShowDialog();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace vCardEditor.View
|
||||
{
|
||||
public class StateTextBox : TextBox
|
||||
{
|
||||
private string _oldText;
|
||||
public string oldText
|
||||
{
|
||||
get { return _oldText; }
|
||||
}
|
||||
|
||||
public string oldText { get; set; }
|
||||
|
||||
protected override void OnLostFocus(EventArgs e)
|
||||
{
|
||||
base.OnLostFocus(e);
|
||||
_oldText = this.Text;
|
||||
oldText = this.Text;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -49,6 +49,8 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Model\FixedList.cs" />
|
||||
<Compile Include="Model\ObjectCopier.cs" />
|
||||
<Compile Include="Repository\ConfigRepository.cs" />
|
||||
<Compile Include="Repository\ContactRepository.cs" />
|
||||
<Compile Include="Repository\FileHandler.cs" />
|
||||
@@ -104,6 +106,12 @@
|
||||
<Compile Include="View\AboutDialog.Designer.cs">
|
||||
<DependentUpon>AboutDialog.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="View\ConfigDialog.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="View\ConfigDialog.Designer.cs">
|
||||
<DependentUpon>ConfigDialog.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="View\EventArgs.cs" />
|
||||
<Compile Include="View\IMainView.cs" />
|
||||
<Compile Include="View\MainForm.cs">
|
||||
@@ -129,10 +137,12 @@
|
||||
<EmbeddedResource Include="View\AboutDialog.resx">
|
||||
<DependentUpon>AboutDialog.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="View\ConfigDialog.resx">
|
||||
<DependentUpon>ConfigDialog.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="View\MainForm.resx">
|
||||
<DependentUpon>MainForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<None Include="App.config" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
|
||||
67
vCardEditor_Test/FixedListTest.cs
Normal file
67
vCardEditor_Test/FixedListTest.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using vCardEditor.Model;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
|
||||
namespace vCardEditor_Test
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
///Classe de test pour FixedListTest, destinée à contenir tous
|
||||
///les tests unitaires FixedListTest
|
||||
///</summary>
|
||||
[TestClass()]
|
||||
public class FixedListTest
|
||||
{
|
||||
/// <summary>
|
||||
///Test pour enqueue
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void enqueue_one_element_test()
|
||||
{
|
||||
int size = 1;
|
||||
FixedList target = new FixedList(size);
|
||||
string elem = "test";
|
||||
target.Enqueue(elem);
|
||||
|
||||
Assert.IsTrue( target.Size == 1);
|
||||
Assert.IsTrue(target[0] == "test");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///Test pour enqueue
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void enqueue_two_elements_test()
|
||||
{
|
||||
int size = 1;
|
||||
FixedList target = new FixedList(size);
|
||||
|
||||
target.Enqueue("elem1");
|
||||
target.Enqueue("elem2");
|
||||
|
||||
Assert.IsTrue(target.Size == 1);
|
||||
Assert.IsTrue(target[0] == "elem2");
|
||||
|
||||
Assert.IsTrue(target.Size == 1);
|
||||
}
|
||||
|
||||
[TestMethod()]
|
||||
public void enqueue_three_elements_test()
|
||||
{
|
||||
int size = 3;
|
||||
FixedList target = new FixedList(size);
|
||||
|
||||
target.Enqueue("elem1"); // this one should be remove !
|
||||
target.Enqueue("elem2");
|
||||
target.Enqueue("elem3");
|
||||
target.Enqueue("elem4");
|
||||
|
||||
Assert.IsTrue(target.Size == 3);
|
||||
Assert.IsTrue(target[0] == "elem2");
|
||||
Assert.IsTrue(target[1] == "elem3");
|
||||
|
||||
Assert.IsTrue(target.Size == 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,6 +41,13 @@
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
|
||||
@@ -48,6 +55,7 @@
|
||||
</CodeAnalysisDependentAssemblyPaths>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="FixedListTest.cs" />
|
||||
<Compile Include="MainPresenterTest.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user