mirror of
https://github.com/abdelkader/vCardEditor
synced 2025-12-12 08:27:19 +07:00
Compare commits
31 Commits
v0.5.5
...
66a77f3b98
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
66a77f3b98 | ||
| 5f33b3adaf | |||
|
|
90dce429bd | ||
|
|
b17fce8dde | ||
|
|
afe52e2b18 | ||
|
|
c89d9a197c | ||
|
|
6b57814c5b | ||
|
|
2023043889 | ||
|
|
4401f13fb4 | ||
|
|
c9b9dfb623 | ||
|
|
d79ea44306 | ||
|
|
724113e304 | ||
|
|
32bf064f93 | ||
|
|
250279cf7c | ||
|
|
62744daa8a | ||
|
|
4dad2c4151 | ||
|
|
e89b85411f | ||
|
|
81ce797614 | ||
|
|
2eb633cfd7 | ||
|
|
7a575bf526 | ||
|
|
ad990213be | ||
|
|
d1296f66b7 | ||
|
|
6b133c27f5 | ||
|
|
ce69d72d46 | ||
|
|
b2edc48f66 | ||
|
|
ae3961ec33 | ||
|
|
bad8fee66b | ||
|
|
4ab38ffea7 | ||
|
|
2faa7965cd | ||
|
|
3d558b0216 | ||
|
|
ad28a57df8 |
@@ -1906,13 +1906,12 @@ namespace Thought.vCards
|
||||
/// </summary>
|
||||
private void ReadInto_PHOTO(vCard card, vCardProperty property)
|
||||
{
|
||||
string[] Formats = { "GIF", "CGM", "WMF", "JPEG", "BMP", "MET", "PMB", "DIB", "PICT", "TIFF", "PS", "PDF" };
|
||||
string imageType = property.Subproperties.GetValue("TYPE", Formats);
|
||||
|
||||
string imageType = property.Subproperties.GetValue("TYPE");
|
||||
|
||||
// The PHOTO property contains an embedded (encoded) image
|
||||
// or a link to an image. A URL (linked) image is supposed
|
||||
// to be indicated with the VALUE=URI subproperty.
|
||||
|
||||
string valueType = property.Subproperties.GetValue("VALUE");
|
||||
|
||||
//URI is the standard, but I've seen examples online of URL
|
||||
@@ -2290,10 +2289,7 @@ namespace Thought.vCards
|
||||
|
||||
firstLine = firstLine.Trim();
|
||||
if (firstLine.Length == 0)
|
||||
{
|
||||
Warnings.Add(Thought.vCards.WarningMessages.BlankLine);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get the index of the colon (:) in this
|
||||
// property line. All vCard properties are
|
||||
@@ -2301,10 +2297,7 @@ namespace Thought.vCards
|
||||
|
||||
int colonIndex = firstLine.IndexOf(':');
|
||||
if (colonIndex == -1)
|
||||
{
|
||||
Warnings.Add(Thought.vCards.WarningMessages.ColonMissing);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get the name portion of the property. This
|
||||
// portion contains the property name as well
|
||||
@@ -2312,10 +2305,7 @@ namespace Thought.vCards
|
||||
|
||||
string namePart = firstLine.Substring(0, colonIndex).Trim();
|
||||
if (string.IsNullOrEmpty(namePart))
|
||||
{
|
||||
Warnings.Add(Thought.vCards.WarningMessages.EmptyName);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Split apart the name portion of the property.
|
||||
// A property can have subproperties, separated
|
||||
@@ -2323,17 +2313,14 @@ namespace Thought.vCards
|
||||
|
||||
string[] nameParts = namePart.Split(';');
|
||||
for (int i = 0; i < nameParts.Length; i++)
|
||||
nameParts[i] = nameParts[i].Trim();
|
||||
nameParts[i] = nameParts[i].Trim();
|
||||
|
||||
// The name of the property is supposed to
|
||||
// be first on the line. An empty name is not
|
||||
// legal syntax.
|
||||
|
||||
if (nameParts[0].Length == 0)
|
||||
{
|
||||
Warnings.Add(Thought.vCards.WarningMessages.EmptyName);
|
||||
continue;
|
||||
}
|
||||
|
||||
// At this point there is sufficient text
|
||||
// to define a vCard property. The only
|
||||
@@ -2362,13 +2349,14 @@ namespace Thought.vCards
|
||||
if (subNameValue.Length == 1)
|
||||
{
|
||||
|
||||
// The Split function above returned a single
|
||||
// array element. This means no equal (=) sign
|
||||
// was present. The subproperty consists of
|
||||
// a name only.
|
||||
|
||||
property.Subproperties.Add(
|
||||
nameParts[index].Trim());
|
||||
// The Split function above returned a single
|
||||
// array element. This means no equal (=) sign
|
||||
// was present. The subproperty consists of
|
||||
// a name only.
|
||||
if (!string.IsNullOrEmpty(subNameValue[0]))
|
||||
{
|
||||
property.Subproperties.Add(nameParts[index].Trim());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -44,6 +44,9 @@ namespace VCFEditor.Model
|
||||
|
||||
[Browsable(false)]
|
||||
public bool isDeleted { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
public string path { get; set; }
|
||||
|
||||
|
||||
public Contact()
|
||||
@@ -53,6 +56,18 @@ namespace VCFEditor.Model
|
||||
isDirty = false;
|
||||
}
|
||||
|
||||
public Contact(vCard card)
|
||||
{
|
||||
this.card = card;
|
||||
isSelected = false;
|
||||
isDirty = false;
|
||||
}
|
||||
|
||||
public Contact(string path) : this()
|
||||
{
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
private void NotifyPropertyChanged(string name)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
using System;
|
||||
using Thought.vCards;
|
||||
using VCFEditor.View;
|
||||
using vCardEditor.View;
|
||||
using vCardEditor.View.Customs;
|
||||
using VCFEditor.Repository;
|
||||
using vCardEditor.Repository;
|
||||
using vCardEditor.Model;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace VCFEditor.Presenter
|
||||
@@ -15,6 +14,7 @@ namespace VCFEditor.Presenter
|
||||
{
|
||||
private readonly IMainView _view;
|
||||
private readonly IContactRepository _repository;
|
||||
|
||||
|
||||
public MainPresenter(IMainView view, IContactRepository repository)
|
||||
{
|
||||
@@ -23,7 +23,7 @@ namespace VCFEditor.Presenter
|
||||
|
||||
_view.LoadForm += LoadFormHandler;
|
||||
_view.AddContact += AddContactHandler;
|
||||
_view.NewFileOpened += NewFileOpenedHandler;
|
||||
_view.NewFileOpened += OpenNewFileHandler;
|
||||
_view.SaveContactsSelected += SaveContactsHandler;
|
||||
_view.ChangeContactsSelected += ChangeContactSelectedHandler;
|
||||
_view.DeleteContact += DeleteContactHandler;
|
||||
@@ -39,7 +39,135 @@ namespace VCFEditor.Presenter
|
||||
_view.AddressRemoved += AddressRemovedHandler;
|
||||
_view.CopyTextToClipboardEvent += CopyTextToClipboardHandler;
|
||||
_view.AddExtraField += _view_AddExtraField;
|
||||
_view.CountImagesEvent += _view_CountImages;
|
||||
_view.ClearImagesEvent += _view_ClearImages;
|
||||
_view.BatchExportImagesEvent += _view_BatchExportImagesEvent;
|
||||
_view.SplitFileEvent += SaveSplittedFileHandler;
|
||||
_view.OpenFolderEvent += OpenNewFolderHandler;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void OpenNewFolderHandler(object sender, EventArg<string> e)
|
||||
{
|
||||
BeforeOpeningNewFileHandler();
|
||||
|
||||
string path = e.Data;
|
||||
if (string.IsNullOrEmpty(path))
|
||||
path = _view.DisplayOpenFolderDialog();
|
||||
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
var Loaded =_repository.LoadMultipleFilesContact(path);
|
||||
if (!Loaded)
|
||||
{
|
||||
_view.DisplayMessage("No file loaded!", "Error");
|
||||
return;
|
||||
}
|
||||
|
||||
AddPathToMostRecentUsedFiles(path);
|
||||
_view.DisplayContacts(_repository.Contacts);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void OpenNewFileHandler(object sender, EventArg<string> e)
|
||||
{
|
||||
BeforeOpeningNewFileHandler();
|
||||
|
||||
string path = e.Data;
|
||||
if (string.IsNullOrEmpty(path))
|
||||
path = _view.DisplayOpenFileDialog("vCard Files|*.vcf");
|
||||
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
string ext = _repository.GetExtension(path);
|
||||
if (!string.Equals(ext, ".vcf", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
_view.DisplayMessage("Only vcf extension accepted!", "Error");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!_repository.LoadContacts(path))
|
||||
_view.DisplayMessage("File seems missing or corrupted!", "Error");
|
||||
else
|
||||
{
|
||||
_view.DisplayContacts(_repository.Contacts);
|
||||
AddPathToMostRecentUsedFiles(path);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
private void AddPathToMostRecentUsedFiles(string path)
|
||||
{
|
||||
FixedList MostRecentUsedFiles = ConfigRepository.Instance.Paths;
|
||||
if (!MostRecentUsedFiles.Contains(path))
|
||||
{
|
||||
MostRecentUsedFiles.Enqueue(path);
|
||||
_view.UpdateMRUMenu(MostRecentUsedFiles);
|
||||
}
|
||||
}
|
||||
private void _view_BatchExportImagesEvent(object sender, EventArgs e)
|
||||
{
|
||||
if (_repository.Contacts == null || _repository.Contacts.Count == 0)
|
||||
return;
|
||||
|
||||
int count = 0;
|
||||
for (int i = 0; i < _repository.Contacts.Count; i++)
|
||||
{
|
||||
if (_repository.Contacts[i].card.Photos.Count > 0)
|
||||
{
|
||||
count++;
|
||||
SaveCardPhoto(_repository.Contacts[i].card, i);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (count > 0)
|
||||
_view.DisplayMessage($"{count} contact(s) processed!", "Photo Count");
|
||||
else
|
||||
_view.DisplayMessage($"No picture found!", "Photo Count");
|
||||
}
|
||||
|
||||
private void _view_ClearImages(object sender, EventArgs e)
|
||||
{
|
||||
if (_repository.Contacts == null || _repository.Contacts.Count == 0)
|
||||
return;
|
||||
|
||||
int count = 0;
|
||||
for (int i = 0; i < _repository.Contacts.Count; i++)
|
||||
{
|
||||
if (_repository.Contacts[i].card.Photos.Count > 0)
|
||||
{
|
||||
count++;
|
||||
_repository.ModifyImage(i, null);
|
||||
|
||||
//remove from the form the image displayed.
|
||||
if (_view.SelectedContactIndex == i)
|
||||
_view.ClearImageFromForm();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (count > 0)
|
||||
_view.DisplayMessage($"{count} contact(s) processed!", "Photo Count");
|
||||
else
|
||||
_view.DisplayMessage($"No picture found!", "Photo Count");
|
||||
}
|
||||
|
||||
private void _view_CountImages(object sender, EventArgs e)
|
||||
{
|
||||
if (_repository.Contacts == null)
|
||||
return;
|
||||
|
||||
var count = _repository.Contacts.Count(x => x.card.Photos.Count > 0);
|
||||
if (count > 0)
|
||||
_view.DisplayMessage($"{count} contact(s) containing a picture = ", "Photo Count");
|
||||
else
|
||||
_view.DisplayMessage($"No picture found!", "Photo Count");
|
||||
}
|
||||
|
||||
private void _view_AddExtraField(object sender, EventArg<vCardPropeties> e)
|
||||
@@ -66,7 +194,7 @@ namespace VCFEditor.Presenter
|
||||
if (paths.Length > 1)
|
||||
{
|
||||
var evt = new EventArg<string>(paths[1]);
|
||||
NewFileOpenedHandler(sender, evt);
|
||||
OpenNewFileHandler(sender, evt);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -103,16 +231,25 @@ namespace VCFEditor.Presenter
|
||||
{
|
||||
//TODO: image can be url, or file location.
|
||||
var card = _repository.Contacts[_view.SelectedContactIndex].card;
|
||||
var image = card.Photos.FirstOrDefault();
|
||||
SaveCardPhoto(card, _view.SelectedContactIndex, true);
|
||||
}
|
||||
}
|
||||
|
||||
if (image != null)
|
||||
{
|
||||
|
||||
var newPath = _repository.ChangeExtension(_repository.fileName, image.Extension);
|
||||
private void SaveCardPhoto(vCard card, int index, bool askUser = false)
|
||||
{
|
||||
//TODO: Save every image for a vCard.
|
||||
var image = card.Photos.FirstOrDefault();
|
||||
|
||||
string imageFile = _view.DisplaySaveDialog(newPath);
|
||||
_repository.SaveImageToDisk(imageFile, image);
|
||||
}
|
||||
if (image != null)
|
||||
{
|
||||
|
||||
var newPath = _repository.GenerateFileName(_repository.fileName, index, image.Extension);
|
||||
|
||||
//string ImagePath = string.Empty;
|
||||
//if (askUser)
|
||||
// ImagePath = _view.DisplaySaveDialog(newPath);
|
||||
|
||||
_repository.SaveImageToDisk(newPath, image);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,6 +312,7 @@ namespace VCFEditor.Presenter
|
||||
private void AddContactHandler(object sender, EventArgs e)
|
||||
{
|
||||
_repository.AddEmptyContact();
|
||||
_view.DisplayContacts(_repository.Contacts);
|
||||
}
|
||||
|
||||
private void DeleteContactHandler(object sender, EventArgs e)
|
||||
@@ -184,8 +322,29 @@ namespace VCFEditor.Presenter
|
||||
|
||||
private void SaveContactsHandler(object sender, EventArgs e)
|
||||
{
|
||||
string filename;
|
||||
if (!string.IsNullOrEmpty(_repository.fileName))
|
||||
_repository.SaveContactsToFile(_repository.fileName);
|
||||
filename = _repository.fileName;
|
||||
else
|
||||
filename = _view.DisplaySaveDialog("");
|
||||
|
||||
|
||||
_repository.SaveContactsToFile(filename);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void SaveSplittedFileHandler(object sender, EventArgs e)
|
||||
{
|
||||
if (_repository.Contacts == null || _repository.Contacts.Count == 0)
|
||||
return;
|
||||
|
||||
string Path = _view.DisplayOpenFolderDialog();
|
||||
if (!string.IsNullOrEmpty(Path))
|
||||
{
|
||||
int count = _repository.SaveSplittedFiles(Path);
|
||||
_view.DisplayMessage(string.Format("{0} contact(s) processed!", count), "Information");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -194,42 +353,12 @@ namespace VCFEditor.Presenter
|
||||
if (_repository.Contacts != null && _repository.dirty)
|
||||
{
|
||||
if (!_view.AskMessage("Save current file before?", "Load"))
|
||||
_repository.SaveContactsToFile(_repository.fileName);
|
||||
SaveContactsHandler(null, null);
|
||||
//_repository.SaveContactsToFile(_repository.fileName);
|
||||
}
|
||||
|
||||
}
|
||||
public void NewFileOpenedHandler(object sender, EventArg<string> e)
|
||||
{
|
||||
BeforeOpeningNewFileHandler();
|
||||
|
||||
string path = e.Data;
|
||||
if (string.IsNullOrEmpty(path))
|
||||
path = _view.DisplayOpenDialog("vCard Files|*.vcf");
|
||||
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
string ext = _repository.GetExtension(path);
|
||||
if (!string.Equals(ext, ".vcf", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
_view.DisplayMessage("Only vcf extension accepted!", "Error");
|
||||
return;
|
||||
}
|
||||
|
||||
FixedList MostRecentUsedFiles = ConfigRepository.Instance.Paths;
|
||||
if (!MostRecentUsedFiles.Contains(path))
|
||||
{
|
||||
MostRecentUsedFiles.Enqueue(path);
|
||||
_view.UpdateMRUMenu(MostRecentUsedFiles);
|
||||
}
|
||||
|
||||
if (!_repository.LoadContacts(path))
|
||||
_view.DisplayMessage("File seems missing or corrupted!", "Error");
|
||||
else
|
||||
_view.DisplayContacts(_repository.Contacts);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void ChangeContactSelectedHandler(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
@@ -32,4 +32,4 @@ using System.Runtime.InteropServices;
|
||||
// Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut
|
||||
// en utilisant '*', comme indiqué ci-dessous :
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("0.5.5")]
|
||||
[assembly: AssemblyVersion("0.5.7")]
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
0.5.5
|
||||
0.5.7
|
||||
added a feature to batch export/clear/count images.
|
||||
Fix bug when opening files by menu.
|
||||
some buttons click were not working properly.
|
||||
|
||||
0.5.6
|
||||
Not released!
|
||||
|
||||
0.5.5
|
||||
redisgn the extra tab
|
||||
Fix some bugs
|
||||
|
||||
@@ -31,4 +39,4 @@
|
||||
Replaced Moq with nsubstitute (Test mocking library).
|
||||
|
||||
0.1
|
||||
Intial release
|
||||
Intial release
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace vCardEditor.Repository
|
||||
}
|
||||
|
||||
[Description("Overwrite the file when saving")]
|
||||
public bool OverWrite { get; set; }
|
||||
public bool Overwrite { get; set; }
|
||||
[Description("Maximum entries for MRU ")]
|
||||
public int Maximum { get; set; }
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using Thought.vCards;
|
||||
using VCFEditor.Model;
|
||||
using System.ComponentModel;
|
||||
using vCardEditor.Repository;
|
||||
using vCardEditor.View;
|
||||
|
||||
@@ -49,22 +48,43 @@ namespace VCFEditor.Repository
|
||||
_fileHandler = fileHandler;
|
||||
}
|
||||
|
||||
public bool LoadMultipleFilesContact(string path)
|
||||
{
|
||||
Contacts.Clear();
|
||||
|
||||
string[] filePaths = _fileHandler.GetFiles(path, "*.vcf");
|
||||
if (filePaths.Count() == 0)
|
||||
return false;
|
||||
|
||||
foreach (var item in filePaths)
|
||||
{
|
||||
var result = LoadContactFromFile(item);
|
||||
Contacts.AddRange(result);
|
||||
OriginalContactList = Contacts;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool LoadContacts(string fileName)
|
||||
{
|
||||
Contacts.Clear();
|
||||
|
||||
this.fileName = fileName;
|
||||
Contacts = LoadContactFromFile(fileName);
|
||||
OriginalContactList = Contacts;
|
||||
return true;
|
||||
}
|
||||
|
||||
public SortableBindingList<Contact> LoadContactFromFile(string fileName)
|
||||
{
|
||||
if (!_fileHandler.FileExist(fileName))
|
||||
{
|
||||
OriginalContactList = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
SortableBindingList<Contact> ListOfContacts = new SortableBindingList<Contact>();
|
||||
|
||||
string[] lines = _fileHandler.ReadAllLines(fileName);
|
||||
|
||||
StringBuilder RawContent = new StringBuilder();
|
||||
Contact contact = new Contact();
|
||||
Contact contact;
|
||||
|
||||
for (int i = 0; i < lines.Length; i++)
|
||||
{
|
||||
@@ -73,23 +93,19 @@ namespace VCFEditor.Repository
|
||||
{
|
||||
if (string.Equals(lines[i].TrimEnd(), "END:VCARD", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
contact.card = ParseRawContent(RawContent);
|
||||
Contacts.Add(contact);
|
||||
contact = new Contact();
|
||||
contact = new Contact(ParseRawContent(RawContent));
|
||||
ListOfContacts.Add(contact);
|
||||
RawContent.Length = 0;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
OriginalContactList = null;
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
OriginalContactList = Contacts;
|
||||
return true;
|
||||
}
|
||||
|
||||
return ListOfContacts;
|
||||
}
|
||||
private vCard ParseRawContent(StringBuilder rawContent)
|
||||
{
|
||||
vCard card = null;
|
||||
@@ -102,11 +118,9 @@ namespace VCFEditor.Repository
|
||||
|
||||
public void AddEmptyContact()
|
||||
{
|
||||
if (_contacts != null && _contacts.Count > 0)
|
||||
{
|
||||
Contact contact = new Contact();
|
||||
Contacts.Add(contact);
|
||||
}
|
||||
Contact contact = new Contact();
|
||||
contact.isDirty = true;
|
||||
Contacts.Add(contact);
|
||||
}
|
||||
|
||||
public void SaveContactsToFile(string fileName)
|
||||
@@ -116,7 +130,7 @@ namespace VCFEditor.Repository
|
||||
fileName = this.fileName;
|
||||
|
||||
//Take a copy if specified in the config file
|
||||
if (!ConfigRepository.Instance.OverWrite)
|
||||
if (!ConfigRepository.Instance.Overwrite)
|
||||
{
|
||||
string backupName = GetBackupName();
|
||||
_fileHandler.MoveFile(fileName, backupName);
|
||||
@@ -388,7 +402,49 @@ namespace VCFEditor.Repository
|
||||
return _fileHandler.ChangeExtension(path, extension);
|
||||
}
|
||||
|
||||
|
||||
public string GenerateFileName(string fileName, int index, string extension)
|
||||
{
|
||||
string result = _fileHandler.GetFileNameWithExtension(fileName, index, extension);
|
||||
return result;
|
||||
}
|
||||
|
||||
public int SaveSplittedFiles(string FolderPath)
|
||||
{
|
||||
//Do not save the deleted ones!
|
||||
var contactsToSave = Contacts.Where(x => !x.isDeleted).ToList();
|
||||
int count;
|
||||
for (count = 0; count < contactsToSave.Count(); count++)
|
||||
{
|
||||
var entry = contactsToSave[count];
|
||||
string SerializedCard = GenerateStringFromVCard(entry.card);
|
||||
|
||||
//Check if filename for the card is empty, and generate one if empty
|
||||
if (string.IsNullOrEmpty(entry.path))
|
||||
entry.path = GenerateFileName(FolderPath, entry.FamilyName, count);
|
||||
|
||||
_fileHandler.WriteAllText(entry.path, SerializedCard);
|
||||
|
||||
//Clean the flag for every contact, even the deleted ones.
|
||||
entry.isDirty = false;
|
||||
|
||||
}
|
||||
|
||||
//Clean the global flag for the entire vCard Catalog.
|
||||
_dirty = false;
|
||||
|
||||
//return number of contacts processed!
|
||||
return count;
|
||||
}
|
||||
|
||||
private string GenerateFileName(string FolderPath, string familyName, int index)
|
||||
{
|
||||
string FinalPath;
|
||||
if (string.IsNullOrEmpty(familyName))
|
||||
FinalPath = _fileHandler.GetVcfFileName(FolderPath, index.ToString());
|
||||
else
|
||||
FinalPath = _fileHandler.GetVcfFileName(FolderPath, familyName);
|
||||
|
||||
return FinalPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,9 @@ namespace vCardEditor.Repository
|
||||
|
||||
public void MoveFile(string newFilename, string oldFilename)
|
||||
{
|
||||
File.Move(newFilename, oldFilename);
|
||||
if (File.Exists(newFilename))
|
||||
File.Move(newFilename, oldFilename);
|
||||
|
||||
}
|
||||
|
||||
public string[] ReadAllLines(string filename)
|
||||
@@ -43,5 +45,22 @@ namespace vCardEditor.Repository
|
||||
ms.WriteTo(fs);
|
||||
}
|
||||
}
|
||||
|
||||
public string GetVcfFileName(string folderPath, string filename)
|
||||
{
|
||||
return Path.Combine(folderPath, filename + ".vcf");
|
||||
}
|
||||
|
||||
public string GetFileNameWithExtension(string fileName, int index, string extension)
|
||||
{
|
||||
return Path.Combine(Path.GetDirectoryName(fileName), index.ToString() + "." + extension);
|
||||
}
|
||||
|
||||
public string[] GetFiles(string path, string ext)
|
||||
{
|
||||
string[] filePaths = Directory.GetFiles(path, ext,SearchOption.TopDirectoryOnly);
|
||||
return filePaths;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace vCardEditor.Repository
|
||||
public interface IConfigRepository
|
||||
{
|
||||
int Maximum { get; set; }
|
||||
bool OverWrite { get; set; }
|
||||
bool Overwrite { get; set; }
|
||||
FixedList Paths { get; set; }
|
||||
|
||||
void SaveConfig();
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Thought.vCards;
|
||||
using VCFEditor.Model;
|
||||
using System.ComponentModel;
|
||||
using vCardEditor.View;
|
||||
|
||||
namespace VCFEditor.Repository
|
||||
@@ -15,6 +11,7 @@ namespace VCFEditor.Repository
|
||||
string fileName { get; set; }
|
||||
SortableBindingList<Contact> Contacts { get; set; }
|
||||
bool LoadContacts(string fileName);
|
||||
bool LoadMultipleFilesContact(string path);
|
||||
SortableBindingList<Contact> FilterContacts(string p);
|
||||
void SaveContactsToFile(string fileName);
|
||||
void DeleteContact();
|
||||
@@ -23,9 +20,12 @@ namespace VCFEditor.Repository
|
||||
void AddEmptyContact();
|
||||
void ModifyImage(int index, vCardPhoto photo);
|
||||
string GetExtension(string path);
|
||||
string ChangeExtension(string path, string extension);
|
||||
//string ChangeExtension(string path, int index, string extension);
|
||||
void SaveImageToDisk(string imageFile, vCardPhoto image);
|
||||
|
||||
string GenerateStringFromVCard(vCard card);
|
||||
string GenerateFileName(string fileName, int index, string extension);
|
||||
int SaveSplittedFiles(string Path);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
namespace vCardEditor.Repository
|
||||
using System.IO;
|
||||
|
||||
namespace vCardEditor.Repository
|
||||
{
|
||||
public interface IFileHandler
|
||||
{
|
||||
@@ -9,5 +11,8 @@
|
||||
string GetExtension(string path);
|
||||
string ChangeExtension(string path, string extension);
|
||||
void WriteBytesToFile(string imageFile, byte[] image);
|
||||
string GetVcfFileName(string folderPath, string familyName);
|
||||
string GetFileNameWithExtension(string fileName, int index, string extension);
|
||||
string[] GetFiles(string path, string ext);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Ce code a été généré par un outil.
|
||||
// Version du runtime :4.0.30319.34209
|
||||
//
|
||||
// Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si
|
||||
// le code est régénéré.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Thought.vCards {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Une classe de ressource fortement typée destinée, entre autres, à la consultation des chaînes localisées.
|
||||
/// </summary>
|
||||
// Cette classe a été générée automatiquement par la classe StronglyTypedResourceBuilder
|
||||
// à l'aide d'un outil, tel que ResGen ou Visual Studio.
|
||||
// Pour ajouter ou supprimer un membre, modifiez votre fichier .ResX, puis réexécutez ResGen
|
||||
// avec l'option /str ou régénérez votre projet VS.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class WarningMessages {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal WarningMessages() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retourne l'instance ResourceManager mise en cache utilisée par cette classe.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("vCardEditor.Thought.vCards.WarningMessages", typeof(WarningMessages).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remplace la propriété CurrentUICulture du thread actuel pour toutes
|
||||
/// les recherches de ressources à l'aide de cette classe de ressource fortement typée.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recherche une chaîne localisée semblable à Line {0} A blank line was encountered. This is not allowed in the vCard specification..
|
||||
/// </summary>
|
||||
internal static string BlankLine {
|
||||
get {
|
||||
return ResourceManager.GetString("BlankLine", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recherche une chaîne localisée semblable à Line {0}: A colon (:) is missing. All properties must be in NAME:VALUE format..
|
||||
/// </summary>
|
||||
internal static string ColonMissing {
|
||||
get {
|
||||
return ResourceManager.GetString("ColonMissing", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recherche une chaîne localisée semblable à Line {0}: The name section of the property is empty..
|
||||
/// </summary>
|
||||
internal static string EmptyName {
|
||||
get {
|
||||
return ResourceManager.GetString("EmptyName", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,129 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="BlankLine" xml:space="preserve">
|
||||
<value>Line {0} A blank line was encountered. This is not allowed in the vCard specification.</value>
|
||||
</data>
|
||||
<data name="ColonMissing" xml:space="preserve">
|
||||
<value>Line {0}: A colon (:) is missing. All properties must be in NAME:VALUE format.</value>
|
||||
</data>
|
||||
<data name="EmptyName" xml:space="preserve">
|
||||
<value>Line {0}: The name section of the property is empty.</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -10,7 +10,7 @@ namespace vCardEditor.View
|
||||
public ConfigDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
ConfigRepository conf = ConfigRepository.Instance;//
|
||||
ConfigRepository conf = ConfigRepository.Instance;
|
||||
pgConfig.SelectedObject = conf;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,8 +36,8 @@ namespace vCardEditor.View.Customs
|
||||
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.cbParcel = new System.Windows.Forms.CheckBox();
|
||||
this.cbPreferred = new System.Windows.Forms.CheckBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// cbHome
|
||||
@@ -73,7 +73,7 @@ namespace vCardEditor.View.Customs
|
||||
// cbDomestic
|
||||
//
|
||||
this.cbDomestic.AutoSize = true;
|
||||
this.cbDomestic.Location = new System.Drawing.Point(12, 94);
|
||||
this.cbDomestic.Location = new System.Drawing.Point(143, 40);
|
||||
this.cbDomestic.Name = "cbDomestic";
|
||||
this.cbDomestic.Size = new System.Drawing.Size(88, 21);
|
||||
this.cbDomestic.TabIndex = 3;
|
||||
@@ -82,8 +82,9 @@ namespace vCardEditor.View.Customs
|
||||
//
|
||||
// btnOK
|
||||
//
|
||||
this.btnOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.btnOK.Location = new System.Drawing.Point(95, 187);
|
||||
this.btnOK.Location = new System.Drawing.Point(95, 161);
|
||||
this.btnOK.Name = "btnOK";
|
||||
this.btnOK.Size = new System.Drawing.Size(75, 23);
|
||||
this.btnOK.TabIndex = 7;
|
||||
@@ -93,9 +94,10 @@ namespace vCardEditor.View.Customs
|
||||
//
|
||||
// btnCancel
|
||||
//
|
||||
this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnCancel.CausesValidation = false;
|
||||
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.btnCancel.Location = new System.Drawing.Point(176, 187);
|
||||
this.btnCancel.Location = new System.Drawing.Point(176, 161);
|
||||
this.btnCancel.Name = "btnCancel";
|
||||
this.btnCancel.Size = new System.Drawing.Size(75, 23);
|
||||
this.btnCancel.TabIndex = 8;
|
||||
@@ -105,37 +107,41 @@ namespace vCardEditor.View.Customs
|
||||
// cbInternational
|
||||
//
|
||||
this.cbInternational.AutoSize = true;
|
||||
this.cbInternational.Location = new System.Drawing.Point(12, 121);
|
||||
this.cbInternational.Location = new System.Drawing.Point(143, 12);
|
||||
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
|
||||
// cbParcel
|
||||
//
|
||||
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;
|
||||
this.cbParcel.AutoSize = true;
|
||||
this.cbParcel.Location = new System.Drawing.Point(143, 67);
|
||||
this.cbParcel.Name = "cbParcel";
|
||||
this.cbParcel.Size = new System.Drawing.Size(70, 21);
|
||||
this.cbParcel.TabIndex = 10;
|
||||
this.cbParcel.Text = "Parcel";
|
||||
this.cbParcel.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// textBox1
|
||||
// cbPreferred
|
||||
//
|
||||
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;
|
||||
this.cbPreferred.AutoSize = true;
|
||||
this.cbPreferred.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.cbPreferred.Location = new System.Drawing.Point(95, 113);
|
||||
this.cbPreferred.Name = "cbPreferred";
|
||||
this.cbPreferred.Size = new System.Drawing.Size(99, 21);
|
||||
this.cbPreferred.TabIndex = 11;
|
||||
this.cbPreferred.Text = "Preferred";
|
||||
this.cbPreferred.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// AddAddress
|
||||
// AddAddressDialog
|
||||
//
|
||||
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.ClientSize = new System.Drawing.Size(263, 196);
|
||||
this.Controls.Add(this.cbPreferred);
|
||||
this.Controls.Add(this.cbParcel);
|
||||
this.Controls.Add(this.cbInternational);
|
||||
this.Controls.Add(this.btnCancel);
|
||||
this.Controls.Add(this.btnOK);
|
||||
@@ -143,7 +149,7 @@ namespace vCardEditor.View.Customs
|
||||
this.Controls.Add(this.cbPostal);
|
||||
this.Controls.Add(this.cbWork);
|
||||
this.Controls.Add(this.cbHome);
|
||||
this.Name = "AddAddress";
|
||||
this.Name = "AddAddressDialog";
|
||||
this.Text = "Address Type";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
@@ -159,7 +165,7 @@ namespace vCardEditor.View.Customs
|
||||
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;
|
||||
private System.Windows.Forms.CheckBox cbParcel;
|
||||
private System.Windows.Forms.CheckBox cbPreferred;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,7 @@
|
||||
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;
|
||||
|
||||
@@ -30,50 +26,52 @@ namespace vCardEditor.View.Customs
|
||||
Addresses = addressCollection;
|
||||
_checkBoxes = Controls.OfType<CheckBox>().ToList();
|
||||
|
||||
|
||||
|
||||
foreach (var item in addressCollection)
|
||||
{
|
||||
switch (item.ToString())
|
||||
{
|
||||
case "Home":
|
||||
cbHome.Checked = true;
|
||||
break;
|
||||
|
||||
break;
|
||||
case "Work":
|
||||
cbWork.Checked = true;
|
||||
break;
|
||||
|
||||
case "Postal":
|
||||
cbPostal.Checked = true;
|
||||
break;
|
||||
|
||||
case "Parcel":
|
||||
cbParcel.Checked = true;
|
||||
break;
|
||||
case "Preferred":
|
||||
cbPreferred.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);
|
||||
var checkedItems = _checkBoxes.Where(checkBox => checkBox.Checked);
|
||||
|
||||
if (total.Count() == 0)
|
||||
if (checkedItems.Count() == 0)
|
||||
{
|
||||
MessageBox.Show("One item must be checked!");
|
||||
MessageBox.Show("At least, one address type must be checked!");
|
||||
DialogResult = DialogResult.None;
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var item in total)
|
||||
|
||||
Addresses.Clear();
|
||||
foreach (var item in checkedItems)
|
||||
{
|
||||
var enumType = (vCardDeliveryAddressTypes)Enum.Parse(typeof(vCardDeliveryAddressTypes), item.Text, true);
|
||||
Addresses.Add(enumType);
|
||||
@@ -81,6 +79,5 @@ namespace vCardEditor.View.Customs
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
74
vCardEditor/View/Customs/AddressBox.Designer.cs
generated
74
vCardEditor/View/Customs/AddressBox.Designer.cs
generated
@@ -29,38 +29,36 @@ namespace vCardEditor.View.Customs
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.ExtAddrValue = new vCardEditor.View.StateTextBox();
|
||||
this.ExtAddrValue = new vCardEditor.View.Customs.StateTextBox();
|
||||
this.ExtAdressLabel = new System.Windows.Forms.Label();
|
||||
this.StreetLabel = new System.Windows.Forms.Label();
|
||||
this.StreetValue = new vCardEditor.View.StateTextBox();
|
||||
this.StreetValue = new vCardEditor.View.Customs.StateTextBox();
|
||||
this.POBoxLabel = new System.Windows.Forms.Label();
|
||||
this.CountryValue = new vCardEditor.View.StateTextBox();
|
||||
this.CountryValue = new vCardEditor.View.Customs.StateTextBox();
|
||||
this.Country = new System.Windows.Forms.Label();
|
||||
this.POBoxValue = new vCardEditor.View.StateTextBox();
|
||||
this.POBoxValue = new vCardEditor.View.Customs.StateTextBox();
|
||||
this.CityLabel = new System.Windows.Forms.Label();
|
||||
this.RegionValue = new vCardEditor.View.StateTextBox();
|
||||
this.CityValue = new vCardEditor.View.StateTextBox();
|
||||
this.RegionValue = new vCardEditor.View.Customs.StateTextBox();
|
||||
this.CityValue = new vCardEditor.View.Customs.StateTextBox();
|
||||
this.StateLabel = new System.Windows.Forms.Label();
|
||||
this.ZipLabel = new System.Windows.Forms.Label();
|
||||
this.ZipValue = new vCardEditor.View.StateTextBox();
|
||||
this.ZipValue = new vCardEditor.View.Customs.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.Location = new System.Drawing.Point(68, 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.Size = new System.Drawing.Size(190, 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(4, 45);
|
||||
this.ExtAdressLabel.Location = new System.Drawing.Point(5, 44);
|
||||
this.ExtAdressLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.ExtAdressLabel.Name = "ExtAdressLabel";
|
||||
this.ExtAdressLabel.Size = new System.Drawing.Size(40, 23);
|
||||
@@ -73,7 +71,7 @@ namespace vCardEditor.View.Customs
|
||||
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.Size = new System.Drawing.Size(64, 23);
|
||||
this.StreetLabel.TabIndex = 14;
|
||||
this.StreetLabel.Text = "Address:";
|
||||
this.StreetLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
@@ -82,18 +80,18 @@ namespace vCardEditor.View.Customs
|
||||
//
|
||||
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.Location = new System.Drawing.Point(68, 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.Size = new System.Drawing.Size(632, 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(338, 75);
|
||||
this.POBoxLabel.Location = new System.Drawing.Point(267, 76);
|
||||
this.POBoxLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.POBoxLabel.Name = "POBoxLabel";
|
||||
this.POBoxLabel.Size = new System.Drawing.Size(38, 23);
|
||||
@@ -105,18 +103,18 @@ namespace vCardEditor.View.Customs
|
||||
//
|
||||
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.Location = new System.Drawing.Point(557, 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.Size = new System.Drawing.Size(143, 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.Location = new System.Drawing.Point(486, 74);
|
||||
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);
|
||||
@@ -126,20 +124,18 @@ namespace vCardEditor.View.Customs
|
||||
//
|
||||
// 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, 76);
|
||||
this.POBoxValue.Location = new System.Drawing.Point(315, 77);
|
||||
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.Size = new System.Drawing.Size(166, 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, 46);
|
||||
this.CityLabel.Location = new System.Drawing.Point(267, 44);
|
||||
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);
|
||||
@@ -151,31 +147,29 @@ namespace vCardEditor.View.Customs
|
||||
//
|
||||
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.Location = new System.Drawing.Point(557, 44);
|
||||
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.Size = new System.Drawing.Size(143, 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.Location = new System.Drawing.Point(316, 46);
|
||||
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.Size = new System.Drawing.Size(166, 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(2, 74);
|
||||
this.StateLabel.Location = new System.Drawing.Point(486, 46);
|
||||
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);
|
||||
@@ -185,31 +179,29 @@ namespace vCardEditor.View.Customs
|
||||
//
|
||||
// ZipLabel
|
||||
//
|
||||
this.ZipLabel.Location = new System.Drawing.Point(533, 45);
|
||||
this.ZipLabel.Location = new System.Drawing.Point(5, 75);
|
||||
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.TabIndex = 28;
|
||||
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.Location = new System.Drawing.Point(68, 77);
|
||||
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);
|
||||
this.ZipValue.Size = new System.Drawing.Size(190, 22);
|
||||
this.ZipValue.TabIndex = 29;
|
||||
//
|
||||
// AddressBox
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.ZipLabel);
|
||||
this.Controls.Add(this.ZipValue);
|
||||
this.Controls.Add(this.ExtAddrValue);
|
||||
this.Controls.Add(this.ExtAdressLabel);
|
||||
this.Controls.Add(this.StreetLabel);
|
||||
@@ -222,8 +214,6 @@ namespace vCardEditor.View.Customs
|
||||
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);
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace vCardEditor.View.Customs
|
||||
da.AddressType = diag.Addresses;
|
||||
AddtabForAddress(da);
|
||||
AddTab?.Invoke(sender, new EventArg<List<vCardDeliveryAddressTypes>>(diag.Addresses));
|
||||
SelectedIndex = TabCount - 1;
|
||||
SelectedIndex = TabCount - 2;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -200,6 +200,7 @@ namespace vCardEditor.View.Customs
|
||||
da.PostalCode, da.ExtendedAddress, da.PostOfficeBox, da.AddressType);
|
||||
|
||||
ab.TextChangedEvent += (s, e) => TextChangedEvent?.Invoke(s, e);
|
||||
ab.Dock = DockStyle.Fill;
|
||||
page.Controls.Add(ab);
|
||||
page.ToolTipText = string.Join(",", da.AddressType.ConvertAll(f => f.ToString()));
|
||||
|
||||
|
||||
@@ -9,27 +9,17 @@ namespace vCardEditor.View.Customs
|
||||
|
||||
public partial class ExtendedPanel : UserControl
|
||||
{
|
||||
public event EventHandler ContentTextChanged;
|
||||
|
||||
public string Caption
|
||||
{
|
||||
get { return PanelContent.Text; }
|
||||
set { PanelContent.Text = value; }
|
||||
}
|
||||
|
||||
public PanelType panelType { get; set; }
|
||||
|
||||
public ExtendedPanel(PanelType _panel)
|
||||
public ExtendedPanel()
|
||||
{
|
||||
InitializeComponent();
|
||||
panelType = _panel;
|
||||
|
||||
miCell.Click += MenuItemClickHandlers;
|
||||
miCell.Tag = new vCardPhone(string.Empty, vCardPhoneTypes.Cellular);
|
||||
|
||||
miHome.Tag = new vCardPhone(string.Empty, vCardPhoneTypes.Home);
|
||||
miHome.Click += MenuItemClickHandlers;
|
||||
|
||||
miWork.Tag = new vCardPhone(string.Empty, vCardPhoneTypes.Home);
|
||||
miWork.Tag = new vCardPhone(string.Empty, vCardPhoneTypes.Work);
|
||||
miWork.Click += MenuItemClickHandlers;
|
||||
|
||||
miEmail.Tag = new vCardEmailAddress(string.Empty, vCardEmailAddressType.Internet);
|
||||
@@ -47,7 +37,15 @@ namespace vCardEditor.View.Customs
|
||||
//}
|
||||
|
||||
}
|
||||
public event EventHandler ContentTextChanged;
|
||||
|
||||
public string Caption
|
||||
{
|
||||
get { return PanelContent.Text; }
|
||||
set { PanelContent.Text = value; }
|
||||
}
|
||||
|
||||
public PanelType panelType { get; set; }
|
||||
private void MenuItemClickHandlers(object sender, EventArgs e)
|
||||
{
|
||||
var tag = (sender as ToolStripMenuItem).Tag;
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace vCardEditor.View.UIToolbox
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.btnClose = new System.Windows.Forms.Button();
|
||||
this.txtContent = new vCardEditor.View.StateTextBox();
|
||||
this.txtContent = new vCardEditor.View.Customs.StateTextBox();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
@@ -78,7 +78,7 @@ namespace vCardEditor.View.UIToolbox
|
||||
|
||||
#endregion
|
||||
private System.Windows.Forms.Button btnClose;
|
||||
private StateTextBox txtContent;
|
||||
private Customs.StateTextBox txtContent;
|
||||
private System.Windows.Forms.Label label2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace vCardEditor.View.Customs
|
||||
{
|
||||
this.btnRemove = new System.Windows.Forms.Button();
|
||||
this.TitleLabel = new System.Windows.Forms.Label();
|
||||
this.ContentTextBox = new vCardEditor.View.StateTextBox();
|
||||
this.ContentTextBox = new vCardEditor.View.Customs.StateTextBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// btnRemove
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace vCardEditor.View
|
||||
namespace vCardEditor.View.Customs
|
||||
{
|
||||
public class StateTextBox : TextBox
|
||||
{
|
||||
@@ -12,5 +12,7 @@ namespace VCFEditor.View
|
||||
}
|
||||
|
||||
public T Data { get; set; }
|
||||
|
||||
public bool CanCancel { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,13 +27,18 @@ namespace VCFEditor.View
|
||||
event EventHandler<EventArg<int>> AddressRemoved;
|
||||
event EventHandler CopyTextToClipboardEvent;
|
||||
event EventHandler<EventArg<vCardPropeties>> AddExtraField;
|
||||
event EventHandler CountImagesEvent;
|
||||
event EventHandler ClearImagesEvent;
|
||||
event EventHandler BatchExportImagesEvent;
|
||||
event EventHandler<EventArg<string>> OpenFolderEvent;
|
||||
event EventHandler SplitFileEvent;
|
||||
int SelectedContactIndex { get; }
|
||||
void DisplayContacts(SortableBindingList<Contact> contacts);
|
||||
void DisplayContactDetail(vCard card, string FileName);
|
||||
void ClearContactDetail();
|
||||
bool AskMessage(string msg, string caption);
|
||||
void DisplayMessage(string msg, string caption);
|
||||
string DisplayOpenDialog(string filter);
|
||||
string DisplayOpenFileDialog(string filter);
|
||||
string DisplaySaveDialog(string filename);
|
||||
void UpdateMRUMenu(FixedList MRUList);
|
||||
|
||||
@@ -43,5 +48,8 @@ namespace VCFEditor.View
|
||||
void LoadIntialState(FormState state);
|
||||
void AddExtraTextGroup(vCardPropeties type, string content);
|
||||
void DisplayQRCode(string content);
|
||||
|
||||
void ClearImageFromForm();
|
||||
string DisplayOpenFolderDialog();
|
||||
}
|
||||
}
|
||||
|
||||
125
vCardEditor/View/MainForm.Designer.cs
generated
125
vCardEditor/View/MainForm.Designer.cs
generated
@@ -32,7 +32,7 @@ namespace vCardEditor.View
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
||||
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.miSave = new System.Windows.Forms.ToolStripMenuItem();
|
||||
@@ -56,8 +56,8 @@ namespace vCardEditor.View
|
||||
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
|
||||
this.toolStrip1 = new System.Windows.Forms.ToolStrip();
|
||||
this.tbsNew = new System.Windows.Forms.ToolStripButton();
|
||||
this.tbsOpen = new System.Windows.Forms.ToolStripButton();
|
||||
this.tbsSave = new System.Windows.Forms.ToolStripButton();
|
||||
this.tbsOpen = new System.Windows.Forms.ToolStripSplitButton();
|
||||
this.openFolderToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.tbsDelete = new System.Windows.Forms.ToolStripButton();
|
||||
this.tbsQR = new System.Windows.Forms.ToolStripButton();
|
||||
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
|
||||
@@ -78,17 +78,19 @@ namespace vCardEditor.View
|
||||
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
|
||||
this.tcMainTab = new System.Windows.Forms.TabControl();
|
||||
this.TapPageMain = new System.Windows.Forms.TabPage();
|
||||
this.extendedPanelWeb = new vCardEditor.View.Customs.ExtendedPanel();
|
||||
this.extendedPanelPhones = new vCardEditor.View.Customs.ExtendedPanel();
|
||||
this.btnExportImage = new System.Windows.Forms.Button();
|
||||
this.groupBox3 = new System.Windows.Forms.GroupBox();
|
||||
this.FormattedTitleValue = new vCardEditor.View.StateTextBox();
|
||||
this.FormattedTitleValue = new vCardEditor.View.Customs.StateTextBox();
|
||||
this.FormattedTitleLabel = new System.Windows.Forms.Label();
|
||||
this.lastNameValue = new vCardEditor.View.StateTextBox();
|
||||
this.lastNameValue = new vCardEditor.View.Customs.StateTextBox();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.middleNameValue = new vCardEditor.View.StateTextBox();
|
||||
this.middleNameValue = new vCardEditor.View.Customs.StateTextBox();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.firstNameValue = new vCardEditor.View.StateTextBox();
|
||||
this.firstNameValue = new vCardEditor.View.Customs.StateTextBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.FormattedNameValue = new vCardEditor.View.StateTextBox();
|
||||
this.FormattedNameValue = new vCardEditor.View.Customs.StateTextBox();
|
||||
this.FormattedNameLabel = new System.Windows.Forms.Label();
|
||||
this.btnRemoveImage = new System.Windows.Forms.Button();
|
||||
this.groupBox4 = new System.Windows.Forms.GroupBox();
|
||||
@@ -97,11 +99,13 @@ namespace vCardEditor.View
|
||||
this.PhotoBox = new System.Windows.Forms.PictureBox();
|
||||
this.TapPageExtra = new System.Windows.Forms.TabPage();
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.panelTabExtra = new System.Windows.Forms.Panel();
|
||||
this.btnAddExtraText = new System.Windows.Forms.Button();
|
||||
this.panelTabExtra = new System.Windows.Forms.Panel();
|
||||
this.menuExtraField = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.miNote = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.miOrg = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.tbsSave = new System.Windows.Forms.ToolStripSplitButton();
|
||||
this.splitToFilesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.menuStrip1.SuspendLayout();
|
||||
this.toolStrip1.SuspendLayout();
|
||||
this.gbNameList.SuspendLayout();
|
||||
@@ -204,7 +208,7 @@ namespace vCardEditor.View
|
||||
// copyToolStripMenuItem
|
||||
//
|
||||
this.copyToolStripMenuItem.Name = "copyToolStripMenuItem";
|
||||
this.copyToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
|
||||
this.copyToolStripMenuItem.Size = new System.Drawing.Size(167, 26);
|
||||
this.copyToolStripMenuItem.Text = "Copy";
|
||||
this.copyToolStripMenuItem.Click += new System.EventHandler(this.copyToolStripMenuItem_Click);
|
||||
//
|
||||
@@ -214,7 +218,7 @@ namespace vCardEditor.View
|
||||
this.addNotesToolStripMenuItem,
|
||||
this.addOrgToolStripMenuItem});
|
||||
this.extraFieldsToolStripMenuItem.Name = "extraFieldsToolStripMenuItem";
|
||||
this.extraFieldsToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
|
||||
this.extraFieldsToolStripMenuItem.Size = new System.Drawing.Size(167, 26);
|
||||
this.extraFieldsToolStripMenuItem.Text = "Extra Fields";
|
||||
//
|
||||
// addNotesToolStripMenuItem
|
||||
@@ -254,18 +258,21 @@ namespace vCardEditor.View
|
||||
this.exportToolStripMenuItem.Name = "exportToolStripMenuItem";
|
||||
this.exportToolStripMenuItem.Size = new System.Drawing.Size(135, 26);
|
||||
this.exportToolStripMenuItem.Text = "Export";
|
||||
this.exportToolStripMenuItem.Click += new System.EventHandler(this.exportToolStripMenuItem_Click);
|
||||
//
|
||||
// clearToolStripMenuItem
|
||||
//
|
||||
this.clearToolStripMenuItem.Name = "clearToolStripMenuItem";
|
||||
this.clearToolStripMenuItem.Size = new System.Drawing.Size(135, 26);
|
||||
this.clearToolStripMenuItem.Text = "Clear";
|
||||
this.clearToolStripMenuItem.Click += new System.EventHandler(this.clearToolStripMenuItem_Click);
|
||||
//
|
||||
// countToolStripMenuItem
|
||||
//
|
||||
this.countToolStripMenuItem.Name = "countToolStripMenuItem";
|
||||
this.countToolStripMenuItem.Size = new System.Drawing.Size(135, 26);
|
||||
this.countToolStripMenuItem.Text = "Count";
|
||||
this.countToolStripMenuItem.Click += new System.EventHandler(this.countToolStripMenuItem_Click);
|
||||
//
|
||||
// helpToolStripMenuItem
|
||||
//
|
||||
@@ -325,22 +332,21 @@ namespace vCardEditor.View
|
||||
// tbsOpen
|
||||
//
|
||||
this.tbsOpen.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
this.tbsOpen.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.openFolderToolStripMenuItem});
|
||||
this.tbsOpen.Image = ((System.Drawing.Image)(resources.GetObject("tbsOpen.Image")));
|
||||
this.tbsOpen.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.tbsOpen.Name = "tbsOpen";
|
||||
this.tbsOpen.Size = new System.Drawing.Size(29, 24);
|
||||
this.tbsOpen.Size = new System.Drawing.Size(39, 24);
|
||||
this.tbsOpen.Text = "&Open";
|
||||
this.tbsOpen.Click += new System.EventHandler(this.tbsOpen_Click);
|
||||
this.tbsOpen.ButtonClick += new System.EventHandler(this.tbsOpen_Click);
|
||||
//
|
||||
// tbsSave
|
||||
// openFolderToolStripMenuItem
|
||||
//
|
||||
this.tbsSave.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
this.tbsSave.Image = ((System.Drawing.Image)(resources.GetObject("tbsSave.Image")));
|
||||
this.tbsSave.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.tbsSave.Name = "tbsSave";
|
||||
this.tbsSave.Size = new System.Drawing.Size(29, 24);
|
||||
this.tbsSave.Text = "&Save";
|
||||
this.tbsSave.Click += new System.EventHandler(this.tbsSave_Click);
|
||||
this.openFolderToolStripMenuItem.Name = "openFolderToolStripMenuItem";
|
||||
this.openFolderToolStripMenuItem.Size = new System.Drawing.Size(174, 26);
|
||||
this.openFolderToolStripMenuItem.Text = "Open Folder";
|
||||
this.openFolderToolStripMenuItem.Click += new System.EventHandler(this.openFolderToolStripMenuItem_Click);
|
||||
//
|
||||
// tbsDelete
|
||||
//
|
||||
@@ -407,8 +413,8 @@ namespace vCardEditor.View
|
||||
this.dgContacts.AllowUserToAddRows = false;
|
||||
this.dgContacts.AllowUserToDeleteRows = false;
|
||||
this.dgContacts.AllowUserToResizeRows = false;
|
||||
dataGridViewCellStyle4.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
|
||||
this.dgContacts.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle4;
|
||||
dataGridViewCellStyle2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
|
||||
this.dgContacts.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle2;
|
||||
this.dgContacts.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
@@ -557,23 +563,25 @@ namespace vCardEditor.View
|
||||
//
|
||||
// extendedPanelWeb
|
||||
//
|
||||
this.extendedPanelWeb.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
|
||||
this.extendedPanelWeb.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.extendedPanelWeb.Caption = "";
|
||||
this.extendedPanelWeb.Location = new System.Drawing.Point(402, 389);
|
||||
this.extendedPanelWeb.Location = new System.Drawing.Point(386, 389);
|
||||
this.extendedPanelWeb.Name = "extendedPanelWeb";
|
||||
this.extendedPanelWeb.panelType = vCardEditor.View.Customs.PanelType.Web;
|
||||
this.extendedPanelWeb.Size = new System.Drawing.Size(381, 155);
|
||||
this.extendedPanelWeb.Size = new System.Drawing.Size(397, 161);
|
||||
this.extendedPanelWeb.TabIndex = 59;
|
||||
//
|
||||
// extendedPanelPhones
|
||||
//
|
||||
this.extendedPanelPhones.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.extendedPanelPhones.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.extendedPanelPhones.Caption = "";
|
||||
this.extendedPanelPhones.Location = new System.Drawing.Point(13, 389);
|
||||
this.extendedPanelPhones.Name = "extendedPanelPhones";
|
||||
this.extendedPanelPhones.panelType = vCardEditor.View.Customs.PanelType.Phone;
|
||||
this.extendedPanelPhones.Size = new System.Drawing.Size(367, 155);
|
||||
this.extendedPanelPhones.Size = new System.Drawing.Size(367, 161);
|
||||
this.extendedPanelPhones.TabIndex = 58;
|
||||
//
|
||||
// btnExportImage
|
||||
@@ -586,6 +594,7 @@ namespace vCardEditor.View
|
||||
this.btnExportImage.Size = new System.Drawing.Size(21, 23);
|
||||
this.btnExportImage.TabIndex = 57;
|
||||
this.btnExportImage.UseVisualStyleBackColor = true;
|
||||
this.btnExportImage.Click += new System.EventHandler(this.btnExportImage_Click);
|
||||
//
|
||||
// groupBox3
|
||||
//
|
||||
@@ -729,11 +738,11 @@ namespace vCardEditor.View
|
||||
this.btnRemoveImage.Size = new System.Drawing.Size(20, 23);
|
||||
this.btnRemoveImage.TabIndex = 56;
|
||||
this.btnRemoveImage.UseVisualStyleBackColor = true;
|
||||
this.btnRemoveImage.Click += new System.EventHandler(this.btnRemoveImage_Click);
|
||||
//
|
||||
// groupBox4
|
||||
//
|
||||
this.groupBox4.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
this.groupBox4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.groupBox4.Controls.Add(this.tbcAddress);
|
||||
this.groupBox4.Location = new System.Drawing.Point(13, 184);
|
||||
@@ -783,6 +792,7 @@ namespace vCardEditor.View
|
||||
this.PhotoBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
|
||||
this.PhotoBox.TabIndex = 55;
|
||||
this.PhotoBox.TabStop = false;
|
||||
this.PhotoBox.Click += new System.EventHandler(this.PhotoBox_Click);
|
||||
//
|
||||
// TapPageExtra
|
||||
//
|
||||
@@ -806,15 +816,6 @@ namespace vCardEditor.View
|
||||
this.groupBox1.TabIndex = 0;
|
||||
this.groupBox1.TabStop = false;
|
||||
//
|
||||
// panelTabExtra
|
||||
//
|
||||
this.panelTabExtra.AutoScroll = true;
|
||||
this.panelTabExtra.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.panelTabExtra.Location = new System.Drawing.Point(3, 18);
|
||||
this.panelTabExtra.Name = "panelTabExtra";
|
||||
this.panelTabExtra.Size = new System.Drawing.Size(780, 530);
|
||||
this.panelTabExtra.TabIndex = 1;
|
||||
//
|
||||
// btnAddExtraText
|
||||
//
|
||||
this.btnAddExtraText.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
@@ -827,6 +828,17 @@ namespace vCardEditor.View
|
||||
this.btnAddExtraText.UseVisualStyleBackColor = true;
|
||||
this.btnAddExtraText.Click += new System.EventHandler(this.btnAddExtraText_Click);
|
||||
//
|
||||
// panelTabExtra
|
||||
//
|
||||
this.panelTabExtra.AutoScroll = true;
|
||||
this.panelTabExtra.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.panelTabExtra.Location = new System.Drawing.Point(3, 18);
|
||||
this.panelTabExtra.Name = "panelTabExtra";
|
||||
this.panelTabExtra.Size = new System.Drawing.Size(780, 530);
|
||||
this.panelTabExtra.TabIndex = 1;
|
||||
this.panelTabExtra.ControlAdded += new System.Windows.Forms.ControlEventHandler(this.panelTabExtra_ControlAdded);
|
||||
this.panelTabExtra.ControlRemoved += new System.Windows.Forms.ControlEventHandler(this.panelTabExtra_ControlRemoved);
|
||||
//
|
||||
// menuExtraField
|
||||
//
|
||||
this.menuExtraField.ImageScalingSize = new System.Drawing.Size(20, 20);
|
||||
@@ -834,22 +846,41 @@ namespace vCardEditor.View
|
||||
this.miNote,
|
||||
this.miOrg});
|
||||
this.menuExtraField.Name = "contextMenuStrip1";
|
||||
this.menuExtraField.Size = new System.Drawing.Size(211, 80);
|
||||
this.menuExtraField.Size = new System.Drawing.Size(164, 52);
|
||||
//
|
||||
// miNote
|
||||
//
|
||||
this.miNote.Name = "miNote";
|
||||
this.miNote.Size = new System.Drawing.Size(210, 24);
|
||||
this.miNote.Size = new System.Drawing.Size(163, 24);
|
||||
this.miNote.Text = "Note";
|
||||
this.miNote.Click += new System.EventHandler(this.miNote_Click);
|
||||
//
|
||||
// miOrg
|
||||
//
|
||||
this.miOrg.Name = "miOrg";
|
||||
this.miOrg.Size = new System.Drawing.Size(210, 24);
|
||||
this.miOrg.Size = new System.Drawing.Size(163, 24);
|
||||
this.miOrg.Text = "Organisation";
|
||||
this.miOrg.Click += new System.EventHandler(this.miOrg_Click);
|
||||
//
|
||||
// tbsSave
|
||||
//
|
||||
this.tbsSave.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
this.tbsSave.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.splitToFilesToolStripMenuItem});
|
||||
this.tbsSave.Image = ((System.Drawing.Image)(resources.GetObject("tbsSave.Image")));
|
||||
this.tbsSave.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.tbsSave.Name = "tbsSave";
|
||||
this.tbsSave.Size = new System.Drawing.Size(39, 24);
|
||||
this.tbsSave.Text = "&Save";
|
||||
this.tbsSave.ButtonClick += new System.EventHandler(this.tbsSave_Click);
|
||||
//
|
||||
// splitToFilesToolStripMenuItem
|
||||
//
|
||||
this.splitToFilesToolStripMenuItem.Name = "splitToFilesToolStripMenuItem";
|
||||
this.splitToFilesToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
|
||||
this.splitToFilesToolStripMenuItem.Text = "Split to files";
|
||||
this.splitToFilesToolStripMenuItem.Click += new System.EventHandler(this.splitToFilesToolStripMenuItem_Click);
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
this.AllowDrop = true;
|
||||
@@ -908,8 +939,6 @@ namespace vCardEditor.View
|
||||
private System.Windows.Forms.ToolStripMenuItem miAbout;
|
||||
private System.Windows.Forms.StatusStrip statusStrip1;
|
||||
private System.Windows.Forms.ToolStrip toolStrip1;
|
||||
private System.Windows.Forms.ToolStripButton tbsOpen;
|
||||
private System.Windows.Forms.ToolStripButton tbsSave;
|
||||
private System.Windows.Forms.ToolStripButton tbsDelete;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
|
||||
private System.Windows.Forms.ToolStripButton tbsAbout;
|
||||
@@ -944,8 +973,6 @@ namespace vCardEditor.View
|
||||
private System.Windows.Forms.ToolStripMenuItem extraFieldsToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem addNotesToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem addOrgToolStripMenuItem;
|
||||
private ExtendedPanel extendedPanelWeb;
|
||||
private ExtendedPanel extendedPanelPhones;
|
||||
private System.Windows.Forms.Button btnExportImage;
|
||||
private System.Windows.Forms.GroupBox groupBox3;
|
||||
internal StateTextBox FormattedTitleValue;
|
||||
@@ -970,5 +997,11 @@ namespace vCardEditor.View
|
||||
private System.Windows.Forms.ContextMenuStrip menuExtraField;
|
||||
private System.Windows.Forms.ToolStripMenuItem miNote;
|
||||
private System.Windows.Forms.ToolStripMenuItem miOrg;
|
||||
private ExtendedPanel extendedPanelWeb;
|
||||
private ExtendedPanel extendedPanelPhones;
|
||||
private System.Windows.Forms.ToolStripSplitButton tbsOpen;
|
||||
private System.Windows.Forms.ToolStripMenuItem openFolderToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripSplitButton tbsSave;
|
||||
private System.Windows.Forms.ToolStripMenuItem splitToFilesToolStripMenuItem;
|
||||
}
|
||||
}
|
||||
@@ -34,10 +34,19 @@ namespace vCardEditor.View
|
||||
public event EventHandler ExportImage;
|
||||
public event EventHandler ExportQR;
|
||||
public event EventHandler CopyTextToClipboardEvent;
|
||||
public event EventHandler CountImagesEvent;
|
||||
public event EventHandler ClearImagesEvent;
|
||||
public event EventHandler BatchExportImagesEvent;
|
||||
public event EventHandler<EventArg<string>> OpenFolderEvent;
|
||||
public event EventHandler SplitFileEvent;
|
||||
|
||||
|
||||
|
||||
|
||||
ComponentResourceManager resources;
|
||||
|
||||
|
||||
private int LastRowIndex = -1;
|
||||
|
||||
public int SelectedContactIndex
|
||||
{
|
||||
get
|
||||
@@ -50,13 +59,12 @@ namespace vCardEditor.View
|
||||
|
||||
}
|
||||
|
||||
|
||||
public MainForm()
|
||||
{
|
||||
this.extendedPanelWeb = new vCardEditor.View.Customs.ExtendedPanel(PanelType.Web);
|
||||
this.extendedPanelPhones = new vCardEditor.View.Customs.ExtendedPanel(PanelType.Phone);
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
|
||||
resources = new ComponentResourceManager(typeof(MainForm));
|
||||
tbcAddress.AddTab += (sender, e) => AddressAdded?.Invoke(sender, e);
|
||||
tbcAddress.RemoveTab += (sender, e) => AddressRemoved?.Invoke(sender, e);
|
||||
@@ -68,10 +76,21 @@ namespace vCardEditor.View
|
||||
BuildMRUMenu();
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void tbsOpen_Click(object sender, EventArgs e)
|
||||
{
|
||||
NewFileOpened?.Invoke(sender, new EventArg<string>(string.Empty));
|
||||
OpenFile(sender, string.Empty);
|
||||
}
|
||||
|
||||
|
||||
private void OpenFile(object sender, string filename)
|
||||
{
|
||||
var evt = new EventArg<string>(filename);
|
||||
|
||||
NewFileOpened?.Invoke(sender, new EventArg<string>(filename));
|
||||
|
||||
if (!evt.CanCancel)
|
||||
LastRowIndex = -1;
|
||||
}
|
||||
|
||||
public void DisplayContacts(SortableBindingList<Contact> contacts)
|
||||
@@ -83,6 +102,9 @@ namespace vCardEditor.View
|
||||
|
||||
private void tbsSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dgContacts.RowCount == 0)
|
||||
return;
|
||||
|
||||
if (SaveContactsSelected != null)
|
||||
{
|
||||
//make sure the last changes in the textboxes is saved.
|
||||
@@ -103,13 +125,25 @@ namespace vCardEditor.View
|
||||
|
||||
private void dgContacts_SelectionChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (ChangeContactsSelected != null && dgContacts.CurrentCell != null)
|
||||
if (dgContacts.CurrentCell == null)
|
||||
return;
|
||||
|
||||
|
||||
//Weired, the selection is fired multiple times...
|
||||
int RowIndex = dgContacts.CurrentCell.RowIndex;
|
||||
if (LastRowIndex != RowIndex)
|
||||
{
|
||||
vCard data = GetvCardFromWindow();
|
||||
ChangeContactsSelected(sender, new EventArg<vCard>(data));
|
||||
|
||||
if (ChangeContactsSelected != null && dgContacts.CurrentCell != null)
|
||||
{
|
||||
vCard data = GetvCardFromWindow();
|
||||
ChangeContactsSelected(sender, new EventArg<vCard>(data));
|
||||
}
|
||||
else
|
||||
ChangeContactsSelected(sender, new EventArg<vCard>(null));
|
||||
|
||||
LastRowIndex = RowIndex;
|
||||
}
|
||||
else
|
||||
ChangeContactsSelected(sender, new EventArg<vCard>(null));
|
||||
}
|
||||
|
||||
private void Value_TextChanged(object sender, EventArgs e)
|
||||
@@ -124,9 +158,9 @@ namespace vCardEditor.View
|
||||
throw new ArgumentException("vCard must be valid!");
|
||||
|
||||
ClearContactDetail();
|
||||
|
||||
|
||||
Text = string.Format("{0} - vCard Editor", FileName);
|
||||
//gbContactDetail.Enabled = true;
|
||||
|
||||
tcMainTab.Enabled = true;
|
||||
gbNameList.Enabled = true;
|
||||
|
||||
@@ -135,12 +169,11 @@ namespace vCardEditor.View
|
||||
SetSummaryValue(lastNameValue, card.FamilyName);
|
||||
SetSummaryValue(middleNameValue, card.AdditionalNames);
|
||||
SetSummaryValue(FormattedNameValue, card.FormattedName);
|
||||
|
||||
|
||||
SetAddressesValues(card);
|
||||
SetPhotoValue(card.Photos);
|
||||
|
||||
SetExtraInfos(card);
|
||||
|
||||
SetExtraTabFields(card);
|
||||
|
||||
}
|
||||
@@ -148,37 +181,28 @@ namespace vCardEditor.View
|
||||
private void SetExtraInfos(vCard card)
|
||||
{
|
||||
foreach (var item in card.EmailAddresses)
|
||||
{
|
||||
extendedPanelWeb.AddControl(item);
|
||||
}
|
||||
|
||||
foreach (var item in card.Websites)
|
||||
{
|
||||
extendedPanelWeb.AddControl(item);
|
||||
}
|
||||
|
||||
foreach (var item in card.Phones)
|
||||
{
|
||||
extendedPanelPhones.AddControl(item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private void SetExtraTabFields(vCard card)
|
||||
{
|
||||
if (card.Notes.Count > 0)
|
||||
{
|
||||
foreach (var note in card.Notes)
|
||||
AddExtraTextGroup(vCardPropeties.NOTE, note.Text);
|
||||
}
|
||||
foreach (var note in card.Notes)
|
||||
AddExtraTextGroup(vCardPropeties.NOTE, note.Text);
|
||||
|
||||
if (!string.IsNullOrEmpty(card.Organization))
|
||||
{
|
||||
AddExtraTextGroup(vCardPropeties.ORG, card.Organization);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void AddExtraTextGroup(vCardPropeties type, string content)
|
||||
@@ -201,7 +225,6 @@ namespace vCardEditor.View
|
||||
|
||||
public void ClearContactDetail()
|
||||
{
|
||||
//gbContactDetail.Enabled = false;
|
||||
tcMainTab.Enabled = false;
|
||||
gbNameList.Enabled = false;
|
||||
|
||||
@@ -211,9 +234,6 @@ namespace vCardEditor.View
|
||||
SetSummaryValue(FormattedTitleValue, string.Empty);
|
||||
SetSummaryValue(FormattedNameValue, string.Empty);
|
||||
|
||||
//SetAddressesValues(new vCard());
|
||||
|
||||
|
||||
SetPhotoValue(new vCardPhotoCollection());
|
||||
panelTabExtra.Controls.Clear();
|
||||
extendedPanelPhones.ClearFields();
|
||||
@@ -278,12 +298,15 @@ namespace vCardEditor.View
|
||||
{
|
||||
//Save before leaving contact.
|
||||
BeforeLeavingContact?.Invoke(sender, new EventArg<vCard>(GetvCardFromWindow()));
|
||||
|
||||
FilterTextChanged?.Invoke(sender, new EventArg<string>(textBoxFilter.Text));
|
||||
|
||||
LastRowIndex = -1;
|
||||
dgContacts.ClearSelection();
|
||||
textBoxFilter.Focus();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private vCard GetvCardFromWindow()
|
||||
{
|
||||
vCard card = new vCard
|
||||
@@ -309,7 +332,7 @@ namespace vCardEditor.View
|
||||
card.Phones.Clear();
|
||||
foreach (var item in extendedPanelPhones.GetExtraFields())
|
||||
{
|
||||
if (item is vCardPhone)
|
||||
if (item is vCardPhone)
|
||||
{
|
||||
vCardPhone phone = item as vCardPhone;
|
||||
card.Phones.Add(phone);
|
||||
@@ -342,7 +365,7 @@ namespace vCardEditor.View
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private void getExtraData(vCard card)
|
||||
{
|
||||
@@ -389,18 +412,15 @@ namespace vCardEditor.View
|
||||
return;
|
||||
}
|
||||
|
||||
NewFileOpened(sender, new EventArg<string>(FileList[0]));
|
||||
|
||||
OpenFile(sender, FileList[0]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void BuildMRUMenu()
|
||||
{
|
||||
recentFilesMenuItem.DropDownItemClicked += (s, e) =>
|
||||
{
|
||||
var evt = new EventArg<string>(e.ClickedItem.Text);
|
||||
NewFileOpened(s, evt);
|
||||
};
|
||||
|
||||
//TODO: Open File or Folder.
|
||||
recentFilesMenuItem.DropDownItemClicked += (s, e) => OpenFile(s, e.ClickedItem.Text);
|
||||
UpdateMRUMenu(ConfigRepository.Instance.Paths);
|
||||
|
||||
}
|
||||
@@ -446,7 +466,7 @@ namespace vCardEditor.View
|
||||
{
|
||||
MessageBox.Show(msg, caption);
|
||||
}
|
||||
public string DisplayOpenDialog(string filter = "")
|
||||
public string DisplayOpenFileDialog(string filter = "")
|
||||
{
|
||||
string filename = string.Empty;
|
||||
openFileDialog.Filter = filter;
|
||||
@@ -476,7 +496,7 @@ namespace vCardEditor.View
|
||||
{
|
||||
if (ModifyImage != null)
|
||||
{
|
||||
var fileName = DisplayOpenDialog();
|
||||
var fileName = DisplayOpenFileDialog();
|
||||
if (!string.IsNullOrEmpty(fileName))
|
||||
{
|
||||
try
|
||||
@@ -496,6 +516,11 @@ namespace vCardEditor.View
|
||||
|
||||
}
|
||||
|
||||
public void ClearImageFromForm()
|
||||
{
|
||||
PhotoBox.Image = (Image)resources.GetObject("PhotoBox.Image");
|
||||
}
|
||||
|
||||
private void btnRemoveImage_Click(object sender, EventArgs e)
|
||||
{
|
||||
PhotoBox.Image = (Image)resources.GetObject("PhotoBox.Image");
|
||||
@@ -518,6 +543,7 @@ namespace vCardEditor.View
|
||||
Clipboard.SetText(text);
|
||||
}
|
||||
|
||||
|
||||
private void dgContacts_CellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs e)
|
||||
{
|
||||
if (e.RowIndex == -1)
|
||||
@@ -659,5 +685,51 @@ namespace vCardEditor.View
|
||||
var evt = new EventArg<vCardPropeties>(vCardPropeties.ORG);
|
||||
AddExtraField?.Invoke(sender, evt);
|
||||
}
|
||||
|
||||
private void panelTabExtra_ControlAdded(object sender, ControlEventArgs e)
|
||||
{
|
||||
TapPageExtra.Text = string.Format("Extra ({0})", panelTabExtra.Controls.Count);
|
||||
}
|
||||
|
||||
private void panelTabExtra_ControlRemoved(object sender, ControlEventArgs e)
|
||||
{
|
||||
TapPageExtra.Text = string.Format("Extra ({0})", panelTabExtra.Controls.Count);
|
||||
}
|
||||
|
||||
private void countToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
CountImagesEvent?.Invoke(sender, e);
|
||||
}
|
||||
|
||||
private void clearToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
ClearImagesEvent?.Invoke(sender, e);
|
||||
}
|
||||
|
||||
private void exportToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
BatchExportImagesEvent?.Invoke(sender, e);
|
||||
}
|
||||
|
||||
private void openFolderToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var evt = new EventArg<string>(string.Empty);
|
||||
OpenFolderEvent?.Invoke(sender, evt);
|
||||
}
|
||||
|
||||
private void splitToFilesToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
SplitFileEvent?.Invoke(sender, e);
|
||||
}
|
||||
|
||||
public string DisplayOpenFolderDialog()
|
||||
{
|
||||
string result = string.Empty;
|
||||
FolderBrowserDialog dialog = new FolderBrowserDialog();
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
result = dialog.SelectedPath;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -339,6 +339,9 @@
|
||||
<metadata name="menuExtraField.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>804, 17</value>
|
||||
</metadata>
|
||||
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>25</value>
|
||||
</metadata>
|
||||
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
AAABAAkAAAAAAAEAIAAHLwAAlgAAAICAAAABACAAKAgBAJ0vAABgYAAAAQAgAKiUAADFNwEASEgAAAEA
|
||||
|
||||
@@ -95,5 +95,36 @@ namespace vCardEditor.View
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
//https://stackoverflow.com/questions/43331145/how-can-i-improve-performance-of-an-addrange-method-on-a-custom-bindinglist
|
||||
public void AddRange(IEnumerable<T> collection)
|
||||
{
|
||||
if (collection == null)
|
||||
throw new ArgumentNullException(nameof(collection));
|
||||
|
||||
// Remember the current setting for RaiseListChangedEvents
|
||||
// (if it was already deactivated, we shouldn't activate it after adding!).
|
||||
var oldRaiseEventsValue = RaiseListChangedEvents;
|
||||
|
||||
try
|
||||
{
|
||||
RaiseListChangedEvents = false;
|
||||
|
||||
foreach (var value in collection)
|
||||
Add(value);
|
||||
}
|
||||
// Restore the old setting for RaiseListChangedEvents (even if there was an exception),
|
||||
// and fire the ListChanged-event once (if RaiseListChangedEvents is activated).
|
||||
finally
|
||||
{
|
||||
RaiseListChangedEvents = oldRaiseEventsValue;
|
||||
|
||||
if (RaiseListChangedEvents)
|
||||
ResetBindings();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,51 +99,50 @@
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Repository\Interfaces\IFileHandler.cs" />
|
||||
<Compile Include="Thought.vCards\vCard.cs" />
|
||||
<Compile Include="Thought.vCards\vCardAccessClassification.cs" />
|
||||
<Compile Include="Thought.vCards\vCardCertificate.cs" />
|
||||
<Compile Include="Thought.vCards\vCardCertificateCollection.cs" />
|
||||
<Compile Include="Thought.vCards\vCardCollection.cs" />
|
||||
<Compile Include="Thought.vCards\vCardDeliveryAddress.cs" />
|
||||
<Compile Include="Thought.vCards\vCardDeliveryAddressCollection.cs" />
|
||||
<Compile Include="Thought.vCards\vCardDeliveryAddressTypes.cs" />
|
||||
<Compile Include="Thought.vCards\vCardDeliveryLabel.cs" />
|
||||
<Compile Include="Thought.vCards\vCardDeliveryLabelCollection.cs" />
|
||||
<Compile Include="Thought.vCards\vCardEmailAddress.cs" />
|
||||
<Compile Include="Thought.vCards\vCardEmailAddressCollection.cs" />
|
||||
<Compile Include="Thought.vCards\vCardEmailAddressType.cs" />
|
||||
<Compile Include="Thought.vCards\vCardEncoding.cs" />
|
||||
<Compile Include="Thought.vCards\vCardException.cs" />
|
||||
<Compile Include="Thought.vCards\vCardFormat.cs" />
|
||||
<Compile Include="Thought.vCards\vCardGender.cs" />
|
||||
<Compile Include="Thought.vCards\vCardIMPP.cs" />
|
||||
<Compile Include="Thought.vCards\vCardIMPPCollection.cs" />
|
||||
<Compile Include="Thought.vCards\vCardNote.cs" />
|
||||
<Compile Include="Thought.vCards\vCardNoteCollection.cs" />
|
||||
<Compile Include="Thought.vCards\vCardPhone.cs" />
|
||||
<Compile Include="Thought.vCards\vCardPhoneCollection.cs" />
|
||||
<Compile Include="Thought.vCards\vCardPhoneTypes.cs" />
|
||||
<Compile Include="Thought.vCards\vCardPhoto.cs" />
|
||||
<Compile Include="Thought.vCards\vCardPhotoCollection.cs" />
|
||||
<Compile Include="Thought.vCards\vCardProperty.cs" />
|
||||
<Compile Include="Thought.vCards\vCardPropertyCollection.cs" />
|
||||
<Compile Include="Thought.vCards\vCardReader.cs" />
|
||||
<Compile Include="Thought.vCards\vCardRoot.cs" />
|
||||
<Compile Include="Thought.vCards\vCardSocialProfile.cs" />
|
||||
<Compile Include="Thought.vCards\vCardSocialProfileCollection.cs" />
|
||||
<Compile Include="Thought.vCards\vCardSource.cs" />
|
||||
<Compile Include="Thought.vCards\vCardSourceCollection.cs" />
|
||||
<Compile Include="Thought.vCards\vCardStandardReader.cs" />
|
||||
<Compile Include="Thought.vCards\vCardStandardWriter.cs" />
|
||||
<Compile Include="Thought.vCards\vCardStandardWriterOptions.cs" />
|
||||
<Compile Include="Thought.vCards\vCardSubproperty.cs" />
|
||||
<Compile Include="Thought.vCards\vCardSubpropertyCollection.cs" />
|
||||
<Compile Include="Thought.vCards\vCardValueCollection.cs" />
|
||||
<Compile Include="Thought.vCards\vCardWebsite.cs" />
|
||||
<Compile Include="Thought.vCards\vCardWebsiteCollection.cs" />
|
||||
<Compile Include="Thought.vCards\vCardWebsiteTypes.cs" />
|
||||
<Compile Include="Thought.vCards\vCardWriter.cs" />
|
||||
<Compile Include="Thought.vCards\WarningMessages.Designer.cs" />
|
||||
<Compile Include="Libs\Thought.vCards\vCard.cs" />
|
||||
<Compile Include="Libs\Thought.vCards\vCardAccessClassification.cs" />
|
||||
<Compile Include="Libs\Thought.vCards\vCardCertificate.cs" />
|
||||
<Compile Include="Libs\Thought.vCards\vCardCertificateCollection.cs" />
|
||||
<Compile Include="Libs\Thought.vCards\vCardCollection.cs" />
|
||||
<Compile Include="Libs\Thought.vCards\vCardDeliveryAddress.cs" />
|
||||
<Compile Include="Libs\Thought.vCards\vCardDeliveryAddressCollection.cs" />
|
||||
<Compile Include="Libs\Thought.vCards\vCardDeliveryAddressTypes.cs" />
|
||||
<Compile Include="Libs\Thought.vCards\vCardDeliveryLabel.cs" />
|
||||
<Compile Include="Libs\Thought.vCards\vCardDeliveryLabelCollection.cs" />
|
||||
<Compile Include="Libs\Thought.vCards\vCardEmailAddress.cs" />
|
||||
<Compile Include="Libs\Thought.vCards\vCardEmailAddressCollection.cs" />
|
||||
<Compile Include="Libs\Thought.vCards\vCardEmailAddressType.cs" />
|
||||
<Compile Include="Libs\Thought.vCards\vCardEncoding.cs" />
|
||||
<Compile Include="Libs\Thought.vCards\vCardException.cs" />
|
||||
<Compile Include="Libs\Thought.vCards\vCardFormat.cs" />
|
||||
<Compile Include="Libs\Thought.vCards\vCardGender.cs" />
|
||||
<Compile Include="Libs\Thought.vCards\vCardIMPP.cs" />
|
||||
<Compile Include="Libs\Thought.vCards\vCardIMPPCollection.cs" />
|
||||
<Compile Include="Libs\Thought.vCards\vCardNote.cs" />
|
||||
<Compile Include="Libs\Thought.vCards\vCardNoteCollection.cs" />
|
||||
<Compile Include="Libs\Thought.vCards\vCardPhone.cs" />
|
||||
<Compile Include="Libs\Thought.vCards\vCardPhoneCollection.cs" />
|
||||
<Compile Include="Libs\Thought.vCards\vCardPhoneTypes.cs" />
|
||||
<Compile Include="Libs\Thought.vCards\vCardPhoto.cs" />
|
||||
<Compile Include="Libs\Thought.vCards\vCardPhotoCollection.cs" />
|
||||
<Compile Include="Libs\Thought.vCards\vCardProperty.cs" />
|
||||
<Compile Include="Libs\Thought.vCards\vCardPropertyCollection.cs" />
|
||||
<Compile Include="Libs\Thought.vCards\vCardReader.cs" />
|
||||
<Compile Include="Libs\Thought.vCards\vCardRoot.cs" />
|
||||
<Compile Include="Libs\Thought.vCards\vCardSocialProfile.cs" />
|
||||
<Compile Include="Libs\Thought.vCards\vCardSocialProfileCollection.cs" />
|
||||
<Compile Include="Libs\Thought.vCards\vCardSource.cs" />
|
||||
<Compile Include="Libs\Thought.vCards\vCardSourceCollection.cs" />
|
||||
<Compile Include="Libs\Thought.vCards\vCardStandardReader.cs" />
|
||||
<Compile Include="Libs\Thought.vCards\vCardStandardWriter.cs" />
|
||||
<Compile Include="Libs\Thought.vCards\vCardStandardWriterOptions.cs" />
|
||||
<Compile Include="Libs\Thought.vCards\vCardSubproperty.cs" />
|
||||
<Compile Include="Libs\Thought.vCards\vCardSubpropertyCollection.cs" />
|
||||
<Compile Include="Libs\Thought.vCards\vCardValueCollection.cs" />
|
||||
<Compile Include="Libs\Thought.vCards\vCardWebsite.cs" />
|
||||
<Compile Include="Libs\Thought.vCards\vCardWebsiteCollection.cs" />
|
||||
<Compile Include="Libs\Thought.vCards\vCardWebsiteTypes.cs" />
|
||||
<Compile Include="Libs\Thought.vCards\vCardWriter.cs" />
|
||||
<Compile Include="View\AboutDialog.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
@@ -211,7 +210,7 @@
|
||||
<DependentUpon>QRDialog.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="View\SortableBindingList.cs" />
|
||||
<Compile Include="View\StateTextBox.cs">
|
||||
<Compile Include="View\Customs\StateTextBox.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="View\Customs\ExtraTextGroup.cs">
|
||||
@@ -230,7 +229,6 @@
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
<DesignTime>True</DesignTime>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="Thought.vCards\WarningMessages.resx" />
|
||||
<EmbeddedResource Include="View\AboutDialog.resx">
|
||||
<DependentUpon>AboutDialog.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
|
||||
@@ -178,8 +178,7 @@ namespace vCardEditor_Test
|
||||
|
||||
repo.AddEmptyContact();
|
||||
|
||||
|
||||
Assert.IsTrue(repo.Contacts.Count == 0);
|
||||
Assert.IsTrue(repo.Contacts.Count == 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -259,6 +259,42 @@ namespace vCardEditor_Test
|
||||
Assert.IsTrue(repo.Contacts[0].isDirty);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void AddContact_ShouldCreateEmtptyContactFile_Test()
|
||||
{
|
||||
|
||||
var fileHandler = Substitute.For<IFileHandler>();
|
||||
var repo = Substitute.For<ContactRepository>(fileHandler);
|
||||
var view = Substitute.For<IMainView>();
|
||||
_ = new MainPresenter(view, repo);
|
||||
view.AddContact += Raise.Event();
|
||||
|
||||
view.Received().DisplayContacts(Arg.Any<SortableBindingList<Contact>>());
|
||||
Assert.IsTrue(repo.Contacts.Count == 1);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SaveSplittedFile_ShouldCall3TimesFileSaving_Test()
|
||||
{
|
||||
|
||||
var fileHandler = Substitute.For<IFileHandler>();
|
||||
fileHandler.ReadAllLines(Arg.Any<string>()).Returns(Entries.vcfFourEntry);
|
||||
fileHandler.FileExist(Arg.Any<string>()).Returns(true);
|
||||
|
||||
var repo = Substitute.For<ContactRepository>(fileHandler);
|
||||
|
||||
repo.LoadContacts("aaa.vcf");
|
||||
repo.Contacts[3].isDeleted = true;
|
||||
|
||||
var view = Substitute.For<IMainView>();
|
||||
view.DisplayOpenFolderDialog().Returns("aaa");
|
||||
_ = new MainPresenter(view, repo);
|
||||
view.SplitFileEvent += Raise.Event();
|
||||
|
||||
//Should save only 3 files.
|
||||
fileHandler.Received(3).WriteAllText(Arg.Any<string>(), Arg.Any<string>());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user