mirror of
https://github.com/abdelkader/vCardEditor
synced 2025-12-12 08:27:19 +07:00
Support adding/removing multiple addresses
This commit is contained in:
@@ -8,6 +8,7 @@ using vCardEditor.Model;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using System.Drawing;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace VCFEditor.Presenter
|
||||
{
|
||||
@@ -33,7 +34,26 @@ namespace VCFEditor.Presenter
|
||||
_view.CloseForm += CloseForm;
|
||||
_view.ModifyImage += ModifyImage;
|
||||
_view.ExportImage += ExportImage;
|
||||
_view.AddressAdded += _view_AddressAdded;
|
||||
_view.AddressRemoved += _view_AddressRemoved;
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void _view_AddressRemoved(object sender, EventArg<int> e)
|
||||
{
|
||||
var contact = _repository.Contacts[_view.SelectedContactIndex];
|
||||
_repository.SetDirtyFlag(_view.SelectedContactIndex);
|
||||
|
||||
contact.card.DeliveryAddresses.RemoveAt(e.Data);
|
||||
}
|
||||
|
||||
private void _view_AddressAdded(object sender, EventArg<List<vCardDeliveryAddressTypes>> e)
|
||||
{
|
||||
var contact = _repository.Contacts[_view.SelectedContactIndex];
|
||||
_repository.SetDirtyFlag(_view.SelectedContactIndex);
|
||||
|
||||
contact.card.DeliveryAddresses.Add(new vCardDeliveryAddress( e.Data));
|
||||
}
|
||||
|
||||
private void ExportImage(object sender, EventArgs e)
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace VCFEditor.Repository
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
OriginalContactList = Contacts;
|
||||
return Contacts;
|
||||
}
|
||||
@@ -135,7 +135,7 @@ namespace VCFEditor.Repository
|
||||
if (_contacts[i].isSelected)
|
||||
{
|
||||
_contacts[i].isDeleted = true;
|
||||
_contacts[i].isDirty = true;
|
||||
SetDirtyFlag(i);
|
||||
_contacts.RemoveAt(i);
|
||||
}
|
||||
|
||||
@@ -342,7 +342,7 @@ namespace VCFEditor.Repository
|
||||
{
|
||||
if (index > -1)
|
||||
{
|
||||
_contacts[index].isDirty = true;
|
||||
SetDirtyFlag(index);
|
||||
_contacts[index].card.Photos.Clear();
|
||||
if (photo != null)
|
||||
_contacts[index].card.Photos.Add(photo);
|
||||
|
||||
@@ -25,6 +25,8 @@ namespace Thought.vCards
|
||||
private string postalCode;
|
||||
private string region;
|
||||
private string street;
|
||||
private string postOfficeBox;
|
||||
private string extendedAddress;
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -37,6 +39,8 @@ namespace Thought.vCards
|
||||
this.postalCode = string.Empty;
|
||||
this.region = string.Empty;
|
||||
this.street = string.Empty;
|
||||
this.postOfficeBox = string.Empty;
|
||||
this.extendedAddress = string.Empty;
|
||||
this.addressType = new List<vCardDeliveryAddressTypes>();
|
||||
}
|
||||
|
||||
@@ -50,7 +54,22 @@ namespace Thought.vCards
|
||||
Street = street;
|
||||
}
|
||||
|
||||
public vCardDeliveryAddress(string street, string city, string region, string country, string postalCode, string extendedAddress, string postOfficeBox, vCardDeliveryAddressTypes addressType)
|
||||
{
|
||||
AddressType = new List<vCardDeliveryAddressTypes>() { addressType };
|
||||
City = city;
|
||||
Country = country;
|
||||
PostalCode = postalCode;
|
||||
Region = region;
|
||||
Street = street;
|
||||
ExtendedAddress = extendedAddress;
|
||||
PostOfficeBox= postOfficeBox;
|
||||
}
|
||||
|
||||
public vCardDeliveryAddress(List<vCardDeliveryAddressTypes> addressType)
|
||||
{
|
||||
AddressType = addressType ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The type of postal address.
|
||||
@@ -230,6 +249,28 @@ namespace Thought.vCards
|
||||
}
|
||||
}
|
||||
|
||||
public string ExtendedAddress
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.extendedAddress ?? string.Empty;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.extendedAddress = value;
|
||||
}
|
||||
}
|
||||
public string PostOfficeBox
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.postOfficeBox ?? string.Empty;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.postOfficeBox = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1225,6 +1225,12 @@ namespace Thought.vCards
|
||||
if (addressParts.Length >= 3)
|
||||
deliveryAddress.Street = addressParts[2].Trim();
|
||||
|
||||
if (addressParts.Length >= 1)
|
||||
deliveryAddress.ExtendedAddress = addressParts[1].Trim();
|
||||
|
||||
if (addressParts.Length >= 0)
|
||||
deliveryAddress.PostOfficeBox = addressParts[0].Trim();
|
||||
|
||||
if (
|
||||
(string.IsNullOrEmpty(deliveryAddress.City)) &&
|
||||
(string.IsNullOrEmpty(deliveryAddress.Country)) &&
|
||||
@@ -1661,6 +1667,7 @@ namespace Thought.vCards
|
||||
// often consist of binary data.
|
||||
|
||||
vCardCertificate certificate = new vCardCertificate();
|
||||
|
||||
certificate.Data = (byte[])property.Value;
|
||||
|
||||
// TODO: Support other key types.
|
||||
|
||||
165
vCardEditor/View/Customs/AddAddress.Designer.cs
generated
Normal file
165
vCardEditor/View/Customs/AddAddress.Designer.cs
generated
Normal file
@@ -0,0 +1,165 @@
|
||||
|
||||
namespace vCardEditor.View.Customs
|
||||
{
|
||||
partial class AddAddress
|
||||
{
|
||||
/// <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.cbHome = new System.Windows.Forms.CheckBox();
|
||||
this.cbWork = new System.Windows.Forms.CheckBox();
|
||||
this.cbPostal = new System.Windows.Forms.CheckBox();
|
||||
this.cbDomestic = new System.Windows.Forms.CheckBox();
|
||||
this.btnOK = new System.Windows.Forms.Button();
|
||||
this.btnCancel = new System.Windows.Forms.Button();
|
||||
this.cbInternational = new System.Windows.Forms.CheckBox();
|
||||
this.cbCustom = new System.Windows.Forms.CheckBox();
|
||||
this.textBox1 = new System.Windows.Forms.TextBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// cbHome
|
||||
//
|
||||
this.cbHome.AutoSize = true;
|
||||
this.cbHome.Location = new System.Drawing.Point(12, 12);
|
||||
this.cbHome.Name = "cbHome";
|
||||
this.cbHome.Size = new System.Drawing.Size(67, 21);
|
||||
this.cbHome.TabIndex = 0;
|
||||
this.cbHome.Text = "Home";
|
||||
this.cbHome.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// cbWork
|
||||
//
|
||||
this.cbWork.AutoSize = true;
|
||||
this.cbWork.Location = new System.Drawing.Point(12, 40);
|
||||
this.cbWork.Name = "cbWork";
|
||||
this.cbWork.Size = new System.Drawing.Size(63, 21);
|
||||
this.cbWork.TabIndex = 1;
|
||||
this.cbWork.Text = "Work";
|
||||
this.cbWork.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// cbPostal
|
||||
//
|
||||
this.cbPostal.AutoSize = true;
|
||||
this.cbPostal.Location = new System.Drawing.Point(12, 67);
|
||||
this.cbPostal.Name = "cbPostal";
|
||||
this.cbPostal.Size = new System.Drawing.Size(69, 21);
|
||||
this.cbPostal.TabIndex = 2;
|
||||
this.cbPostal.Text = "Postal";
|
||||
this.cbPostal.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// cbDomestic
|
||||
//
|
||||
this.cbDomestic.AutoSize = true;
|
||||
this.cbDomestic.Location = new System.Drawing.Point(12, 94);
|
||||
this.cbDomestic.Name = "cbDomestic";
|
||||
this.cbDomestic.Size = new System.Drawing.Size(88, 21);
|
||||
this.cbDomestic.TabIndex = 3;
|
||||
this.cbDomestic.Text = "Domestic";
|
||||
this.cbDomestic.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// btnOK
|
||||
//
|
||||
this.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.btnOK.Location = new System.Drawing.Point(95, 187);
|
||||
this.btnOK.Name = "btnOK";
|
||||
this.btnOK.Size = new System.Drawing.Size(75, 23);
|
||||
this.btnOK.TabIndex = 7;
|
||||
this.btnOK.Text = "OK";
|
||||
this.btnOK.UseVisualStyleBackColor = true;
|
||||
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
|
||||
//
|
||||
// btnCancel
|
||||
//
|
||||
this.btnCancel.CausesValidation = false;
|
||||
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.btnCancel.Location = new System.Drawing.Point(176, 187);
|
||||
this.btnCancel.Name = "btnCancel";
|
||||
this.btnCancel.Size = new System.Drawing.Size(75, 23);
|
||||
this.btnCancel.TabIndex = 8;
|
||||
this.btnCancel.Text = "Cancel";
|
||||
this.btnCancel.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// cbInternational
|
||||
//
|
||||
this.cbInternational.AutoSize = true;
|
||||
this.cbInternational.Location = new System.Drawing.Point(12, 121);
|
||||
this.cbInternational.Name = "cbInternational";
|
||||
this.cbInternational.Size = new System.Drawing.Size(108, 21);
|
||||
this.cbInternational.TabIndex = 9;
|
||||
this.cbInternational.Text = "International";
|
||||
this.cbInternational.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// cbCustom
|
||||
//
|
||||
this.cbCustom.AutoSize = true;
|
||||
this.cbCustom.Location = new System.Drawing.Point(12, 148);
|
||||
this.cbCustom.Name = "cbCustom";
|
||||
this.cbCustom.Size = new System.Drawing.Size(81, 21);
|
||||
this.cbCustom.TabIndex = 10;
|
||||
this.cbCustom.Text = "Custom:";
|
||||
this.cbCustom.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// textBox1
|
||||
//
|
||||
this.textBox1.Location = new System.Drawing.Point(90, 149);
|
||||
this.textBox1.Name = "textBox1";
|
||||
this.textBox1.Size = new System.Drawing.Size(161, 22);
|
||||
this.textBox1.TabIndex = 11;
|
||||
//
|
||||
// AddAddress
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(263, 223);
|
||||
this.Controls.Add(this.textBox1);
|
||||
this.Controls.Add(this.cbCustom);
|
||||
this.Controls.Add(this.cbInternational);
|
||||
this.Controls.Add(this.btnCancel);
|
||||
this.Controls.Add(this.btnOK);
|
||||
this.Controls.Add(this.cbDomestic);
|
||||
this.Controls.Add(this.cbPostal);
|
||||
this.Controls.Add(this.cbWork);
|
||||
this.Controls.Add(this.cbHome);
|
||||
this.Name = "AddAddress";
|
||||
this.Text = "Address Type";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.CheckBox cbHome;
|
||||
private System.Windows.Forms.CheckBox cbWork;
|
||||
private System.Windows.Forms.CheckBox cbPostal;
|
||||
private System.Windows.Forms.CheckBox cbDomestic;
|
||||
private System.Windows.Forms.Button btnOK;
|
||||
private System.Windows.Forms.Button btnCancel;
|
||||
private System.Windows.Forms.CheckBox cbInternational;
|
||||
private System.Windows.Forms.CheckBox cbCustom;
|
||||
private System.Windows.Forms.TextBox textBox1;
|
||||
}
|
||||
}
|
||||
88
vCardEditor/View/Customs/AddAddress.cs
Normal file
88
vCardEditor/View/Customs/AddAddress.cs
Normal file
@@ -0,0 +1,88 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Thought.vCards;
|
||||
|
||||
namespace vCardEditor.View.Customs
|
||||
{
|
||||
public partial class AddAddress : Form
|
||||
{
|
||||
public List<vCardDeliveryAddressTypes> Addresses { get;}
|
||||
private readonly List<CheckBox> _checkBoxes;
|
||||
|
||||
public AddAddress()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_checkBoxes = Controls.OfType<CheckBox>().ToList();
|
||||
Addresses = new List<vCardDeliveryAddressTypes>();
|
||||
}
|
||||
|
||||
public AddAddress(List<vCardDeliveryAddressTypes> addressCollection)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_checkBoxes = Controls.OfType<CheckBox>().ToList();
|
||||
|
||||
foreach (var item in addressCollection)
|
||||
{
|
||||
switch (item.ToString())
|
||||
{
|
||||
case "Home":
|
||||
cbHome.Checked = true;
|
||||
break;
|
||||
|
||||
case "Work":
|
||||
cbWork.Checked = true;
|
||||
break;
|
||||
|
||||
case "Postal":
|
||||
cbPostal.Checked = true;
|
||||
break;
|
||||
|
||||
case "Domestic":
|
||||
cbDomestic.Checked = true;
|
||||
break;
|
||||
|
||||
case "International":
|
||||
cbInternational.Checked = true;
|
||||
break;
|
||||
case "Default":
|
||||
cbCustom.Checked = true;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void btnOK_Click(object sender, EventArgs e)
|
||||
{
|
||||
var total = _checkBoxes
|
||||
.Where(checkBox => checkBox.Checked);
|
||||
|
||||
if (total.Count() == 0)
|
||||
{
|
||||
MessageBox.Show("One item must be checked!");
|
||||
DialogResult = DialogResult.None;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
foreach (var item in total)
|
||||
{
|
||||
var enumType = (vCardDeliveryAddressTypes)Enum.Parse(typeof(vCardDeliveryAddressTypes), item.Text, true);
|
||||
Addresses.Add(enumType);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
120
vCardEditor/View/Customs/AddAddress.resx
Normal file
120
vCardEditor/View/Customs/AddAddress.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=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>
|
||||
252
vCardEditor/View/Customs/AddressBox.Designer.cs
generated
Normal file
252
vCardEditor/View/Customs/AddressBox.Designer.cs
generated
Normal file
@@ -0,0 +1,252 @@
|
||||
|
||||
namespace vCardEditor.View.Customs
|
||||
{
|
||||
partial class AddressBox
|
||||
{
|
||||
/// <summary>
|
||||
/// Variable nécessaire au concepteur.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Nettoyage des ressources utilisées.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true si les ressources managées doivent être supprimées ; sinon, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Code généré par le Concepteur de composants
|
||||
|
||||
/// <summary>
|
||||
/// Méthode requise pour la prise en charge du concepteur - ne modifiez pas
|
||||
/// le contenu de cette méthode avec l'éditeur de code.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.ExtAddrValue = new vCardEditor.View.StateTextBox();
|
||||
this.ExtAdressLabel = new System.Windows.Forms.Label();
|
||||
this.StreetLabel = new System.Windows.Forms.Label();
|
||||
this.StreetValue = new vCardEditor.View.StateTextBox();
|
||||
this.POBoxLabel = new System.Windows.Forms.Label();
|
||||
this.CountryValue = new vCardEditor.View.StateTextBox();
|
||||
this.Country = new System.Windows.Forms.Label();
|
||||
this.POBoxValue = new vCardEditor.View.StateTextBox();
|
||||
this.CityLabel = new System.Windows.Forms.Label();
|
||||
this.RegionValue = new vCardEditor.View.StateTextBox();
|
||||
this.CityValue = new vCardEditor.View.StateTextBox();
|
||||
this.StateLabel = new System.Windows.Forms.Label();
|
||||
this.ZipLabel = new System.Windows.Forms.Label();
|
||||
this.ZipValue = new vCardEditor.View.StateTextBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// ExtAddrValue
|
||||
//
|
||||
this.ExtAddrValue.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.ExtAddrValue.Location = new System.Drawing.Point(90, 45);
|
||||
this.ExtAddrValue.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.ExtAddrValue.Name = "ExtAddrValue";
|
||||
this.ExtAddrValue.oldText = null;
|
||||
this.ExtAddrValue.Size = new System.Drawing.Size(237, 22);
|
||||
this.ExtAddrValue.TabIndex = 27;
|
||||
this.ExtAddrValue.LostFocus += new System.EventHandler(this.Value_TextChanged);
|
||||
this.ExtAddrValue.Validated += new System.EventHandler(this.Value_TextChanged);
|
||||
//
|
||||
// ExtAdressLabel
|
||||
//
|
||||
this.ExtAdressLabel.Location = new System.Drawing.Point(1, 42);
|
||||
this.ExtAdressLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.ExtAdressLabel.Name = "ExtAdressLabel";
|
||||
this.ExtAdressLabel.Size = new System.Drawing.Size(87, 23);
|
||||
this.ExtAdressLabel.TabIndex = 26;
|
||||
this.ExtAdressLabel.Text = "Ext Address:";
|
||||
this.ExtAdressLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
//
|
||||
// StreetLabel
|
||||
//
|
||||
this.StreetLabel.Location = new System.Drawing.Point(2, 14);
|
||||
this.StreetLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.StreetLabel.Name = "StreetLabel";
|
||||
this.StreetLabel.Size = new System.Drawing.Size(65, 23);
|
||||
this.StreetLabel.TabIndex = 14;
|
||||
this.StreetLabel.Text = "Address:";
|
||||
this.StreetLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
//
|
||||
// StreetValue
|
||||
//
|
||||
this.StreetValue.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.StreetValue.Location = new System.Drawing.Point(90, 14);
|
||||
this.StreetValue.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.StreetValue.Name = "StreetValue";
|
||||
this.StreetValue.oldText = "";
|
||||
this.StreetValue.Size = new System.Drawing.Size(613, 22);
|
||||
this.StreetValue.TabIndex = 15;
|
||||
this.StreetValue.LostFocus += new System.EventHandler(this.Value_TextChanged);
|
||||
this.StreetValue.Validated += new System.EventHandler(this.Value_TextChanged);
|
||||
//
|
||||
// POBoxLabel
|
||||
//
|
||||
this.POBoxLabel.Location = new System.Drawing.Point(334, 75);
|
||||
this.POBoxLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.POBoxLabel.Name = "POBoxLabel";
|
||||
this.POBoxLabel.Size = new System.Drawing.Size(59, 23);
|
||||
this.POBoxLabel.TabIndex = 16;
|
||||
this.POBoxLabel.Text = "PO Box:";
|
||||
this.POBoxLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
|
||||
//
|
||||
// CountryValue
|
||||
//
|
||||
this.CountryValue.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.CountryValue.Location = new System.Drawing.Point(579, 76);
|
||||
this.CountryValue.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.CountryValue.Name = "CountryValue";
|
||||
this.CountryValue.oldText = null;
|
||||
this.CountryValue.Size = new System.Drawing.Size(125, 22);
|
||||
this.CountryValue.TabIndex = 25;
|
||||
this.CountryValue.LostFocus += new System.EventHandler(this.Value_TextChanged);
|
||||
this.CountryValue.Validated += new System.EventHandler(this.Value_TextChanged);
|
||||
//
|
||||
// Country
|
||||
//
|
||||
this.Country.Location = new System.Drawing.Point(505, 76);
|
||||
this.Country.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.Country.Name = "Country";
|
||||
this.Country.Size = new System.Drawing.Size(65, 23);
|
||||
this.Country.TabIndex = 24;
|
||||
this.Country.Text = "Country:";
|
||||
this.Country.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
//
|
||||
// POBoxValue
|
||||
//
|
||||
this.POBoxValue.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.POBoxValue.Location = new System.Drawing.Point(397, 75);
|
||||
this.POBoxValue.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.POBoxValue.Name = "POBoxValue";
|
||||
this.POBoxValue.oldText = null;
|
||||
this.POBoxValue.Size = new System.Drawing.Size(100, 22);
|
||||
this.POBoxValue.TabIndex = 17;
|
||||
this.POBoxValue.LostFocus += new System.EventHandler(this.Value_TextChanged);
|
||||
this.POBoxValue.Validated += new System.EventHandler(this.Value_TextChanged);
|
||||
//
|
||||
// CityLabel
|
||||
//
|
||||
this.CityLabel.Location = new System.Drawing.Point(338, 45);
|
||||
this.CityLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.CityLabel.Name = "CityLabel";
|
||||
this.CityLabel.Size = new System.Drawing.Size(32, 23);
|
||||
this.CityLabel.TabIndex = 18;
|
||||
this.CityLabel.Text = "City:";
|
||||
this.CityLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
//
|
||||
// RegionValue
|
||||
//
|
||||
this.RegionValue.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.RegionValue.Location = new System.Drawing.Point(90, 75);
|
||||
this.RegionValue.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.RegionValue.Name = "RegionValue";
|
||||
this.RegionValue.oldText = null;
|
||||
this.RegionValue.Size = new System.Drawing.Size(236, 22);
|
||||
this.RegionValue.TabIndex = 23;
|
||||
this.RegionValue.LostFocus += new System.EventHandler(this.Value_TextChanged);
|
||||
this.RegionValue.Validated += new System.EventHandler(this.Value_TextChanged);
|
||||
//
|
||||
// CityValue
|
||||
//
|
||||
this.CityValue.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.CityValue.Location = new System.Drawing.Point(397, 45);
|
||||
this.CityValue.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.CityValue.Name = "CityValue";
|
||||
this.CityValue.oldText = null;
|
||||
this.CityValue.Size = new System.Drawing.Size(127, 22);
|
||||
this.CityValue.TabIndex = 19;
|
||||
this.CityValue.LostFocus += new System.EventHandler(this.Value_TextChanged);
|
||||
this.CityValue.Validated += new System.EventHandler(this.Value_TextChanged);
|
||||
//
|
||||
// StateLabel
|
||||
//
|
||||
this.StateLabel.Location = new System.Drawing.Point(17, 74);
|
||||
this.StateLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.StateLabel.Name = "StateLabel";
|
||||
this.StateLabel.Size = new System.Drawing.Size(61, 23);
|
||||
this.StateLabel.TabIndex = 22;
|
||||
this.StateLabel.Text = "Region:";
|
||||
this.StateLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
//
|
||||
// ZipLabel
|
||||
//
|
||||
this.ZipLabel.Location = new System.Drawing.Point(533, 45);
|
||||
this.ZipLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.ZipLabel.Name = "ZipLabel";
|
||||
this.ZipLabel.Size = new System.Drawing.Size(37, 23);
|
||||
this.ZipLabel.TabIndex = 20;
|
||||
this.ZipLabel.Text = "Zip:";
|
||||
this.ZipLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
//
|
||||
// ZipValue
|
||||
//
|
||||
this.ZipValue.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.ZipValue.Location = new System.Drawing.Point(579, 46);
|
||||
this.ZipValue.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.ZipValue.Name = "ZipValue";
|
||||
this.ZipValue.oldText = null;
|
||||
this.ZipValue.Size = new System.Drawing.Size(124, 22);
|
||||
this.ZipValue.TabIndex = 21;
|
||||
this.ZipValue.LostFocus += new System.EventHandler(this.Value_TextChanged);
|
||||
this.ZipValue.Validated += new System.EventHandler(this.Value_TextChanged);
|
||||
//
|
||||
// AddressBox
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.ExtAddrValue);
|
||||
this.Controls.Add(this.ExtAdressLabel);
|
||||
this.Controls.Add(this.StreetLabel);
|
||||
this.Controls.Add(this.StreetValue);
|
||||
this.Controls.Add(this.POBoxLabel);
|
||||
this.Controls.Add(this.CountryValue);
|
||||
this.Controls.Add(this.Country);
|
||||
this.Controls.Add(this.POBoxValue);
|
||||
this.Controls.Add(this.CityLabel);
|
||||
this.Controls.Add(this.RegionValue);
|
||||
this.Controls.Add(this.CityValue);
|
||||
this.Controls.Add(this.StateLabel);
|
||||
this.Controls.Add(this.ZipLabel);
|
||||
this.Controls.Add(this.ZipValue);
|
||||
this.Name = "AddressBox";
|
||||
this.Size = new System.Drawing.Size(706, 104);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
internal StateTextBox ExtAddrValue;
|
||||
internal System.Windows.Forms.Label ExtAdressLabel;
|
||||
internal System.Windows.Forms.Label StreetLabel;
|
||||
internal StateTextBox StreetValue;
|
||||
internal System.Windows.Forms.Label POBoxLabel;
|
||||
internal StateTextBox CountryValue;
|
||||
internal System.Windows.Forms.Label Country;
|
||||
internal StateTextBox POBoxValue;
|
||||
internal System.Windows.Forms.Label CityLabel;
|
||||
internal StateTextBox RegionValue;
|
||||
internal StateTextBox CityValue;
|
||||
internal System.Windows.Forms.Label StateLabel;
|
||||
internal System.Windows.Forms.Label ZipLabel;
|
||||
internal StateTextBox ZipValue;
|
||||
}
|
||||
}
|
||||
65
vCardEditor/View/Customs/AddressBox.cs
Normal file
65
vCardEditor/View/Customs/AddressBox.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
using Thought.vCards;
|
||||
|
||||
namespace vCardEditor.View.Customs
|
||||
{
|
||||
public partial class AddressBox : UserControl
|
||||
{
|
||||
public event EventHandler TextChangedEvent;
|
||||
public List<vCardDeliveryAddressTypes> AddressType { get; set; }
|
||||
|
||||
|
||||
public AddressBox(string street, string city, string region, string country, string postalCode,
|
||||
string extendedAddress, string postOfficeBox, List<vCardDeliveryAddressTypes> addressType)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
this.AddressType = addressType;
|
||||
CityValue.Text = city;
|
||||
CityValue.oldText = city;
|
||||
|
||||
CountryValue.Text = country;
|
||||
CountryValue.oldText = country;
|
||||
|
||||
ZipValue.Text = postalCode;
|
||||
ZipValue.oldText = postalCode;
|
||||
|
||||
RegionValue.Text = region;
|
||||
RegionValue.oldText = region;
|
||||
|
||||
StreetValue.Text = street;
|
||||
StreetValue.oldText = street;
|
||||
|
||||
ExtAddrValue.Text = extendedAddress;
|
||||
ExtAddrValue.oldText = extendedAddress;
|
||||
|
||||
POBoxValue.Text = postOfficeBox;
|
||||
POBoxValue.oldText = postOfficeBox;
|
||||
}
|
||||
|
||||
private void Value_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
TextChangedEvent?.Invoke(sender, e);
|
||||
}
|
||||
|
||||
public vCardDeliveryAddress getDeliveryAddress()
|
||||
{
|
||||
var deliveryAddress = new vCardDeliveryAddress
|
||||
{
|
||||
City = CityValue.Text,
|
||||
Country = CountryValue.Text,
|
||||
PostalCode = ZipValue.Text,
|
||||
Region = RegionValue.Text,
|
||||
Street = StreetValue.Text,
|
||||
ExtendedAddress = ExtAddrValue.Text,
|
||||
PostOfficeBox = POBoxValue.Text,
|
||||
AddressType = AddressType
|
||||
};
|
||||
|
||||
return deliveryAddress;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
120
vCardEditor/View/Customs/AddressBox.resx
Normal file
120
vCardEditor/View/Customs/AddressBox.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=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>
|
||||
@@ -1,32 +1,83 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Forms;
|
||||
using Thought.vCards;
|
||||
using VCFEditor.View;
|
||||
|
||||
namespace vCardEditor.View.Customs
|
||||
{
|
||||
class AddressTabControl : TabControl
|
||||
{
|
||||
|
||||
|
||||
public event EventHandler TextChangedEvent;
|
||||
public event EventHandler<EventArg<List<vCardDeliveryAddressTypes>>> AddTab;
|
||||
public event EventHandler<EventArg<int>> RemoveTab;
|
||||
//public event EventHandler<EventArg<TabPage>> ModifyTab;
|
||||
|
||||
public AddressTabControl()
|
||||
{
|
||||
Padding = new Point(12, 4);
|
||||
|
||||
Padding = new Point(20, 20);
|
||||
ShowToolTips = true;
|
||||
DrawMode = TabDrawMode.OwnerDrawFixed;
|
||||
|
||||
DrawItem += tbcAddress_DrawItem;
|
||||
MouseDown += tbcAddress_MouseDown;
|
||||
Selecting += tbcAddress_Selecting;
|
||||
HandleCreated += tbcAddress_HandleCreated;
|
||||
HandleCreated += tabControl1_HandleCreated;
|
||||
MouseDoubleClick += AddressTabControl_MouseDoubleClick;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void getDeliveryAddress(vCard card)
|
||||
{
|
||||
if (TabCount < 2)
|
||||
return;
|
||||
|
||||
card.DeliveryAddresses.Clear();
|
||||
|
||||
for (int i = 0; i < TabCount - 1; i++)
|
||||
{
|
||||
AddressBox adr = TabPages[i].Controls[0] as AddressBox;
|
||||
card.DeliveryAddresses.Add(adr.getDeliveryAddress());
|
||||
}
|
||||
}
|
||||
|
||||
private void AddressTabControl_MouseDoubleClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
//NOT IMPLEMENTED
|
||||
//TabPage checkTab;
|
||||
//for (int i = 0; i < TabPages.Count; ++i)
|
||||
//{
|
||||
// if (GetTabRect(i).Contains(e.Location))
|
||||
// {
|
||||
// var AddressBox = TabPages[i].Controls[0] as AddressBox;
|
||||
|
||||
// var diag = new AddAddress(AddressBox.AddressType);
|
||||
// diag.ShowDialog();
|
||||
// //if (diag.ShowDialog() == DialogResult.OK)
|
||||
// // _card.DeliveryAddresses[i].AddressType = diag.Addresses;
|
||||
// //ModifyTab?.Invoke(sender, new EventArg<TabPage>(checkTab));
|
||||
// break;
|
||||
// }
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wp, IntPtr lp);
|
||||
private const int TCM_SETMINTABWIDTH = 0x1300 + 49;
|
||||
|
||||
private void tbcAddress_HandleCreated(object sender, EventArgs e)
|
||||
private void tabControl1_HandleCreated(object sender, EventArgs e)
|
||||
{
|
||||
SendMessage(Handle, TCM_SETMINTABWIDTH, IntPtr.Zero, (IntPtr)16);
|
||||
}
|
||||
|
||||
|
||||
private void tbcAddress_Selecting(object sender, TabControlCancelEventArgs e)
|
||||
{
|
||||
if (e.TabPageIndex == TabCount - 1)
|
||||
@@ -39,9 +90,15 @@ namespace vCardEditor.View.Customs
|
||||
var lastIndex = TabCount - 1;
|
||||
if (GetTabRect(lastIndex).Contains(e.Location))
|
||||
{
|
||||
TabPages.Insert(lastIndex, "New Tab");
|
||||
SelectedIndex = lastIndex;
|
||||
|
||||
var diag = new AddAddress();
|
||||
if (diag.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
vCardDeliveryAddress da = new vCardDeliveryAddress();
|
||||
da.AddressType = diag.Addresses;
|
||||
AddtabForAddress(da);
|
||||
AddTab?.Invoke(sender, new EventArg<List<vCardDeliveryAddressTypes>>(diag.Addresses));
|
||||
}
|
||||
SelectedIndex = TabCount - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -53,22 +110,36 @@ namespace vCardEditor.View.Customs
|
||||
var imageRect = new Rectangle(
|
||||
(tabRect.Right - closeImage.Width),
|
||||
tabRect.Top + (tabRect.Height - closeImage.Height) / 2,
|
||||
closeImage.Width,
|
||||
closeImage.Height);
|
||||
closeImage.Width, closeImage.Height);
|
||||
|
||||
if (imageRect.Contains(e.Location))
|
||||
{
|
||||
TabPages.RemoveAt(i);
|
||||
break;
|
||||
var result = MessageBox.Show("Remove tab?", "Asking", MessageBoxButtons.YesNo);
|
||||
if (result == DialogResult.Yes)
|
||||
{
|
||||
TabPages.RemoveAt(i);
|
||||
SelectedIndex = 0;
|
||||
RemoveTab?.Invoke(sender, new EventArg<int>(i));
|
||||
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void tbcAddress_DrawItem(object sender, DrawItemEventArgs e)
|
||||
{
|
||||
var tabPage = TabPages[e.Index];
|
||||
if (e.Index > TabCount - 1)
|
||||
return;
|
||||
|
||||
var tabRect = GetTabRect(e.Index);
|
||||
tabRect.Inflate(-2, -2);
|
||||
|
||||
if (e.Index == TabCount - 1)
|
||||
{
|
||||
var addImage = Properties.Resources.Add;
|
||||
@@ -82,10 +153,72 @@ namespace vCardEditor.View.Customs
|
||||
e.Graphics.DrawImage(closeImage,
|
||||
(tabRect.Right - closeImage.Width),
|
||||
tabRect.Top + (tabRect.Height - closeImage.Height) / 2);
|
||||
TextRenderer.DrawText(e.Graphics, tabPage.Text, tabPage.Font,
|
||||
tabRect, tabPage.ForeColor, TextFormatFlags.Left);
|
||||
|
||||
TabPage SelectedTab = TabPages[e.Index];
|
||||
Rectangle HeaderRect = GetTabRect(e.Index);
|
||||
SolidBrush TextBrush = new SolidBrush(Color.Black);
|
||||
StringFormat sf = new StringFormat
|
||||
{
|
||||
LineAlignment = StringAlignment.Center
|
||||
};
|
||||
|
||||
if (e.State == DrawItemState.Selected)
|
||||
{
|
||||
Font BoldFont = new Font(Font.Name, Font.Size, FontStyle.Bold);
|
||||
|
||||
e.Graphics.DrawString(SelectedTab.Text, BoldFont, TextBrush, HeaderRect, sf);
|
||||
}
|
||||
else
|
||||
e.Graphics.DrawString(SelectedTab.Text , e.Font, TextBrush, HeaderRect, sf);
|
||||
|
||||
TextBrush.Dispose();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void SetAddresses(vCard card)
|
||||
{
|
||||
ClearTabs();
|
||||
AddTabForEveryAddress(card);
|
||||
}
|
||||
|
||||
private void AddTabForEveryAddress(vCard card)
|
||||
{
|
||||
foreach (var item in card.DeliveryAddresses)
|
||||
AddtabForAddress(item);
|
||||
|
||||
//Page for the "+" sign
|
||||
TabPages.Add(new TabPage(" "));
|
||||
}
|
||||
|
||||
private void AddtabForAddress(vCardDeliveryAddress da)
|
||||
{
|
||||
var title = da.AddressType[0].ToString();
|
||||
|
||||
if (da.AddressType.Count > 1)
|
||||
title += "...";
|
||||
|
||||
var page = new TabPage($" {title} ");
|
||||
TabPages.Add(page);
|
||||
|
||||
var ab = new AddressBox(da.Street, da.City, da.Region, da.Country,
|
||||
da.PostalCode, da.ExtendedAddress, da.PostOfficeBox, da.AddressType);
|
||||
|
||||
ab.TextChangedEvent += (s, e) => TextChangedEvent?.Invoke(s, e);
|
||||
page.Controls.Add(ab);
|
||||
page.ToolTipText = string.Join(",", da.AddressType.ConvertAll(f => f.ToString()));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void ClearTabs()
|
||||
{
|
||||
|
||||
//Remove every tab. We don't call Clear() as it doesn't free memory.
|
||||
while (TabCount > 0)
|
||||
TabPages[TabCount - 1].Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,10 @@ namespace VCFEditor.View
|
||||
event EventHandler<EventArg<bool>> CloseForm;
|
||||
event EventHandler<EventArg<string>> ModifyImage;
|
||||
event EventHandler ExportImage;
|
||||
event EventHandler<EventArg<List<vCardDeliveryAddressTypes>>> AddressAdded;
|
||||
event EventHandler<EventArg<int>> AddressRemoved;
|
||||
|
||||
|
||||
int SelectedContactIndex { get; }
|
||||
void DisplayContacts(BindingList<Contact> contacts);
|
||||
void DisplayContactDetail(vCard card, string FileName);
|
||||
|
||||
898
vCardEditor/View/MainForm.Designer.cs
generated
898
vCardEditor/View/MainForm.Designer.cs
generated
File diff suppressed because it is too large
Load Diff
@@ -8,7 +8,7 @@ using Thought.vCards;
|
||||
using vCardEditor.Repository;
|
||||
using vCardEditor.Model;
|
||||
using System.Drawing;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace vCardEditor.View
|
||||
{
|
||||
@@ -25,10 +25,13 @@ namespace vCardEditor.View
|
||||
public event EventHandler TextBoxValueChanged;
|
||||
public event EventHandler<EventArg<bool>> CloseForm;
|
||||
public event EventHandler<EventArg<string>> ModifyImage;
|
||||
public event EventHandler<EventArg<List<vCardDeliveryAddressTypes>>> AddressAdded;
|
||||
public event EventHandler<EventArg<int>> AddressRemoved;
|
||||
public event EventHandler ExportImage;
|
||||
|
||||
ComponentResourceManager resources;
|
||||
|
||||
|
||||
public int SelectedContactIndex
|
||||
{
|
||||
get
|
||||
@@ -45,11 +48,12 @@ namespace vCardEditor.View
|
||||
{
|
||||
InitializeComponent();
|
||||
resources = new ComponentResourceManager(typeof(MainForm));
|
||||
|
||||
tbcAddress.AddTab += (sender, e) => AddressAdded?.Invoke(sender, e);
|
||||
tbcAddress.RemoveTab += (sender, e) => AddressRemoved?.Invoke(sender, e);
|
||||
tbcAddress.TextChangedEvent += (sender, e) => TextBoxValueChanged?.Invoke(sender, e);
|
||||
BuildMRUMenu();
|
||||
|
||||
}
|
||||
|
||||
private void tbsOpen_Click(object sender, EventArgs e)
|
||||
{
|
||||
NewFileOpened?.Invoke(sender, new EventArg<string>(string.Empty));
|
||||
@@ -78,14 +82,13 @@ namespace vCardEditor.View
|
||||
private void tbsNew_Click(object sender, EventArgs e)
|
||||
{
|
||||
AddContact?.Invoke(sender, e);
|
||||
|
||||
}
|
||||
|
||||
private void dgContacts_SelectionChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (ChangeContactsSelected != null && dgContacts.CurrentCell != null)
|
||||
{
|
||||
vCard data = GetvCard();
|
||||
vCard data = GetvCardFromWindow();
|
||||
ChangeContactsSelected(sender, new EventArg<vCard>(data));
|
||||
}
|
||||
else
|
||||
@@ -116,7 +119,7 @@ namespace vCardEditor.View
|
||||
SetSummaryValue(WorkPhoneValue, card.Phones.GetFirstChoice(vCardPhoneTypes.Work));
|
||||
SetSummaryValue(EmailAddressValue, card.EmailAddresses.GetFirstChoice(vCardEmailAddressType.Internet));
|
||||
SetSummaryValue(PersonalWebSiteValue, card.Websites.GetFirstChoice(vCardWebsiteTypes.Personal));
|
||||
SetAddressesValues(card.DeliveryAddresses);
|
||||
SetAddressesValues(card);
|
||||
SetPhotoValue(card.Photos);
|
||||
|
||||
}
|
||||
@@ -136,7 +139,7 @@ namespace vCardEditor.View
|
||||
SetSummaryValue(WorkPhoneValue, string.Empty);
|
||||
SetSummaryValue(EmailAddressValue, string.Empty);
|
||||
SetSummaryValue(PersonalWebSiteValue, string.Empty);
|
||||
SetAddressesValues(new vCardDeliveryAddressCollection());
|
||||
SetAddressesValues(new vCard());
|
||||
SetPhotoValue(new vCardPhotoCollection());
|
||||
|
||||
}
|
||||
@@ -198,72 +201,11 @@ namespace vCardEditor.View
|
||||
PhotoBox.Image = (Image)resources.GetObject("PhotoBox.Image");
|
||||
|
||||
}
|
||||
private void SetAddressesValues(vCardDeliveryAddressCollection addresses)
|
||||
private void SetAddressesValues(vCard card)
|
||||
{
|
||||
ClearAddressTextFields();
|
||||
|
||||
if (addresses.Any())
|
||||
{
|
||||
var HomeAddress = addresses.Where(x => x.IsHome).FirstOrDefault();
|
||||
if (HomeAddress != null)
|
||||
{
|
||||
HomeAddressValue.Text = HomeAddress.Street;
|
||||
HomeCityValue.Text = HomeAddress.City;
|
||||
HomeZipValue.Text = HomeAddress.PostalCode;
|
||||
HomeStateValue.Text = HomeAddress.Region;
|
||||
HomeCountryValue.Text = HomeAddress.Country;
|
||||
}
|
||||
|
||||
var WorkAddress = addresses.Where(x => x.IsWork).FirstOrDefault();
|
||||
if (WorkAddress != null)
|
||||
{
|
||||
WorkAddressValue.Text = WorkAddress.Street;
|
||||
WorkCityValue.Text = WorkAddress.City;
|
||||
WorkZipValue.Text = WorkAddress.PostalCode;
|
||||
WorkStateValue.Text = WorkAddress.Region;
|
||||
WorkCountryValue.Text = WorkAddress.Country;
|
||||
}
|
||||
|
||||
var PostalAddress = addresses.Where(x => x.IsPostal).FirstOrDefault();
|
||||
if (PostalAddress != null)
|
||||
{
|
||||
PostalAddressValue.Text = PostalAddress.Street;
|
||||
PostalAddressValue.Text = PostalAddress.Street;
|
||||
PostalCityValue.Text = PostalAddress.City;
|
||||
PostalZipValue.Text = PostalAddress.PostalCode;
|
||||
PostalStateValue.Text = PostalAddress.Region;
|
||||
PostalCountryValue.Text = PostalAddress.Country;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
tbcAddress.SetAddresses(card);
|
||||
}
|
||||
|
||||
private void ClearAddressTextFields()
|
||||
{
|
||||
HomeAddressValue.Clear();
|
||||
HomePOBoxValue.Clear();
|
||||
HomeCityValue.Clear();
|
||||
HomeZipValue.Clear();
|
||||
HomeStateValue.Clear();
|
||||
HomeCountryValue.Clear();
|
||||
|
||||
WorkAddressValue.Clear();
|
||||
WorkPOBoxValue.Clear();
|
||||
WorkCityValue.Clear();
|
||||
WorkZipValue.Clear();
|
||||
WorkStateValue.Clear();
|
||||
WorkCountryValue.Clear();
|
||||
|
||||
PostalAddressValue.Clear();
|
||||
PostalPOBoxValue.Clear();
|
||||
PostalCityValue.Clear();
|
||||
PostalZipValue.Clear();
|
||||
PostalStateValue.Clear();
|
||||
PostalCountryValue.Clear();
|
||||
}
|
||||
|
||||
|
||||
private void tbsDelete_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (DeleteContact != null)
|
||||
@@ -283,7 +225,7 @@ namespace vCardEditor.View
|
||||
private void textBoxFilter_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
//Save before leaving contact.
|
||||
BeforeLeavingContact?.Invoke(sender, new EventArg<vCard>(GetvCard()));
|
||||
BeforeLeavingContact?.Invoke(sender, new EventArg<vCard>(GetvCardFromWindow()));
|
||||
|
||||
FilterTextChanged?.Invoke(sender, new EventArg<string>(textBoxFilter.Text));
|
||||
}
|
||||
@@ -294,10 +236,10 @@ namespace vCardEditor.View
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generate a vcard from differents fields
|
||||
/// Generate a vcard from differents fields on the form.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private vCard GetvCard()
|
||||
private vCard GetvCardFromWindow()
|
||||
{
|
||||
vCard card = new vCard
|
||||
{
|
||||
@@ -316,32 +258,21 @@ namespace vCardEditor.View
|
||||
card.Phones.Add(new vCardPhone(CellularPhoneValue.Text, vCardPhoneTypes.Cellular));
|
||||
if (!string.IsNullOrEmpty(WorkPhoneValue.Text))
|
||||
card.Phones.Add(new vCardPhone(WorkPhoneValue.Text, vCardPhoneTypes.Work));
|
||||
|
||||
if (!string.IsNullOrEmpty(this.EmailAddressValue.Text))
|
||||
card.EmailAddresses.Add(new vCardEmailAddress(this.EmailAddressValue.Text));
|
||||
|
||||
if (!string.IsNullOrEmpty(this.PersonalWebSiteValue.Text))
|
||||
card.Websites.Add(new vCardWebsite(this.PersonalWebSiteValue.Text));
|
||||
|
||||
if (!string.IsNullOrEmpty(this.HomeAddressValue.Text))
|
||||
card.DeliveryAddresses.Add(new vCardDeliveryAddress(HomeAddressValue.Text, HomeCityValue.Text, HomeStateValue.Text, HomeCountryValue.Text,
|
||||
HomePOBoxValue.Text, vCardDeliveryAddressTypes.Home));
|
||||
|
||||
|
||||
if (!string.IsNullOrEmpty(this.WorkAddressValue.Text))
|
||||
card.DeliveryAddresses.Add(new vCardDeliveryAddress(WorkAddressValue.Text, WorkCityValue.Text, WorkStateValue.Text, WorkCountryValue.Text,
|
||||
WorkPOBoxValue.Text, vCardDeliveryAddressTypes.Work));
|
||||
|
||||
if (!string.IsNullOrEmpty(this.PostalAddressValue.Text))
|
||||
card.DeliveryAddresses.Add(new vCardDeliveryAddress(PostalAddressValue.Text, PostalCityValue.Text, PostalStateValue.Text, PostalCountryValue.Text,
|
||||
PostalPOBoxValue.Text, vCardDeliveryAddressTypes.Postal));
|
||||
|
||||
|
||||
tbcAddress.getDeliveryAddress(card);
|
||||
|
||||
return card;
|
||||
}
|
||||
|
||||
private void dgContacts_RowLeave(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
vCard data = GetvCard();
|
||||
vCard data = GetvCardFromWindow();
|
||||
BeforeLeavingContact?.Invoke(sender, new EventArg<vCard>(data));
|
||||
}
|
||||
|
||||
@@ -460,7 +391,7 @@ namespace vCardEditor.View
|
||||
var evt = new EventArg<string>(fileName);
|
||||
ModifyImage(sender, evt);
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
catch (ArgumentException)
|
||||
{
|
||||
MessageBox.Show($"Invalid file! : {fileName}");
|
||||
}
|
||||
@@ -482,7 +413,5 @@ namespace vCardEditor.View
|
||||
{
|
||||
ExportImage?.Invoke(sender, e);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,6 +133,18 @@
|
||||
<Compile Include="View\ConfigDialog.Designer.cs">
|
||||
<DependentUpon>ConfigDialog.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="View\Customs\AddAddress.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="View\Customs\AddAddress.Designer.cs">
|
||||
<DependentUpon>AddAddress.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="View\Customs\AddressBox.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="View\Customs\AddressBox.Designer.cs">
|
||||
<DependentUpon>AddressBox.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="View\Customs\AddressTabControl.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
@@ -164,6 +176,12 @@
|
||||
<EmbeddedResource Include="View\ConfigDialog.resx">
|
||||
<DependentUpon>ConfigDialog.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="View\Customs\AddAddress.resx">
|
||||
<DependentUpon>AddAddress.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="View\Customs\AddressBox.resx">
|
||||
<DependentUpon>AddressBox.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="View\MainForm.resx">
|
||||
<DependentUpon>MainForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
|
||||
Reference in New Issue
Block a user