mirror of
https://github.com/abdelkader/vCardEditor
synced 2025-12-12 08:27:19 +07:00
fixed merge
This commit is contained in:
@@ -15,6 +15,7 @@ namespace VCFEditor.Model
|
|||||||
NotifyPropertyChanged("Name");
|
NotifyPropertyChanged("Name");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[DisplayName("F.Name")]
|
[DisplayName("F.Name")]
|
||||||
public string FamilyName
|
public string FamilyName
|
||||||
{
|
{
|
||||||
@@ -27,12 +28,10 @@ namespace VCFEditor.Model
|
|||||||
get {
|
get {
|
||||||
if (card.Phones.GetFirstChoice(vCardPhoneTypes.Cellular) != null)
|
if (card.Phones.GetFirstChoice(vCardPhoneTypes.Cellular) != null)
|
||||||
return card.Phones.GetFirstChoice(vCardPhoneTypes.Cellular).FullNumber;
|
return card.Phones.GetFirstChoice(vCardPhoneTypes.Cellular).FullNumber;
|
||||||
|
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[Browsable(false)]
|
[Browsable(false)]
|
||||||
public vCard card { get; set; }
|
public vCard card { get; set; }
|
||||||
|
|
||||||
@@ -47,7 +46,6 @@ namespace VCFEditor.Model
|
|||||||
|
|
||||||
[Browsable(false)]
|
[Browsable(false)]
|
||||||
public string path { get; set; }
|
public string path { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public Contact()
|
public Contact()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,10 +16,9 @@ namespace vCardEditor.Model
|
|||||||
get { return _size; }
|
get { return _size; }
|
||||||
set { _size = value; }
|
set { _size = value; }
|
||||||
}
|
}
|
||||||
public FixedList() : this(5)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
public FixedList() : this(5) { }
|
||||||
|
|
||||||
public FixedList(int size)
|
public FixedList(int size)
|
||||||
{
|
{
|
||||||
this._size = size;
|
this._size = size;
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using Thought.vCards;
|
using Thought.vCards;
|
||||||
using VCFEditor.View;
|
using vCardEditor.Model;
|
||||||
|
using vCardEditor.Repository;
|
||||||
using vCardEditor.View.Customs;
|
using vCardEditor.View.Customs;
|
||||||
using VCFEditor.Repository;
|
using VCFEditor.Repository;
|
||||||
using vCardEditor.Repository;
|
using VCFEditor.View;
|
||||||
using vCardEditor.Model;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace VCFEditor.Presenter
|
namespace VCFEditor.Presenter
|
||||||
{
|
{
|
||||||
@@ -14,7 +14,6 @@ namespace VCFEditor.Presenter
|
|||||||
{
|
{
|
||||||
private readonly IMainView _view;
|
private readonly IMainView _view;
|
||||||
private readonly IContactRepository _repository;
|
private readonly IContactRepository _repository;
|
||||||
|
|
||||||
|
|
||||||
public MainPresenter(IMainView view, IContactRepository repository)
|
public MainPresenter(IMainView view, IContactRepository repository)
|
||||||
{
|
{
|
||||||
@@ -44,9 +43,6 @@ namespace VCFEditor.Presenter
|
|||||||
_view.BatchExportImagesEvent += _view_BatchExportImagesEvent;
|
_view.BatchExportImagesEvent += _view_BatchExportImagesEvent;
|
||||||
_view.SplitFileEvent += SaveSplittedFileHandler;
|
_view.SplitFileEvent += SaveSplittedFileHandler;
|
||||||
_view.OpenFolderEvent += OpenNewFolderHandler;
|
_view.OpenFolderEvent += OpenNewFolderHandler;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OpenNewFolderHandler(object sender, EventArg<string> e)
|
private void OpenNewFolderHandler(object sender, EventArg<string> e)
|
||||||
@@ -59,7 +55,7 @@ namespace VCFEditor.Presenter
|
|||||||
|
|
||||||
if (!string.IsNullOrEmpty(path))
|
if (!string.IsNullOrEmpty(path))
|
||||||
{
|
{
|
||||||
var Loaded =_repository.LoadMultipleFilesContact(path);
|
bool Loaded =_repository.LoadMultipleFilesContact(path);
|
||||||
if (!Loaded)
|
if (!Loaded)
|
||||||
{
|
{
|
||||||
_view.DisplayMessage("No file loaded!", "Error");
|
_view.DisplayMessage("No file loaded!", "Error");
|
||||||
@@ -69,7 +65,6 @@ namespace VCFEditor.Presenter
|
|||||||
AddPathToMostRecentUsedFiles(path);
|
AddPathToMostRecentUsedFiles(path);
|
||||||
_view.DisplayContacts(_repository.Contacts);
|
_view.DisplayContacts(_repository.Contacts);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OpenNewFileHandler(object sender, EventArg<string> e)
|
public void OpenNewFileHandler(object sender, EventArg<string> e)
|
||||||
@@ -89,7 +84,6 @@ namespace VCFEditor.Presenter
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!_repository.LoadContacts(path))
|
if (!_repository.LoadContacts(path))
|
||||||
_view.DisplayMessage("File seems missing or corrupted!", "Error");
|
_view.DisplayMessage("File seems missing or corrupted!", "Error");
|
||||||
else
|
else
|
||||||
@@ -98,9 +92,8 @@ namespace VCFEditor.Presenter
|
|||||||
AddPathToMostRecentUsedFiles(path);
|
AddPathToMostRecentUsedFiles(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddPathToMostRecentUsedFiles(string path)
|
private void AddPathToMostRecentUsedFiles(string path)
|
||||||
{
|
{
|
||||||
FixedList MostRecentUsedFiles = ConfigRepository.Instance.Paths;
|
FixedList MostRecentUsedFiles = ConfigRepository.Instance.Paths;
|
||||||
@@ -110,6 +103,7 @@ namespace VCFEditor.Presenter
|
|||||||
_view.UpdateMRUMenu(MostRecentUsedFiles);
|
_view.UpdateMRUMenu(MostRecentUsedFiles);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void _view_BatchExportImagesEvent(object sender, EventArgs e)
|
private void _view_BatchExportImagesEvent(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_repository.Contacts == null || _repository.Contacts.Count == 0)
|
if (_repository.Contacts == null || _repository.Contacts.Count == 0)
|
||||||
@@ -122,7 +116,6 @@ namespace VCFEditor.Presenter
|
|||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
SaveCardPhoto(_repository.Contacts[i].card, i);
|
SaveCardPhoto(_repository.Contacts[i].card, i);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,7 +144,6 @@ namespace VCFEditor.Presenter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (count > 0)
|
if (count > 0)
|
||||||
_view.DisplayMessage($"{count} contact(s) processed!", "Photo Count");
|
_view.DisplayMessage($"{count} contact(s) processed!", "Photo Count");
|
||||||
else
|
else
|
||||||
@@ -163,7 +155,7 @@ namespace VCFEditor.Presenter
|
|||||||
if (_repository.Contacts == null)
|
if (_repository.Contacts == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var count = _repository.Contacts.Count(x => x.card.Photos.Count > 0);
|
int count = _repository.Contacts.Count(x => x.card.Photos.Count > 0);
|
||||||
if (count > 0)
|
if (count > 0)
|
||||||
_view.DisplayMessage($"{count} contact(s) containing a picture = ", "Photo Count");
|
_view.DisplayMessage($"{count} contact(s) containing a picture = ", "Photo Count");
|
||||||
else
|
else
|
||||||
@@ -187,19 +179,18 @@ namespace VCFEditor.Presenter
|
|||||||
_view.SendTextToClipBoard(SerializedCard);
|
_view.SendTextToClipBoard(SerializedCard);
|
||||||
_view.DisplayMessage("vCard copied to clipboard!", "Information");
|
_view.DisplayMessage("vCard copied to clipboard!", "Information");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadFormHandler(object sender, EventArg<FormState> e)
|
private void LoadFormHandler(object sender, EventArg<FormState> e)
|
||||||
{
|
{
|
||||||
_view.LoadIntialState(ConfigRepository.Instance.FormState);
|
_view.LoadIntialState(ConfigRepository.Instance.FormState);
|
||||||
var paths = Environment.GetCommandLineArgs();
|
string[] paths = Environment.GetCommandLineArgs();
|
||||||
if (paths.Length > 1)
|
if (paths.Length > 1)
|
||||||
{
|
{
|
||||||
var evt = new EventArg<string>(paths[1]);
|
var evt = new EventArg<string>(paths[1]);
|
||||||
OpenNewFileHandler(sender, evt);
|
OpenNewFileHandler(sender, evt);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void AddressRemovedHandler(object sender, EventArg<int> e)
|
private void AddressRemovedHandler(object sender, EventArg<int> e)
|
||||||
{
|
{
|
||||||
var contact = _repository.Contacts[_view.SelectedContactIndex];
|
var contact = _repository.Contacts[_view.SelectedContactIndex];
|
||||||
@@ -224,13 +215,13 @@ namespace VCFEditor.Presenter
|
|||||||
contact.card.DeliveryAddresses.Clear();
|
contact.card.DeliveryAddresses.Clear();
|
||||||
contact.card.DeliveryAddresses.Add(new vCardDeliveryAddress(e.Data));
|
contact.card.DeliveryAddresses.Add(new vCardDeliveryAddress(e.Data));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ExportImageHandler(object sender, EventArgs e)
|
private void ExportImageHandler(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (_view.SelectedContactIndex > -1)
|
if (_view.SelectedContactIndex > -1)
|
||||||
{
|
{
|
||||||
//TODO: image can be url, or file location.
|
//TODO: image can be url, or file location.
|
||||||
var card = _repository.Contacts[_view.SelectedContactIndex].card;
|
vCard card = _repository.Contacts[_view.SelectedContactIndex].card;
|
||||||
SaveCardPhoto(card, _view.SelectedContactIndex, true);
|
SaveCardPhoto(card, _view.SelectedContactIndex, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -238,12 +229,11 @@ namespace VCFEditor.Presenter
|
|||||||
private void SaveCardPhoto(vCard card, int index, bool askUser = false)
|
private void SaveCardPhoto(vCard card, int index, bool askUser = false)
|
||||||
{
|
{
|
||||||
//TODO: Save every image for a vCard.
|
//TODO: Save every image for a vCard.
|
||||||
var image = card.Photos.FirstOrDefault();
|
vCardPhoto image = card.Photos.FirstOrDefault();
|
||||||
|
|
||||||
if (image != null)
|
if (image != null)
|
||||||
{
|
{
|
||||||
|
string newPath = _repository.GenerateFileName(_repository.fileName, index, image.Extension);
|
||||||
var newPath = _repository.GenerateFileName(_repository.fileName, index, image.Extension);
|
|
||||||
|
|
||||||
//string ImagePath = string.Empty;
|
//string ImagePath = string.Empty;
|
||||||
//if (askUser)
|
//if (askUser)
|
||||||
@@ -255,10 +245,9 @@ namespace VCFEditor.Presenter
|
|||||||
|
|
||||||
private void ExportQRHandler(object sender, EventArgs e)
|
private void ExportQRHandler(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (_view.SelectedContactIndex > -1)
|
if (_view.SelectedContactIndex > -1)
|
||||||
{
|
{
|
||||||
var card = _repository.Contacts[_view.SelectedContactIndex].card;
|
vCard card = _repository.Contacts[_view.SelectedContactIndex].card;
|
||||||
string content = _repository.GenerateStringFromVCard(card);
|
string content = _repository.GenerateStringFromVCard(card);
|
||||||
|
|
||||||
_view.DisplayQRCode(content);
|
_view.DisplayQRCode(content);
|
||||||
@@ -267,14 +256,13 @@ namespace VCFEditor.Presenter
|
|||||||
|
|
||||||
private void ModifyImageHandler(object sender, EventArg<string> e)
|
private void ModifyImageHandler(object sender, EventArg<string> e)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(e.Data) )
|
if (!string.IsNullOrEmpty(e.Data))
|
||||||
{
|
{
|
||||||
vCardPhoto photo = new vCardPhoto(e.Data);
|
vCardPhoto photo = new vCardPhoto(e.Data);
|
||||||
_repository.ModifyImage(_view.SelectedContactIndex, photo);
|
_repository.ModifyImage(_view.SelectedContactIndex, photo);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
_repository.ModifyImage(_view.SelectedContactIndex, null);
|
_repository.ModifyImage(_view.SelectedContactIndex, null);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CloseFormHandler(object sender, EventArg<bool> e)
|
void CloseFormHandler(object sender, EventArg<bool> e)
|
||||||
@@ -284,12 +272,12 @@ namespace VCFEditor.Presenter
|
|||||||
|
|
||||||
if (!e.Data)
|
if (!e.Data)
|
||||||
{
|
{
|
||||||
var state = _view.GetFormState();
|
FormState state = _view.GetFormState();
|
||||||
ConfigRepository.Instance.FormState = state;
|
ConfigRepository.Instance.FormState = state;
|
||||||
ConfigRepository.Instance.SaveConfig();
|
ConfigRepository.Instance.SaveConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void BeforeLeavingContactHandler(object sender, EventArg<vCard> e)
|
public void BeforeLeavingContactHandler(object sender, EventArg<vCard> e)
|
||||||
{
|
{
|
||||||
_repository.SaveDirtyVCard(_view.SelectedContactIndex, e.Data);
|
_repository.SaveDirtyVCard(_view.SelectedContactIndex, e.Data);
|
||||||
@@ -297,10 +285,9 @@ namespace VCFEditor.Presenter
|
|||||||
|
|
||||||
public void TextBoxValueChangedHandler(object sender, EventArgs e)
|
public void TextBoxValueChangedHandler(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var tb = sender as StateTextBox;
|
StateTextBox tb = sender as StateTextBox;
|
||||||
if (tb != null && tb.oldText != tb.Text)
|
if (tb != null && tb.oldText != tb.Text)
|
||||||
_repository.SetDirtyFlag(_view.SelectedContactIndex);
|
_repository.SetDirtyFlag(_view.SelectedContactIndex);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void FilterTextChangedHandler(object sender, EventArg<string> e)
|
public void FilterTextChangedHandler(object sender, EventArg<string> e)
|
||||||
@@ -328,10 +315,7 @@ namespace VCFEditor.Presenter
|
|||||||
else
|
else
|
||||||
filename = _view.DisplaySaveDialog("");
|
filename = _view.DisplaySaveDialog("");
|
||||||
|
|
||||||
|
|
||||||
_repository.SaveContactsToFile(filename);
|
_repository.SaveContactsToFile(filename);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SaveSplittedFileHandler(object sender, EventArgs e)
|
private void SaveSplittedFileHandler(object sender, EventArgs e)
|
||||||
@@ -345,7 +329,6 @@ namespace VCFEditor.Presenter
|
|||||||
int count = _repository.SaveSplittedFiles(Path);
|
int count = _repository.SaveSplittedFiles(Path);
|
||||||
_view.DisplayMessage(string.Format("{0} contact(s) processed!", count), "Information");
|
_view.DisplayMessage(string.Format("{0} contact(s) processed!", count), "Information");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BeforeOpeningNewFileHandler()
|
private void BeforeOpeningNewFileHandler()
|
||||||
@@ -356,13 +339,10 @@ namespace VCFEditor.Presenter
|
|||||||
SaveContactsHandler(null, null);
|
SaveContactsHandler(null, null);
|
||||||
//_repository.SaveContactsToFile(_repository.fileName);
|
//_repository.SaveContactsToFile(_repository.fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void ChangeContactSelectedHandler(object sender, EventArgs e)
|
public void ChangeContactSelectedHandler(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (_view.SelectedContactIndex > -1)
|
if (_view.SelectedContactIndex > -1)
|
||||||
{
|
{
|
||||||
vCard card = _repository.Contacts[_view.SelectedContactIndex].card;
|
vCard card = _repository.Contacts[_view.SelectedContactIndex].card;
|
||||||
@@ -374,8 +354,6 @@ namespace VCFEditor.Presenter
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
_view.ClearContactDetail();
|
_view.ClearContactDetail();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using vCardEditor.Repository;
|
||||||
using vCardEditor.View;
|
using vCardEditor.View;
|
||||||
using VCFEditor.Presenter;
|
using VCFEditor.Presenter;
|
||||||
using VCFEditor;
|
|
||||||
using VCFEditor.Repository;
|
using VCFEditor.Repository;
|
||||||
using vCardEditor.Repository;
|
|
||||||
|
|
||||||
namespace vCardEditor
|
namespace vCardEditor
|
||||||
{
|
{
|
||||||
@@ -21,8 +18,8 @@ namespace vCardEditor
|
|||||||
Application.EnableVisualStyles();
|
Application.EnableVisualStyles();
|
||||||
Application.SetCompatibleTextRenderingDefault(false);
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
|
|
||||||
var fileHandler = new FileHandler();
|
FileHandler fileHandler = new FileHandler();
|
||||||
var mainForm = new MainForm();
|
MainForm mainForm = new MainForm();
|
||||||
new MainPresenter(mainForm, new ContactRepository(fileHandler));
|
new MainPresenter(mainForm, new ContactRepository(fileHandler));
|
||||||
|
|
||||||
Application.Run(mainForm);
|
Application.Run(mainForm);
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ namespace vCardEditor.Repository
|
|||||||
|
|
||||||
private const int MAX_RECENT_FILES = 5;
|
private const int MAX_RECENT_FILES = 5;
|
||||||
private static ConfigRepository instance = null;
|
private static ConfigRepository instance = null;
|
||||||
|
|
||||||
[XmlIgnore]
|
[XmlIgnore]
|
||||||
public static ConfigRepository Instance
|
public static ConfigRepository Instance
|
||||||
{
|
{
|
||||||
@@ -31,6 +32,7 @@ namespace vCardEditor.Repository
|
|||||||
|
|
||||||
[Description("Overwrite the file when saving")]
|
[Description("Overwrite the file when saving")]
|
||||||
public bool Overwrite { get; set; }
|
public bool Overwrite { get; set; }
|
||||||
|
|
||||||
[Description("Maximum entries for MRU ")]
|
[Description("Maximum entries for MRU ")]
|
||||||
public int Maximum { get; set; }
|
public int Maximum { get; set; }
|
||||||
|
|
||||||
@@ -45,14 +47,12 @@ namespace vCardEditor.Repository
|
|||||||
|
|
||||||
private ConfigRepository() { }
|
private ConfigRepository() { }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// save config file
|
/// save config file
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void SaveConfig()
|
public void SaveConfig()
|
||||||
{
|
{
|
||||||
var ns = new XmlSerializerNamespaces();
|
XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
|
||||||
ns.Add("", "");
|
ns.Add("", "");
|
||||||
|
|
||||||
XmlSerializer xsSubmit = new XmlSerializer(typeof(ConfigRepository));
|
XmlSerializer xsSubmit = new XmlSerializer(typeof(ConfigRepository));
|
||||||
@@ -82,7 +82,6 @@ namespace vCardEditor.Repository
|
|||||||
configData = (ConfigRepository)deserializer.Deserialize(reader);
|
configData = (ConfigRepository)deserializer.Deserialize(reader);
|
||||||
configData.Paths.Size = configData.Maximum;
|
configData.Paths.Size = configData.Maximum;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
@@ -94,10 +93,7 @@ namespace vCardEditor.Repository
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return configData;
|
return configData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ using System.IO;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Thought.vCards;
|
using Thought.vCards;
|
||||||
using VCFEditor.Model;
|
|
||||||
using vCardEditor.Repository;
|
using vCardEditor.Repository;
|
||||||
using vCardEditor.View;
|
using vCardEditor.View;
|
||||||
|
using VCFEditor.Model;
|
||||||
|
|
||||||
namespace VCFEditor.Repository
|
namespace VCFEditor.Repository
|
||||||
{
|
{
|
||||||
@@ -13,16 +13,13 @@ namespace VCFEditor.Repository
|
|||||||
{
|
{
|
||||||
public string fileName { get; set; }
|
public string fileName { get; set; }
|
||||||
private IFileHandler _fileHandler;
|
private IFileHandler _fileHandler;
|
||||||
/// <summary>
|
|
||||||
/// Formatted name.
|
|
||||||
/// </summary>
|
|
||||||
public const string KeyName = "FN";
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Keep a copy of contact list when filtering
|
/// Keep a copy of contact list when filtering
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private SortableBindingList<Contact> OriginalContactList = null;
|
private SortableBindingList<Contact> OriginalContactList = null;
|
||||||
private SortableBindingList<Contact> _contacts;
|
private SortableBindingList<Contact> _contacts;
|
||||||
|
|
||||||
public SortableBindingList<Contact> Contacts
|
public SortableBindingList<Contact> Contacts
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -43,6 +40,7 @@ namespace VCFEditor.Repository
|
|||||||
get { return (_contacts != null && _contacts.Any(x => x.isDirty)) || _dirty; }
|
get { return (_contacts != null && _contacts.Any(x => x.isDirty)) || _dirty; }
|
||||||
set { _dirty = true; }
|
set { _dirty = true; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContactRepository(IFileHandler fileHandler)
|
public ContactRepository(IFileHandler fileHandler)
|
||||||
{
|
{
|
||||||
_fileHandler = fileHandler;
|
_fileHandler = fileHandler;
|
||||||
@@ -106,6 +104,7 @@ namespace VCFEditor.Repository
|
|||||||
|
|
||||||
return ListOfContacts;
|
return ListOfContacts;
|
||||||
}
|
}
|
||||||
|
|
||||||
private vCard ParseRawContent(StringBuilder rawContent)
|
private vCard ParseRawContent(StringBuilder rawContent)
|
||||||
{
|
{
|
||||||
vCard card = null;
|
vCard card = null;
|
||||||
@@ -181,12 +180,9 @@ namespace VCFEditor.Repository
|
|||||||
_dirty = true;
|
_dirty = true;
|
||||||
_contacts.RemoveAt(i);
|
_contacts.RemoveAt(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public SortableBindingList<Contact> FilterContacts(string filter)
|
public SortableBindingList<Contact> FilterContacts(string filter)
|
||||||
{
|
{
|
||||||
@@ -196,7 +192,6 @@ namespace VCFEditor.Repository
|
|||||||
return Contacts;
|
return Contacts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void SetDirtyFlag(int index)
|
public void SetDirtyFlag(int index)
|
||||||
{
|
{
|
||||||
if (index > -1)
|
if (index > -1)
|
||||||
@@ -229,7 +224,6 @@ namespace VCFEditor.Repository
|
|||||||
card.Phones.Clear();
|
card.Phones.Clear();
|
||||||
foreach (var item in newCard.Phones)
|
foreach (var item in newCard.Phones)
|
||||||
card.Phones.Add(new vCardPhone(item.FullNumber, item.PhoneType));
|
card.Phones.Add(new vCardPhone(item.FullNumber, item.PhoneType));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SaveExtraField(vCard newCard, vCard card)
|
private void SaveExtraField(vCard newCard, vCard card)
|
||||||
@@ -259,7 +253,6 @@ namespace VCFEditor.Repository
|
|||||||
else
|
else
|
||||||
card.DeliveryAddresses.Add(new vCardDeliveryAddress(item.Street, item.City, item.Region, item.Country,
|
card.DeliveryAddresses.Add(new vCardDeliveryAddress(item.Street, item.City, item.Region, item.Country,
|
||||||
item.PostalCode, item.AddressType.FirstOrDefault()));
|
item.PostalCode, item.AddressType.FirstOrDefault()));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -277,7 +270,6 @@ namespace VCFEditor.Repository
|
|||||||
{
|
{
|
||||||
if (card.Phones.GetFirstChoice(vCardPhoneTypes.Home) != null)
|
if (card.Phones.GetFirstChoice(vCardPhoneTypes.Home) != null)
|
||||||
card.Phones.GetFirstChoice(vCardPhoneTypes.Home).FullNumber = string.Empty;
|
card.Phones.GetFirstChoice(vCardPhoneTypes.Home).FullNumber = string.Empty;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -293,7 +285,6 @@ namespace VCFEditor.Repository
|
|||||||
{
|
{
|
||||||
if (card.Phones.GetFirstChoice(vCardPhoneTypes.Cellular) != null)
|
if (card.Phones.GetFirstChoice(vCardPhoneTypes.Cellular) != null)
|
||||||
card.Phones.GetFirstChoice(vCardPhoneTypes.Cellular).FullNumber = string.Empty;
|
card.Phones.GetFirstChoice(vCardPhoneTypes.Cellular).FullNumber = string.Empty;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Work
|
//Work
|
||||||
@@ -308,7 +299,6 @@ namespace VCFEditor.Repository
|
|||||||
{
|
{
|
||||||
if (card.Phones.GetFirstChoice(vCardPhoneTypes.Work) != null)
|
if (card.Phones.GetFirstChoice(vCardPhoneTypes.Work) != null)
|
||||||
card.Phones.GetFirstChoice(vCardPhoneTypes.Work).FullNumber = string.Empty;
|
card.Phones.GetFirstChoice(vCardPhoneTypes.Work).FullNumber = string.Empty;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -328,9 +318,7 @@ namespace VCFEditor.Repository
|
|||||||
{
|
{
|
||||||
if (card.EmailAddresses.GetFirstChoice(vCardEmailAddressType.Internet) != null)
|
if (card.EmailAddresses.GetFirstChoice(vCardEmailAddressType.Internet) != null)
|
||||||
card.EmailAddresses.GetFirstChoice(vCardEmailAddressType.Internet).Address = string.Empty;
|
card.EmailAddresses.GetFirstChoice(vCardEmailAddressType.Internet).Address = string.Empty;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SaveWebUrl(vCard NewCard, vCard card)
|
private void SaveWebUrl(vCard NewCard, vCard card)
|
||||||
@@ -347,7 +335,6 @@ namespace VCFEditor.Repository
|
|||||||
{
|
{
|
||||||
if (card.Websites.GetFirstChoice(vCardWebsiteTypes.Personal) != null)
|
if (card.Websites.GetFirstChoice(vCardWebsiteTypes.Personal) != null)
|
||||||
card.Websites.GetFirstChoice(vCardWebsiteTypes.Personal).Url = string.Empty;
|
card.Websites.GetFirstChoice(vCardWebsiteTypes.Personal).Url = string.Empty;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -362,7 +349,6 @@ namespace VCFEditor.Repository
|
|||||||
{
|
{
|
||||||
if (card.Websites.GetFirstChoice(vCardWebsiteTypes.Work) != null)
|
if (card.Websites.GetFirstChoice(vCardWebsiteTypes.Work) != null)
|
||||||
card.Websites.GetFirstChoice(vCardWebsiteTypes.Work).Url = string.Empty;
|
card.Websites.GetFirstChoice(vCardWebsiteTypes.Work).Url = string.Empty;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -415,7 +401,7 @@ namespace VCFEditor.Repository
|
|||||||
int count;
|
int count;
|
||||||
for (count = 0; count < contactsToSave.Count(); count++)
|
for (count = 0; count < contactsToSave.Count(); count++)
|
||||||
{
|
{
|
||||||
var entry = contactsToSave[count];
|
Contact entry = contactsToSave[count];
|
||||||
string SerializedCard = GenerateStringFromVCard(entry.card);
|
string SerializedCard = GenerateStringFromVCard(entry.card);
|
||||||
|
|
||||||
//Check if filename for the card is empty, and generate one if empty
|
//Check if filename for the card is empty, and generate one if empty
|
||||||
@@ -426,7 +412,6 @@ namespace VCFEditor.Repository
|
|||||||
|
|
||||||
//Clean the flag for every contact, even the deleted ones.
|
//Clean the flag for every contact, even the deleted ones.
|
||||||
entry.isDirty = false;
|
entry.isDirty = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Clean the global flag for the entire vCard Catalog.
|
//Clean the global flag for the entire vCard Catalog.
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ namespace vCardEditor.Repository
|
|||||||
{
|
{
|
||||||
if (File.Exists(newFilename))
|
if (File.Exists(newFilename))
|
||||||
File.Move(newFilename, oldFilename);
|
File.Move(newFilename, oldFilename);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string[] ReadAllLines(string filename)
|
public string[] ReadAllLines(string filename)
|
||||||
@@ -39,9 +38,9 @@ namespace vCardEditor.Repository
|
|||||||
|
|
||||||
public void WriteBytesToFile(string imageFile, byte[] image)
|
public void WriteBytesToFile(string imageFile, byte[] image)
|
||||||
{
|
{
|
||||||
using (var ms = new MemoryStream(image))
|
using (MemoryStream ms = new MemoryStream(image))
|
||||||
{
|
{
|
||||||
using (var fs = new FileStream(imageFile, FileMode.Create))
|
using (FileStream fs = new FileStream(imageFile, FileMode.Create))
|
||||||
ms.WriteTo(fs);
|
ms.WriteTo(fs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -61,6 +60,5 @@ namespace vCardEditor.Repository
|
|||||||
string[] filePaths = Directory.GetFiles(path, ext,SearchOption.TopDirectoryOnly);
|
string[] filePaths = Directory.GetFiles(path, ext,SearchOption.TopDirectoryOnly);
|
||||||
return filePaths;
|
return filePaths;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using vCardEditor.Repository;
|
using vCardEditor.Repository;
|
||||||
|
|
||||||
@@ -40,7 +35,7 @@ namespace vCardEditor.View
|
|||||||
return titleAttribute.Title;
|
return titleAttribute.Title;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return System.IO.Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase);
|
return Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,10 +104,10 @@ namespace vCardEditor.View
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (var client = new WebClient())
|
using (WebClient client = new WebClient())
|
||||||
{
|
{
|
||||||
string result = await client.DownloadStringTaskAsync(ConfigRepository.Instance.VersionUrl);
|
string result = await client.DownloadStringTaskAsync(ConfigRepository.Instance.VersionUrl);
|
||||||
using (var reader = new StringReader(result))
|
using (StringReader reader = new StringReader(result))
|
||||||
{
|
{
|
||||||
string InternetVersion = reader.ReadLine();
|
string InternetVersion = reader.ReadLine();
|
||||||
string AssemblyVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
string AssemblyVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
||||||
@@ -126,11 +121,11 @@ namespace vCardEditor.View
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (WebException )
|
catch (WebException)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Could not download version information from GitHub.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show("Could not download version information from GitHub.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
catch (Exception )
|
catch (Exception)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Error processing version information.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show("Error processing version information.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
using System;
|
using System.Windows.Forms;
|
||||||
using System.Windows.Forms;
|
|
||||||
using vCardEditor.Repository;
|
using vCardEditor.Repository;
|
||||||
using vCardEditor.Model;
|
|
||||||
|
|
||||||
namespace vCardEditor.View
|
namespace vCardEditor.View
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,9 +26,7 @@ namespace vCardEditor.View.Customs
|
|||||||
Addresses = addressCollection;
|
Addresses = addressCollection;
|
||||||
_checkBoxes = Controls.OfType<CheckBox>().ToList();
|
_checkBoxes = Controls.OfType<CheckBox>().ToList();
|
||||||
|
|
||||||
|
foreach (vCardDeliveryAddressTypes item in addressCollection)
|
||||||
|
|
||||||
foreach (var item in addressCollection)
|
|
||||||
{
|
{
|
||||||
switch (item.ToString())
|
switch (item.ToString())
|
||||||
{
|
{
|
||||||
@@ -53,9 +51,7 @@ namespace vCardEditor.View.Customs
|
|||||||
case "International":
|
case "International":
|
||||||
cbInternational.Checked = true;
|
cbInternational.Checked = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,13 +67,11 @@ namespace vCardEditor.View.Customs
|
|||||||
}
|
}
|
||||||
|
|
||||||
Addresses.Clear();
|
Addresses.Clear();
|
||||||
foreach (var item in checkedItems)
|
foreach (CheckBox item in checkedItems)
|
||||||
{
|
{
|
||||||
var enumType = (vCardDeliveryAddressTypes)Enum.Parse(typeof(vCardDeliveryAddressTypes), item.Text, true);
|
vCardDeliveryAddressTypes enumType = (vCardDeliveryAddressTypes)Enum.Parse(typeof(vCardDeliveryAddressTypes), item.Text, true);
|
||||||
Addresses.Add(enumType);
|
Addresses.Add(enumType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ namespace vCardEditor.View.Customs
|
|||||||
public partial class AddressBox : UserControl
|
public partial class AddressBox : UserControl
|
||||||
{
|
{
|
||||||
public event EventHandler TextChangedEvent;
|
public event EventHandler TextChangedEvent;
|
||||||
|
|
||||||
public List<vCardDeliveryAddressTypes> AddressType { get; set; }
|
public List<vCardDeliveryAddressTypes> AddressType { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public AddressBox(string street, string city, string region, string country, string postalCode,
|
public AddressBox(string street, string city, string region, string country, string postalCode,
|
||||||
string extendedAddress, string postOfficeBox, List<vCardDeliveryAddressTypes> addressType)
|
string extendedAddress, string postOfficeBox, List<vCardDeliveryAddressTypes> addressType)
|
||||||
@@ -46,7 +46,7 @@ namespace vCardEditor.View.Customs
|
|||||||
|
|
||||||
public vCardDeliveryAddress getDeliveryAddress()
|
public vCardDeliveryAddress getDeliveryAddress()
|
||||||
{
|
{
|
||||||
var deliveryAddress = new vCardDeliveryAddress
|
vCardDeliveryAddress deliveryAddress = new vCardDeliveryAddress
|
||||||
{
|
{
|
||||||
City = CityValue.Text,
|
City = CityValue.Text,
|
||||||
Country = CountryValue.Text,
|
Country = CountryValue.Text,
|
||||||
@@ -57,9 +57,7 @@ namespace vCardEditor.View.Customs
|
|||||||
PostOfficeBox = POBoxValue.Text,
|
PostOfficeBox = POBoxValue.Text,
|
||||||
AddressType = AddressType
|
AddressType = AddressType
|
||||||
};
|
};
|
||||||
|
|
||||||
return deliveryAddress;
|
return deliveryAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ namespace vCardEditor.View.Customs
|
|||||||
Selecting += tbcAddress_Selecting;
|
Selecting += tbcAddress_Selecting;
|
||||||
HandleCreated += tbcAddress_HandleCreated;
|
HandleCreated += tbcAddress_HandleCreated;
|
||||||
MouseDoubleClick += AddressTabControl_MouseDoubleClick;
|
MouseDoubleClick += AddressTabControl_MouseDoubleClick;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getDeliveryAddress(vCard card)
|
public void getDeliveryAddress(vCard card)
|
||||||
@@ -51,9 +50,9 @@ namespace vCardEditor.View.Customs
|
|||||||
{
|
{
|
||||||
if (GetTabRect(i).Contains(e.Location))
|
if (GetTabRect(i).Contains(e.Location))
|
||||||
{
|
{
|
||||||
var AddressBox = TabPages[i].Controls[0] as AddressBox;
|
AddressBox AddressBox = TabPages[i].Controls[0] as AddressBox;
|
||||||
|
|
||||||
var diag = new AddAddressDialog(AddressBox.AddressType);
|
AddAddressDialog diag = new AddAddressDialog(AddressBox.AddressType);
|
||||||
|
|
||||||
if (diag.ShowDialog() == DialogResult.OK)
|
if (diag.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
@@ -66,10 +65,8 @@ namespace vCardEditor.View.Customs
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[DllImport("user32.dll")]
|
[DllImport("user32.dll")]
|
||||||
private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wp, IntPtr lp);
|
private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wp, IntPtr lp);
|
||||||
private const int TCM_SETMINTABWIDTH = 0x1300 + 49;
|
private const int TCM_SETMINTABWIDTH = 0x1300 + 49;
|
||||||
@@ -78,20 +75,18 @@ namespace vCardEditor.View.Customs
|
|||||||
SendMessage(Handle, TCM_SETMINTABWIDTH, IntPtr.Zero, (IntPtr)16);
|
SendMessage(Handle, TCM_SETMINTABWIDTH, IntPtr.Zero, (IntPtr)16);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void tbcAddress_Selecting(object sender, TabControlCancelEventArgs e)
|
private void tbcAddress_Selecting(object sender, TabControlCancelEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.TabPageIndex == TabCount - 1)
|
if (e.TabPageIndex == TabCount - 1)
|
||||||
e.Cancel = true;
|
e.Cancel = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void tbcAddress_MouseDown(object sender, MouseEventArgs e)
|
private void tbcAddress_MouseDown(object sender, MouseEventArgs e)
|
||||||
{
|
{
|
||||||
var lastIndex = TabCount - 1;
|
int lastIndex = TabCount - 1;
|
||||||
if (GetTabRect(lastIndex).Contains(e.Location))
|
if (GetTabRect(lastIndex).Contains(e.Location))
|
||||||
{
|
{
|
||||||
var diag = new AddAddressDialog();
|
AddAddressDialog diag = new AddAddressDialog();
|
||||||
if (diag.ShowDialog() == DialogResult.OK)
|
if (diag.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
vCardDeliveryAddress da = new vCardDeliveryAddress();
|
vCardDeliveryAddress da = new vCardDeliveryAddress();
|
||||||
@@ -100,16 +95,15 @@ namespace vCardEditor.View.Customs
|
|||||||
AddTab?.Invoke(sender, new EventArg<List<vCardDeliveryAddressTypes>>(diag.Addresses));
|
AddTab?.Invoke(sender, new EventArg<List<vCardDeliveryAddressTypes>>(diag.Addresses));
|
||||||
SelectedIndex = TabCount - 2;
|
SelectedIndex = TabCount - 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (var i = 0; i < TabPages.Count; i++)
|
for (int i = 0; i < TabPages.Count; i++)
|
||||||
{
|
{
|
||||||
var tabRect = GetTabRect(i);
|
Rectangle tabRect = GetTabRect(i);
|
||||||
tabRect.Inflate(-2, -2);
|
tabRect.Inflate(-2, -2);
|
||||||
var closeImage = Properties.Resources.Close;
|
Bitmap closeImage = Properties.Resources.Close;
|
||||||
var imageRect = new Rectangle(
|
Rectangle imageRect = new Rectangle(
|
||||||
(tabRect.Right - closeImage.Width),
|
(tabRect.Right - closeImage.Width),
|
||||||
tabRect.Top + (tabRect.Height - closeImage.Height) / 2,
|
tabRect.Top + (tabRect.Height - closeImage.Height) / 2,
|
||||||
closeImage.Width, closeImage.Height);
|
closeImage.Width, closeImage.Height);
|
||||||
@@ -122,12 +116,9 @@ namespace vCardEditor.View.Customs
|
|||||||
SelectedIndex = 0;
|
SelectedIndex = 0;
|
||||||
RemoveTab?.Invoke(sender, new EventArg<int>(i));
|
RemoveTab?.Invoke(sender, new EventArg<int>(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,19 +127,19 @@ namespace vCardEditor.View.Customs
|
|||||||
if (e.Index > TabCount - 1)
|
if (e.Index > TabCount - 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var tabRect = GetTabRect(e.Index);
|
Rectangle tabRect = GetTabRect(e.Index);
|
||||||
tabRect.Inflate(-2, -2);
|
tabRect.Inflate(-2, -2);
|
||||||
|
|
||||||
if (e.Index == TabCount - 1)
|
if (e.Index == TabCount - 1)
|
||||||
{
|
{
|
||||||
var addImage = Properties.Resources.Add;
|
Bitmap addImage = Properties.Resources.Add;
|
||||||
e.Graphics.DrawImage(addImage,
|
e.Graphics.DrawImage(addImage,
|
||||||
tabRect.Left + (tabRect.Width - addImage.Width) / 2,
|
tabRect.Left + (tabRect.Width - addImage.Width) / 2,
|
||||||
tabRect.Top + (tabRect.Height - addImage.Height) / 2);
|
tabRect.Top + (tabRect.Height - addImage.Height) / 2);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var closeImage = Properties.Resources.Close;
|
Bitmap closeImage = Properties.Resources.Close;
|
||||||
e.Graphics.DrawImage(closeImage,
|
e.Graphics.DrawImage(closeImage,
|
||||||
(tabRect.Right - closeImage.Width),
|
(tabRect.Right - closeImage.Width),
|
||||||
tabRect.Top + (tabRect.Height - closeImage.Height) / 2);
|
tabRect.Top + (tabRect.Height - closeImage.Height) / 2);
|
||||||
@@ -172,8 +163,6 @@ namespace vCardEditor.View.Customs
|
|||||||
|
|
||||||
TextBrush.Dispose();
|
TextBrush.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetAddresses(vCard card)
|
public void SetAddresses(vCard card)
|
||||||
@@ -184,7 +173,7 @@ namespace vCardEditor.View.Customs
|
|||||||
|
|
||||||
private void AddTabForEveryAddress(vCard card)
|
private void AddTabForEveryAddress(vCard card)
|
||||||
{
|
{
|
||||||
foreach (var item in card.DeliveryAddresses)
|
foreach (vCardDeliveryAddress item in card.DeliveryAddresses)
|
||||||
AddtabForAddress(item);
|
AddtabForAddress(item);
|
||||||
SelectedIndex = 0;
|
SelectedIndex = 0;
|
||||||
}
|
}
|
||||||
@@ -193,36 +182,32 @@ namespace vCardEditor.View.Customs
|
|||||||
{
|
{
|
||||||
string title = GetTabTitle(da.AddressType);
|
string title = GetTabTitle(da.AddressType);
|
||||||
|
|
||||||
var page = new TabPage($" {title} ");
|
TabPage page = new TabPage($" {title} ");
|
||||||
TabPages.Insert(TabCount - 1, page);
|
TabPages.Insert(TabCount - 1, page);
|
||||||
|
|
||||||
var ab = new AddressBox(da.Street, da.City, da.Region, da.Country,
|
AddressBox ab = new AddressBox(da.Street, da.City, da.Region, da.Country,
|
||||||
da.PostalCode, da.ExtendedAddress, da.PostOfficeBox, da.AddressType);
|
da.PostalCode, da.ExtendedAddress, da.PostOfficeBox, da.AddressType);
|
||||||
|
|
||||||
ab.TextChangedEvent += (s, e) => TextChangedEvent?.Invoke(s, e);
|
ab.TextChangedEvent += (s, e) => TextChangedEvent?.Invoke(s, e);
|
||||||
ab.Dock = DockStyle.Fill;
|
ab.Dock = DockStyle.Fill;
|
||||||
page.Controls.Add(ab);
|
page.Controls.Add(ab);
|
||||||
page.ToolTipText = string.Join(",", da.AddressType.ConvertAll(f => f.ToString()));
|
page.ToolTipText = string.Join(",", da.AddressType.ConvertAll(f => f.ToString()));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetTabTitle(List<vCardDeliveryAddressTypes> addressTypes)
|
private string GetTabTitle(List<vCardDeliveryAddressTypes> addressTypes)
|
||||||
{
|
{
|
||||||
var title = string.Empty;
|
string title = string.Empty;
|
||||||
if (addressTypes.Count > 0)
|
if (addressTypes.Count > 0)
|
||||||
{
|
{
|
||||||
title = addressTypes[0].ToString();
|
title = addressTypes[0].ToString();
|
||||||
if (addressTypes.Count > 1)
|
if (addressTypes.Count > 1)
|
||||||
title += "...";
|
title += "...";
|
||||||
}
|
}
|
||||||
|
|
||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ClearTabs()
|
private void ClearTabs()
|
||||||
{
|
{
|
||||||
|
|
||||||
//Remove every tab (except "+"). We don't call Clear() as it doesn't free memory.
|
//Remove every tab (except "+"). We don't call Clear() as it doesn't free memory.
|
||||||
while (TabCount > 1)
|
while (TabCount > 1)
|
||||||
TabPages[0].Dispose();
|
TabPages[0].Dispose();
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ namespace vCardEditor.View.Customs
|
|||||||
_checkBoxes = Controls.OfType<CheckBox>().ToList();
|
_checkBoxes = Controls.OfType<CheckBox>().ToList();
|
||||||
Columns = columns;
|
Columns = columns;
|
||||||
|
|
||||||
foreach (var item in columns)
|
foreach (Column item in columns)
|
||||||
{
|
{
|
||||||
switch (item)
|
switch (item)
|
||||||
{
|
{
|
||||||
@@ -36,13 +36,9 @@ namespace vCardEditor.View.Customs
|
|||||||
private void btnOK_Click(object sender, EventArgs e)
|
private void btnOK_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Columns.Clear();
|
Columns.Clear();
|
||||||
|
foreach (CheckBox item in _checkBoxes.Where(checkBox => checkBox.Checked))
|
||||||
var total = _checkBoxes
|
|
||||||
.Where(checkBox => checkBox.Checked);
|
|
||||||
|
|
||||||
foreach (var item in total)
|
|
||||||
{
|
{
|
||||||
var enumType = (Column)Enum.Parse(typeof(Column), item.Text, true);
|
Column enumType = (Column)Enum.Parse(typeof(Column), item.Text, true);
|
||||||
Columns.Add(enumType);
|
Columns.Add(enumType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
namespace vCardEditor.View.Customs
|
namespace vCardEditor.View.Customs
|
||||||
{
|
{
|
||||||
partial class CustumInputDialog
|
partial class CustomInputDialog
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Required designer variable.
|
/// Required designer variable.
|
||||||
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
namespace vCardEditor.View.Customs
|
namespace vCardEditor.View.Customs
|
||||||
{
|
{
|
||||||
public partial class CustumInputDialog : Form
|
public partial class CustomInputDialog : Form
|
||||||
{
|
{
|
||||||
public CustumInputDialog()
|
public CustomInputDialog()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
@@ -15,7 +15,5 @@ namespace vCardEditor.View.Customs
|
|||||||
{
|
{
|
||||||
input = tbInput.Text;
|
input = tbInput.Text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,7 +6,6 @@ using Thought.vCards;
|
|||||||
|
|
||||||
namespace vCardEditor.View.Customs
|
namespace vCardEditor.View.Customs
|
||||||
{
|
{
|
||||||
|
|
||||||
public partial class ExtendedPanel : UserControl
|
public partial class ExtendedPanel : UserControl
|
||||||
{
|
{
|
||||||
public ExtendedPanel()
|
public ExtendedPanel()
|
||||||
@@ -35,8 +34,8 @@ namespace vCardEditor.View.Customs
|
|||||||
//{
|
//{
|
||||||
// AddControl(custom.input, string.Empty);
|
// AddControl(custom.input, string.Empty);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public event EventHandler ContentTextChanged;
|
public event EventHandler ContentTextChanged;
|
||||||
|
|
||||||
public string Caption
|
public string Caption
|
||||||
@@ -48,12 +47,11 @@ namespace vCardEditor.View.Customs
|
|||||||
public PanelType panelType { get; set; }
|
public PanelType panelType { get; set; }
|
||||||
private void MenuItemClickHandlers(object sender, EventArgs e)
|
private void MenuItemClickHandlers(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var tag = (sender as ToolStripMenuItem).Tag;
|
object tag = (sender as ToolStripMenuItem).Tag;
|
||||||
if (tag != null && tag is vCardRoot)
|
if (tag != null && tag is vCardRoot)
|
||||||
AddControl(tag as vCardRoot);
|
AddControl(tag as vCardRoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void btnAddExtraText_Click(object sender, EventArgs e)
|
private void btnAddExtraText_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Button btnSender = (Button)sender;
|
Button btnSender = (Button)sender;
|
||||||
@@ -71,35 +69,31 @@ namespace vCardEditor.View.Customs
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddControl(vCardRoot card)
|
public void AddControl(vCardRoot card)
|
||||||
{
|
{
|
||||||
Point pt = GetCoordinatesForNewControl();
|
Point pt = GetCoordinatesForNewControl();
|
||||||
|
|
||||||
RemovableTextBox ctl = new RemovableTextBox(card);
|
|
||||||
|
|
||||||
ctl.Anchor = AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Left;
|
|
||||||
ctl.Location = pt;
|
|
||||||
ctl.Width = PanelContent.Width - 20; //TODO : Calculte the right size of the scrollbar!
|
|
||||||
|
|
||||||
|
RemovableTextBox ctl = new RemovableTextBox(card)
|
||||||
|
{
|
||||||
|
Anchor = AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Left,
|
||||||
|
Location = pt,
|
||||||
|
Width = PanelContent.Width - 20 //TODO : Calculte the right size of the scrollbar!
|
||||||
|
};
|
||||||
|
|
||||||
ctl.BoutonRemoveClicked += RemoveControl;
|
ctl.ButtonRemoveClicked += RemoveControl;
|
||||||
ctl.ContentTextChanged += (s, e) => ContentTextChanged?.Invoke(s, e);
|
ctl.ContentTextChanged += (s, e) => ContentTextChanged?.Invoke(s, e);
|
||||||
PanelContent.Controls.Add(ctl);
|
PanelContent.Controls.Add(ctl);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<vCardRoot> GetExtraFields()
|
public List<vCardRoot> GetExtraFields()
|
||||||
{
|
{
|
||||||
List<vCardRoot> result = new List<vCardRoot>();
|
List<vCardRoot> result = new List<vCardRoot>();
|
||||||
|
|
||||||
foreach (var item in PanelContent.Controls)
|
foreach (Control item in PanelContent.Controls)
|
||||||
{
|
{
|
||||||
var ctl = item as RemovableTextBox;
|
result.Add((item as RemovableTextBox).Tag as vCardRoot);
|
||||||
result.Add(ctl.Tag as vCardRoot);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -126,20 +120,16 @@ namespace vCardEditor.View.Customs
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < PanelContent.Controls.Count; i++)
|
for (int i = 0; i < PanelContent.Controls.Count; i++)
|
||||||
{
|
{
|
||||||
var ctl = PanelContent.Controls[i];
|
PanelContent.Controls[i].Location = new Point(5, (i * 30) + 10);
|
||||||
ctl.Location = new Point(5, (i * 30) + 10);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private Point GetCoordinatesForNewControl()
|
private Point GetCoordinatesForNewControl()
|
||||||
{
|
{
|
||||||
Point pt;
|
Point pt;
|
||||||
if (PanelContent.Controls.Count > 0)
|
if (PanelContent.Controls.Count > 0)
|
||||||
{
|
{
|
||||||
var LastControl = PanelContent.Controls[PanelContent.Controls.Count - 1];
|
Control LastControl = PanelContent.Controls[PanelContent.Controls.Count - 1];
|
||||||
pt = LastControl.Location;
|
pt = LastControl.Location;
|
||||||
pt.Y += 30;
|
pt.Y += 30;
|
||||||
}
|
}
|
||||||
@@ -148,8 +138,5 @@ namespace vCardEditor.View.Customs
|
|||||||
|
|
||||||
return pt;
|
return pt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,12 +6,13 @@ namespace vCardEditor.View.Customs
|
|||||||
{
|
{
|
||||||
public partial class RemovableTextBox : UserControl
|
public partial class RemovableTextBox : UserControl
|
||||||
{
|
{
|
||||||
public event EventHandler BoutonRemoveClicked;
|
public event EventHandler ButtonRemoveClicked;
|
||||||
public event EventHandler ContentTextChanged;
|
public event EventHandler ContentTextChanged;
|
||||||
|
|
||||||
public RemovableTextBox()
|
public RemovableTextBox()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
btnRemove.Click += (s, e) => BoutonRemoveClicked?.Invoke(s, e);
|
btnRemove.Click += (s, e) => ButtonRemoveClicked?.Invoke(s, e);
|
||||||
// Bubble up to set the dirty flag from the parent.
|
// Bubble up to set the dirty flag from the parent.
|
||||||
ContentTextBox.LostFocus += (s, e) => ContentTextChanged?.Invoke(s, e);
|
ContentTextBox.LostFocus += (s, e) => ContentTextChanged?.Invoke(s, e);
|
||||||
ContentTextBox.Validated += (s, e) => ContentTextChanged?.Invoke(s, e);
|
ContentTextBox.Validated += (s, e) => ContentTextChanged?.Invoke(s, e);
|
||||||
@@ -22,7 +23,7 @@ namespace vCardEditor.View.Customs
|
|||||||
|
|
||||||
private void ContentTextBox_Validated(object sender, EventArgs e)
|
private void ContentTextBox_Validated(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var card = this.Tag as vCardRoot;
|
vCardRoot card = this.Tag as vCardRoot;
|
||||||
card.ChangeContent(Content);
|
card.ChangeContent(Content);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,7 +34,6 @@ namespace vCardEditor.View.Customs
|
|||||||
Content = cardType.ToString();
|
Content = cardType.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public string Title
|
public string Title
|
||||||
{
|
{
|
||||||
get { return TitleLabel.Text; }
|
get { return TitleLabel.Text; }
|
||||||
@@ -45,6 +45,5 @@ namespace vCardEditor.View.Customs
|
|||||||
get { return ContentTextBox.Text; }
|
get { return ContentTextBox.Text; }
|
||||||
set { ContentTextBox.Text = value; }
|
set { ContentTextBox.Text = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using VCFEditor.View;
|
|
||||||
using VCFEditor.Model;
|
|
||||||
using Thought.vCards;
|
using Thought.vCards;
|
||||||
using vCardEditor.Repository;
|
|
||||||
using vCardEditor.Model;
|
using vCardEditor.Model;
|
||||||
using System.Drawing;
|
using vCardEditor.Repository;
|
||||||
using System.Collections.Generic;
|
|
||||||
using vCardEditor.View.Customs;
|
using vCardEditor.View.Customs;
|
||||||
using vCardEditor.View.UIToolbox;
|
using vCardEditor.View.UIToolbox;
|
||||||
|
using VCFEditor.Model;
|
||||||
|
using VCFEditor.View;
|
||||||
|
|
||||||
namespace vCardEditor.View
|
namespace vCardEditor.View
|
||||||
{
|
{
|
||||||
@@ -39,9 +39,6 @@ namespace vCardEditor.View
|
|||||||
public event EventHandler BatchExportImagesEvent;
|
public event EventHandler BatchExportImagesEvent;
|
||||||
public event EventHandler<EventArg<string>> OpenFolderEvent;
|
public event EventHandler<EventArg<string>> OpenFolderEvent;
|
||||||
public event EventHandler SplitFileEvent;
|
public event EventHandler SplitFileEvent;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ComponentResourceManager resources;
|
ComponentResourceManager resources;
|
||||||
|
|
||||||
@@ -56,13 +53,10 @@ namespace vCardEditor.View
|
|||||||
else
|
else
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public MainForm()
|
public MainForm()
|
||||||
{
|
{
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
resources = new ComponentResourceManager(typeof(MainForm));
|
resources = new ComponentResourceManager(typeof(MainForm));
|
||||||
@@ -74,7 +68,6 @@ namespace vCardEditor.View
|
|||||||
extendedPanelPhones.ContentTextChanged += (sender, e) => TextBoxValueChanged?.Invoke(sender, e);
|
extendedPanelPhones.ContentTextChanged += (sender, e) => TextBoxValueChanged?.Invoke(sender, e);
|
||||||
extendedPanelWeb.ContentTextChanged += (sender, e) => TextBoxValueChanged?.Invoke(sender, e);
|
extendedPanelWeb.ContentTextChanged += (sender, e) => TextBoxValueChanged?.Invoke(sender, e);
|
||||||
BuildMRUMenu();
|
BuildMRUMenu();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tbsOpen_Click(object sender, EventArgs e)
|
private void tbsOpen_Click(object sender, EventArgs e)
|
||||||
@@ -82,7 +75,6 @@ namespace vCardEditor.View
|
|||||||
OpenFile(sender, string.Empty);
|
OpenFile(sender, string.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void OpenFile(object sender, string filename)
|
private void OpenFile(object sender, string filename)
|
||||||
{
|
{
|
||||||
var evt = new EventArg<string>(filename);
|
var evt = new EventArg<string>(filename);
|
||||||
@@ -98,7 +90,6 @@ namespace vCardEditor.View
|
|||||||
bsContacts.DataSource = null;
|
bsContacts.DataSource = null;
|
||||||
if (contacts != null)
|
if (contacts != null)
|
||||||
bsContacts.DataSource = contacts;
|
bsContacts.DataSource = contacts;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tbsSave_Click(object sender, EventArgs e)
|
private void tbsSave_Click(object sender, EventArgs e)
|
||||||
@@ -116,7 +107,6 @@ namespace vCardEditor.View
|
|||||||
|
|
||||||
SaveContactsSelected(sender, e);
|
SaveContactsSelected(sender, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tbsNew_Click(object sender, EventArgs e)
|
private void tbsNew_Click(object sender, EventArgs e)
|
||||||
@@ -129,7 +119,6 @@ namespace vCardEditor.View
|
|||||||
if (dgContacts.CurrentCell == null)
|
if (dgContacts.CurrentCell == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
//Weired, the selection is fired multiple times...
|
//Weired, the selection is fired multiple times...
|
||||||
int RowIndex = dgContacts.CurrentCell.RowIndex;
|
int RowIndex = dgContacts.CurrentCell.RowIndex;
|
||||||
if (LastRowIndex != RowIndex)
|
if (LastRowIndex != RowIndex)
|
||||||
@@ -154,7 +143,6 @@ namespace vCardEditor.View
|
|||||||
|
|
||||||
public void DisplayContactDetail(vCard card, string FileName)
|
public void DisplayContactDetail(vCard card, string FileName)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (card == null)
|
if (card == null)
|
||||||
throw new ArgumentException("vCard must be valid!");
|
throw new ArgumentException("vCard must be valid!");
|
||||||
|
|
||||||
@@ -176,34 +164,29 @@ namespace vCardEditor.View
|
|||||||
|
|
||||||
SetExtraInfos(card);
|
SetExtraInfos(card);
|
||||||
SetExtraTabFields(card);
|
SetExtraTabFields(card);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetExtraInfos(vCard card)
|
private void SetExtraInfos(vCard card)
|
||||||
{
|
{
|
||||||
foreach (var item in card.EmailAddresses)
|
foreach (vCardEmailAddress item in card.EmailAddresses)
|
||||||
extendedPanelWeb.AddControl(item);
|
extendedPanelWeb.AddControl(item);
|
||||||
|
|
||||||
foreach (var item in card.Websites)
|
foreach (vCardWebsite item in card.Websites)
|
||||||
extendedPanelWeb.AddControl(item);
|
extendedPanelWeb.AddControl(item);
|
||||||
|
|
||||||
foreach (var item in card.Phones)
|
foreach (vCardPhone item in card.Phones)
|
||||||
extendedPanelPhones.AddControl(item);
|
extendedPanelPhones.AddControl(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void SetExtraTabFields(vCard card)
|
private void SetExtraTabFields(vCard card)
|
||||||
{
|
{
|
||||||
foreach (var note in card.Notes)
|
foreach (vCardNote note in card.Notes)
|
||||||
AddExtraTextGroup(vCardPropeties.NOTE, note.Text);
|
AddExtraTextGroup(vCardPropeties.NOTE, note.Text);
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(card.Organization))
|
if (!string.IsNullOrEmpty(card.Organization))
|
||||||
{
|
{
|
||||||
AddExtraTextGroup(vCardPropeties.ORG, card.Organization);
|
AddExtraTextGroup(vCardPropeties.ORG, card.Organization);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddExtraTextGroup(vCardPropeties type, string content)
|
public void AddExtraTextGroup(vCardPropeties type, string content)
|
||||||
@@ -215,12 +198,11 @@ namespace vCardEditor.View
|
|||||||
etg.TextChangedEvent += (sender, e) => TextBoxValueChanged?.Invoke(sender, e);
|
etg.TextChangedEvent += (sender, e) => TextBoxValueChanged?.Invoke(sender, e);
|
||||||
etg.ControlDeleted += (sender, e) =>
|
etg.ControlDeleted += (sender, e) =>
|
||||||
{
|
{
|
||||||
var send = sender as Control;
|
Control send = sender as Control;
|
||||||
panelTabExtra.Controls.Remove(send.Parent);
|
panelTabExtra.Controls.Remove(send.Parent);
|
||||||
};
|
};
|
||||||
etg.Dock = DockStyle.Top;
|
etg.Dock = DockStyle.Top;
|
||||||
|
|
||||||
|
|
||||||
panelTabExtra.Controls.Add(etg);
|
panelTabExtra.Controls.Add(etg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,7 +237,7 @@ namespace vCardEditor.View
|
|||||||
{
|
{
|
||||||
if (photos.Any())
|
if (photos.Any())
|
||||||
{
|
{
|
||||||
var photo = photos[0];
|
vCardPhoto photo = photos[0];
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Get the bytes of the photo if it has not already been loaded.
|
// Get the bytes of the photo if it has not already been loaded.
|
||||||
@@ -272,8 +254,8 @@ namespace vCardEditor.View
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
PhotoBox.Image = (Image)resources.GetObject("PhotoBox.Image");
|
PhotoBox.Image = (Image)resources.GetObject("PhotoBox.Image");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetAddressesValues(vCard card)
|
private void SetAddressesValues(vCard card)
|
||||||
{
|
{
|
||||||
tbcAddress.SetAddresses(card);
|
tbcAddress.SetAddresses(card);
|
||||||
@@ -306,19 +288,15 @@ namespace vCardEditor.View
|
|||||||
textBoxFilter.Focus();
|
textBoxFilter.Focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private vCard GetvCardFromWindow()
|
private vCard GetvCardFromWindow()
|
||||||
{
|
{
|
||||||
vCard card = new vCard
|
vCard card = new vCard
|
||||||
{
|
{
|
||||||
|
|
||||||
Title = FormattedTitleValue.Text,
|
Title = FormattedTitleValue.Text,
|
||||||
FormattedName = FormattedNameValue.Text,
|
FormattedName = FormattedNameValue.Text,
|
||||||
GivenName = firstNameValue.Text,
|
GivenName = firstNameValue.Text,
|
||||||
AdditionalNames = middleNameValue.Text,
|
AdditionalNames = middleNameValue.Text,
|
||||||
FamilyName = lastNameValue.Text,
|
FamilyName = lastNameValue.Text,
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
tbcAddress.getDeliveryAddress(card);
|
tbcAddress.getDeliveryAddress(card);
|
||||||
@@ -331,7 +309,7 @@ namespace vCardEditor.View
|
|||||||
private void getExtraPhones(vCard card)
|
private void getExtraPhones(vCard card)
|
||||||
{
|
{
|
||||||
card.Phones.Clear();
|
card.Phones.Clear();
|
||||||
foreach (var item in extendedPanelPhones.GetExtraFields())
|
foreach (vCardRoot item in extendedPanelPhones.GetExtraFields())
|
||||||
{
|
{
|
||||||
if (item is vCardPhone)
|
if (item is vCardPhone)
|
||||||
{
|
{
|
||||||
@@ -339,40 +317,34 @@ namespace vCardEditor.View
|
|||||||
card.Phones.Add(phone);
|
card.Phones.Add(phone);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getExtraWeb(vCard card)
|
private void getExtraWeb(vCard card)
|
||||||
{
|
{
|
||||||
card.Websites.Clear();
|
card.Websites.Clear();
|
||||||
card.EmailAddresses.Clear();
|
card.EmailAddresses.Clear();
|
||||||
|
|
||||||
foreach (var item in extendedPanelWeb.GetExtraFields())
|
foreach (vCardRoot item in extendedPanelWeb.GetExtraFields())
|
||||||
{
|
{
|
||||||
switch (item)
|
switch (item)
|
||||||
{
|
{
|
||||||
case vCardEmailAddress email:
|
case vCardEmailAddress email:
|
||||||
card.EmailAddresses.Add(email);
|
card.EmailAddresses.Add(email);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case vCardWebsite website:
|
case vCardWebsite website:
|
||||||
card.Websites.Add(website);
|
card.Websites.Add(website);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void getExtraData(vCard card)
|
private void getExtraData(vCard card)
|
||||||
{
|
{
|
||||||
foreach (var item in panelTabExtra.Controls)
|
foreach (object item in panelTabExtra.Controls)
|
||||||
{
|
{
|
||||||
var tbc = item as ExtraTextGroup;
|
ExtraTextGroup tbc = item as ExtraTextGroup;
|
||||||
switch (tbc.CardProp)
|
switch (tbc.CardProp)
|
||||||
{
|
{
|
||||||
case vCardPropeties.NOTE:
|
case vCardPropeties.NOTE:
|
||||||
@@ -398,12 +370,12 @@ namespace vCardEditor.View
|
|||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void MainForm_DragEnter(object sender, DragEventArgs e)
|
private void MainForm_DragEnter(object sender, DragEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.Data.GetDataPresent(DataFormats.FileDrop))
|
if (e.Data.GetDataPresent(DataFormats.FileDrop))
|
||||||
e.Effect = DragDropEffects.Copy;
|
e.Effect = DragDropEffects.Copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MainForm_DragDrop(object sender, DragEventArgs e)
|
private void MainForm_DragDrop(object sender, DragEventArgs e)
|
||||||
{
|
{
|
||||||
string[] FileList = (string[])e.Data.GetData(DataFormats.FileDrop, false);
|
string[] FileList = (string[])e.Data.GetData(DataFormats.FileDrop, false);
|
||||||
@@ -416,14 +388,11 @@ namespace vCardEditor.View
|
|||||||
OpenFile(sender, FileList[0]);
|
OpenFile(sender, FileList[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void BuildMRUMenu()
|
private void BuildMRUMenu()
|
||||||
{
|
{
|
||||||
//TODO: Open File or Folder.
|
//TODO: Open File or Folder.
|
||||||
recentFilesMenuItem.DropDownItemClicked += (s, e) => OpenFile(s, e.ClickedItem.Text);
|
recentFilesMenuItem.DropDownItemClicked += (s, e) => OpenFile(s, e.ClickedItem.Text);
|
||||||
UpdateMRUMenu(ConfigRepository.Instance.Paths);
|
UpdateMRUMenu(ConfigRepository.Instance.Paths);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateMRUMenu(FixedList MostRecentFilesList)
|
public void UpdateMRUMenu(FixedList MostRecentFilesList)
|
||||||
@@ -434,7 +403,6 @@ namespace vCardEditor.View
|
|||||||
recentFilesMenuItem.DropDownItems.Clear();
|
recentFilesMenuItem.DropDownItems.Clear();
|
||||||
for (int i = 0; i < MostRecentFilesList._innerList.Count; i++)
|
for (int i = 0; i < MostRecentFilesList._innerList.Count; i++)
|
||||||
recentFilesMenuItem.DropDownItems.Add(MostRecentFilesList[i]);
|
recentFilesMenuItem.DropDownItems.Add(MostRecentFilesList[i]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
|
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
|
||||||
@@ -443,7 +411,6 @@ namespace vCardEditor.View
|
|||||||
CloseForm?.Invoke(sender, evt);
|
CloseForm?.Invoke(sender, evt);
|
||||||
|
|
||||||
e.Cancel = evt.Data;
|
e.Cancel = evt.Data;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool AskMessage(string msg, string caption)
|
public bool AskMessage(string msg, string caption)
|
||||||
@@ -467,6 +434,7 @@ namespace vCardEditor.View
|
|||||||
{
|
{
|
||||||
MessageBox.Show(msg, caption);
|
MessageBox.Show(msg, caption);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string DisplayOpenFileDialog(string filter = "")
|
public string DisplayOpenFileDialog(string filter = "")
|
||||||
{
|
{
|
||||||
string filename = string.Empty;
|
string filename = string.Empty;
|
||||||
@@ -481,8 +449,7 @@ namespace vCardEditor.View
|
|||||||
|
|
||||||
public string DisplaySaveDialog(string filename)
|
public string DisplaySaveDialog(string filename)
|
||||||
{
|
{
|
||||||
|
SaveFileDialog saveFileDialog = new SaveFileDialog
|
||||||
var saveFileDialog = new SaveFileDialog
|
|
||||||
{
|
{
|
||||||
FileName = filename
|
FileName = filename
|
||||||
};
|
};
|
||||||
@@ -493,11 +460,12 @@ namespace vCardEditor.View
|
|||||||
|
|
||||||
return filename;
|
return filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PhotoBox_Click(object sender, EventArgs e)
|
private void PhotoBox_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (ModifyImage != null)
|
if (ModifyImage != null)
|
||||||
{
|
{
|
||||||
var fileName = DisplayOpenFileDialog();
|
string fileName = DisplayOpenFileDialog();
|
||||||
if (!string.IsNullOrEmpty(fileName))
|
if (!string.IsNullOrEmpty(fileName))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -510,11 +478,8 @@ namespace vCardEditor.View
|
|||||||
{
|
{
|
||||||
MessageBox.Show($"Invalid file! : {fileName}");
|
MessageBox.Show($"Invalid file! : {fileName}");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ClearImageFromForm()
|
public void ClearImageFromForm()
|
||||||
@@ -544,26 +509,23 @@ namespace vCardEditor.View
|
|||||||
Clipboard.SetText(text);
|
Clipboard.SetText(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void dgContacts_CellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs e)
|
private void dgContacts_CellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.RowIndex == -1)
|
if (e.RowIndex == -1)
|
||||||
{
|
{
|
||||||
e.ContextMenuStrip = contextMenuStrip1;
|
e.ContextMenuStrip = contextMenuStrip1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void modifiyColumnsToolStripMenuItem_Click(object sender, EventArgs e)
|
private void modifiyColumnsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
List<Column> Columns = GetListColumnsForDataGrid();
|
List<Column> Columns = GetListColumnsForDataGrid();
|
||||||
|
|
||||||
var dialog = new ColumnsDialog(Columns);
|
ColumnsDialog dialog = new ColumnsDialog(Columns);
|
||||||
if (dialog.ShowDialog() == DialogResult.OK)
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
ToggleAllColumnsToInvisible();
|
ToggleAllColumnsToInvisible();
|
||||||
ToggleOnlySelected(dialog.Columns);
|
ToggleOnlySelected(dialog.Columns);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -574,19 +536,17 @@ namespace vCardEditor.View
|
|||||||
{
|
{
|
||||||
if (dgContacts.Columns[i].Visible)
|
if (dgContacts.Columns[i].Visible)
|
||||||
{
|
{
|
||||||
var name = dgContacts.Columns[i].Name;
|
string name = dgContacts.Columns[i].Name;
|
||||||
var enumType = (Column)Enum.Parse(typeof(Column), name, true);
|
Column enumType = (Column)Enum.Parse(typeof(Column), name, true);
|
||||||
Columns.Add(enumType);
|
Columns.Add(enumType);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Columns;
|
return Columns;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ToggleOnlySelected(List<Column> columns)
|
private void ToggleOnlySelected(List<Column> columns)
|
||||||
{
|
{
|
||||||
foreach (var item in columns)
|
foreach (Column item in columns)
|
||||||
{
|
{
|
||||||
switch (item)
|
switch (item)
|
||||||
{
|
{
|
||||||
@@ -610,7 +570,6 @@ namespace vCardEditor.View
|
|||||||
|
|
||||||
public FormState GetFormState()
|
public FormState GetFormState()
|
||||||
{
|
{
|
||||||
|
|
||||||
return new FormState
|
return new FormState
|
||||||
{
|
{
|
||||||
Columns = GetListColumnsForDataGrid(),
|
Columns = GetListColumnsForDataGrid(),
|
||||||
@@ -626,7 +585,6 @@ namespace vCardEditor.View
|
|||||||
{
|
{
|
||||||
var evt = new EventArg<FormState>(new FormState());
|
var evt = new EventArg<FormState>(new FormState());
|
||||||
LoadForm?.Invoke(sender, evt);
|
LoadForm?.Invoke(sender, evt);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadIntialState(FormState state)
|
public void LoadIntialState(FormState state)
|
||||||
@@ -642,6 +600,7 @@ namespace vCardEditor.View
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tbsQR_Click(object sender, EventArgs e)
|
private void tbsQR_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
ExportQR?.Invoke(sender, e);
|
ExportQR?.Invoke(sender, e);
|
||||||
@@ -653,7 +612,6 @@ namespace vCardEditor.View
|
|||||||
qr.ShowDialog();
|
qr.ShowDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void addNotesToolStripMenuItem_Click(object sender, EventArgs e)
|
private void addNotesToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var evt = new EventArg<vCardPropeties>(vCardPropeties.NOTE);
|
var evt = new EventArg<vCardPropeties>(vCardPropeties.NOTE);
|
||||||
@@ -674,7 +632,6 @@ namespace vCardEditor.View
|
|||||||
menuExtraField.Show(ptLowerLeft);
|
menuExtraField.Show(ptLowerLeft);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void miNote_Click(object sender, EventArgs e)
|
private void miNote_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var evt = new EventArg<vCardPropeties>(vCardPropeties.NOTE);
|
var evt = new EventArg<vCardPropeties>(vCardPropeties.NOTE);
|
||||||
|
|||||||
@@ -29,8 +29,6 @@ namespace vCardEditor.View
|
|||||||
pictureBoxQRCode.BackgroundImage = qrCode.GetGraphic(20, Color.Black, Color.White, null, 1);
|
pictureBoxQRCode.BackgroundImage = qrCode.GetGraphic(20, Color.Black, Color.White, null, 1);
|
||||||
pictureBoxQRCode.Size = new Size(pictureBoxQRCode.Width, pictureBoxQRCode.Height);
|
pictureBoxQRCode.Size = new Size(pictureBoxQRCode.Width, pictureBoxQRCode.Height);
|
||||||
pictureBoxQRCode.SizeMode = PictureBoxSizeMode.StretchImage;
|
pictureBoxQRCode.SizeMode = PictureBoxSizeMode.StretchImage;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,30 +59,27 @@ namespace vCardEditor.View
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
using (FileStream fs = (System.IO.FileStream)saveFileDialog1.OpenFile())
|
using (FileStream fs = (FileStream)saveFileDialog1.OpenFile())
|
||||||
{
|
{
|
||||||
|
ImageFormat imageFormat = null;
|
||||||
|
switch (saveFileDialog1.FilterIndex)
|
||||||
ImageFormat imageFormat = null;
|
{
|
||||||
switch (saveFileDialog1.FilterIndex)
|
case 1:
|
||||||
{
|
imageFormat = ImageFormat.Bmp;
|
||||||
case 1:
|
break;
|
||||||
imageFormat = ImageFormat.Bmp;
|
case 2:
|
||||||
break;
|
imageFormat = ImageFormat.Png;
|
||||||
case 2:
|
break;
|
||||||
imageFormat = ImageFormat.Png;
|
case 3:
|
||||||
break;
|
imageFormat = ImageFormat.Jpeg;
|
||||||
case 3:
|
break;
|
||||||
imageFormat = ImageFormat.Jpeg;
|
case 4:
|
||||||
break;
|
imageFormat = ImageFormat.Gif;
|
||||||
case 4:
|
break;
|
||||||
imageFormat = ImageFormat.Gif;
|
default:
|
||||||
break;
|
throw new NotSupportedException("File extension is not supported");
|
||||||
default:
|
}
|
||||||
throw new NotSupportedException("File extension is not supported");
|
pictureBoxQRCode.BackgroundImage.Save(fs, imageFormat);
|
||||||
}
|
|
||||||
pictureBoxQRCode.BackgroundImage.Save(fs, imageFormat);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ namespace vCardEditor.View
|
|||||||
|
|
||||||
// Remember the current setting for RaiseListChangedEvents
|
// Remember the current setting for RaiseListChangedEvents
|
||||||
// (if it was already deactivated, we shouldn't activate it after adding!).
|
// (if it was already deactivated, we shouldn't activate it after adding!).
|
||||||
var oldRaiseEventsValue = RaiseListChangedEvents;
|
bool oldRaiseEventsValue = RaiseListChangedEvents;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -122,9 +122,6 @@ namespace vCardEditor.View
|
|||||||
if (RaiseListChangedEvents)
|
if (RaiseListChangedEvents)
|
||||||
ResetBindings();
|
ResetBindings();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -176,11 +176,11 @@
|
|||||||
<Compile Include="View\Customs\ColumnsDialog.Designer.cs">
|
<Compile Include="View\Customs\ColumnsDialog.Designer.cs">
|
||||||
<DependentUpon>ColumnsDialog.cs</DependentUpon>
|
<DependentUpon>ColumnsDialog.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="View\Customs\CustumInputDialog.cs">
|
<Compile Include="View\Customs\CustomInputDialog.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="View\Customs\CustumInputDialog.Designer.cs">
|
<Compile Include="View\Customs\CustomInputDialog.Designer.cs">
|
||||||
<DependentUpon>CustumInputDialog.cs</DependentUpon>
|
<DependentUpon>CustomInputDialog.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="View\Customs\ExtendedPanel.cs">
|
<Compile Include="View\Customs\ExtendedPanel.cs">
|
||||||
<SubType>UserControl</SubType>
|
<SubType>UserControl</SubType>
|
||||||
@@ -244,8 +244,8 @@
|
|||||||
<EmbeddedResource Include="View\Customs\ColumnsDialog.resx">
|
<EmbeddedResource Include="View\Customs\ColumnsDialog.resx">
|
||||||
<DependentUpon>ColumnsDialog.cs</DependentUpon>
|
<DependentUpon>ColumnsDialog.cs</DependentUpon>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
<EmbeddedResource Include="View\Customs\CustumInputDialog.resx">
|
<EmbeddedResource Include="View\Customs\CustomInputDialog.resx">
|
||||||
<DependentUpon>CustumInputDialog.cs</DependentUpon>
|
<DependentUpon>CustomInputDialog.cs</DependentUpon>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
<EmbeddedResource Include="View\Customs\ExtendedPanel.resx">
|
<EmbeddedResource Include="View\Customs\ExtendedPanel.resx">
|
||||||
<DependentUpon>ExtendedPanel.cs</DependentUpon>
|
<DependentUpon>ExtendedPanel.cs</DependentUpon>
|
||||||
|
|||||||
Reference in New Issue
Block a user