first working draft

This commit is contained in:
abdelkader
2023-04-14 12:07:42 -04:00
parent 437301d5bc
commit fe4c6381da
8 changed files with 601 additions and 453 deletions

View File

@@ -19,7 +19,7 @@ namespace vCardEditor.Properties {
// à 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.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
@@ -59,5 +59,25 @@ namespace vCardEditor.Properties {
resourceCulture = value;
}
}
/// <summary>
/// Recherche une ressource localisée de type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap Add {
get {
object obj = ResourceManager.GetObject("Add", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Recherche une ressource localisée de type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap Close {
get {
object obj = ResourceManager.GetObject("Close", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}

View File

@@ -117,4 +117,11 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="Add" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\assests\Add.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Close" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\assests\Close.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

View File

@@ -0,0 +1,91 @@
using System;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace vCardEditor.View.Customs
{
class AddressTabControl : TabControl
{
public AddressTabControl()
{
Padding = new Point(12, 4);
DrawMode = TabDrawMode.OwnerDrawFixed;
DrawItem += tbcAddress_DrawItem;
MouseDown += tbcAddress_MouseDown;
Selecting += tbcAddress_Selecting;
HandleCreated += tbcAddress_HandleCreated;
}
[DllImport("user32.dll")]
private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wp, IntPtr lp);
private const int TCM_SETMINTABWIDTH = 0x1300 + 49;
private void tbcAddress_HandleCreated(object sender, EventArgs e)
{
SendMessage(Handle, TCM_SETMINTABWIDTH, IntPtr.Zero, (IntPtr)16);
}
private void tbcAddress_Selecting(object sender, TabControlCancelEventArgs e)
{
if (e.TabPageIndex == TabCount - 1)
e.Cancel = true;
}
private void tbcAddress_MouseDown(object sender, MouseEventArgs e)
{
var lastIndex = TabCount - 1;
if (GetTabRect(lastIndex).Contains(e.Location))
{
TabPages.Insert(lastIndex, "New Tab");
SelectedIndex = lastIndex;
}
else
{
for (var i = 0; i < TabPages.Count; i++)
{
var tabRect = GetTabRect(i);
tabRect.Inflate(-2, -2);
var closeImage = Properties.Resources.Close;
var imageRect = new Rectangle(
(tabRect.Right - closeImage.Width),
tabRect.Top + (tabRect.Height - closeImage.Height) / 2,
closeImage.Width,
closeImage.Height);
if (imageRect.Contains(e.Location))
{
TabPages.RemoveAt(i);
break;
}
}
}
}
private void tbcAddress_DrawItem(object sender, DrawItemEventArgs e)
{
var tabPage = TabPages[e.Index];
var tabRect = GetTabRect(e.Index);
tabRect.Inflate(-2, -2);
if (e.Index == TabCount - 1)
{
var addImage = Properties.Resources.Add;
e.Graphics.DrawImage(addImage,
tabRect.Left + (tabRect.Width - addImage.Width) / 2,
tabRect.Top + (tabRect.Height - addImage.Height) / 2);
}
else
{
var closeImage = Properties.Resources.Close;
e.Graphics.DrawImage(closeImage,
(tabRect.Right - closeImage.Width),
tabRect.Top + (tabRect.Height - closeImage.Height) / 2);
TextRenderer.DrawText(e.Graphics, tabPage.Text, tabPage.Font,
tabRect, tabPage.ForeColor, TextFormatFlags.Left);
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -8,6 +8,7 @@ using Thought.vCards;
using vCardEditor.Repository;
using vCardEditor.Model;
using System.Drawing;
using System.Runtime.InteropServices;
namespace vCardEditor.View
{
@@ -48,15 +49,13 @@ namespace vCardEditor.View
BuildMRUMenu();
}
private void tbsOpen_Click(object sender, EventArgs e)
{
NewFileOpened?.Invoke(sender, new EventArg<string>(string.Empty));
}
public void DisplayContacts(BindingList<Contact> contacts)
{
@@ -81,7 +80,7 @@ namespace vCardEditor.View
AddContact?.Invoke(sender, e);
}
private void dgContacts_SelectionChanged(object sender, EventArgs e)
{
if (ChangeContactsSelected != null && dgContacts.CurrentCell != null)
@@ -263,7 +262,7 @@ namespace vCardEditor.View
PostalStateValue.Clear();
PostalCountryValue.Clear();
}
private void tbsDelete_Click(object sender, EventArgs e)
{
@@ -302,7 +301,7 @@ namespace vCardEditor.View
{
vCard card = new vCard
{
Title = FormattedTitleValue.Text,
FormattedName = FormattedNameValue.Text,
GivenName = firstNameValue.Text,
@@ -320,7 +319,7 @@ namespace vCardEditor.View
if (!string.IsNullOrEmpty(this.EmailAddressValue.Text))
card.EmailAddresses.Add(new vCardEmailAddress(this.EmailAddressValue.Text));
if (!string.IsNullOrEmpty(this.PersonalWebSiteValue.Text))
card.Websites.Add(new vCardWebsite(this.PersonalWebSiteValue.Text));
@@ -328,7 +327,7 @@ namespace vCardEditor.View
card.DeliveryAddresses.Add(new vCardDeliveryAddress(HomeAddressValue.Text, HomeCityValue.Text, HomeStateValue.Text, HomeCountryValue.Text,
HomePOBoxValue.Text, vCardDeliveryAddressTypes.Home));
if (!string.IsNullOrEmpty(this.WorkAddressValue.Text))
card.DeliveryAddresses.Add(new vCardDeliveryAddress(WorkAddressValue.Text, WorkCityValue.Text, WorkStateValue.Text, WorkCountryValue.Text,
WorkPOBoxValue.Text, vCardDeliveryAddressTypes.Work));
@@ -351,7 +350,7 @@ namespace vCardEditor.View
Close();
}
private void MainForm_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
@@ -377,7 +376,7 @@ namespace vCardEditor.View
var evt = new EventArg<string>(e.ClickedItem.Text);
NewFileOpened(s, evt);
};
UpdateMRUMenu(ConfigRepository.Instance.Paths);
}
@@ -390,7 +389,7 @@ namespace vCardEditor.View
recentFilesMenuItem.DropDownItems.Clear();
for (int i = 0; i < MostRecentFilesList._innerList.Count; i++)
recentFilesMenuItem.DropDownItems.Add(MostRecentFilesList[i]);
}
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
@@ -427,8 +426,8 @@ namespace vCardEditor.View
public string DisplayOpenDialog(string filter = "")
{
string filename = string.Empty;
openFileDialog.Filter = filter;
openFileDialog.Filter = filter;
DialogResult result = openFileDialog.ShowDialog();
if (result == DialogResult.OK)
filename = openFileDialog.FileName;
@@ -465,9 +464,9 @@ namespace vCardEditor.View
{
MessageBox.Show($"Invalid file! : {fileName}");
}
}
}
}
@@ -484,6 +483,6 @@ namespace vCardEditor.View
ExportImage?.Invoke(sender, e);
}
}
}

BIN
vCardEditor/assests/Add.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 437 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 605 B

View File

@@ -14,6 +14,21 @@
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -118,6 +133,9 @@
<Compile Include="View\ConfigDialog.Designer.cs">
<DependentUpon>ConfigDialog.cs</DependentUpon>
</Compile>
<Compile Include="View\Customs\AddressTabControl.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="View\EventArgs.cs" />
<Compile Include="View\IMainView.cs" />
<Compile Include="View\MainForm.cs">
@@ -162,9 +180,18 @@
</ItemGroup>
<ItemGroup>
<Content Include="assests\About.ico" />
<Content Include="assests\Add.png" />
<Content Include="assests\Close.png" />
<Content Include="assests\icons8-close-16.png" />
<Content Include="assests\vCard.ico" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.