B1.2 SQ2 finie
25
Contacts.sln
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30104.148
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Contacts", "Contacts\Contacts.csproj", "{7A989FF0-CB51-4312-B11C-5F8476E5A113}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{7A989FF0-CB51-4312-B11C-5F8476E5A113}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7A989FF0-CB51-4312-B11C-5F8476E5A113}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7A989FF0-CB51-4312-B11C-5F8476E5A113}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{7A989FF0-CB51-4312-B11C-5F8476E5A113}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {6BDD0F5B-A066-402D-BABE-A977D94B24AD}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
6
Contacts/App.config
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
||||
</startup>
|
||||
</configuration>
|
||||
117
Contacts/Contact.cs
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
namespace Contacts
|
||||
{
|
||||
/// <summary>
|
||||
/// Classe Contact
|
||||
/// mémorise les informations du contact
|
||||
/// </summary>
|
||||
[SerializableAttribute]
|
||||
public class Contact : IComparable
|
||||
// public class Contact
|
||||
{
|
||||
private string nom;
|
||||
private string prenom;
|
||||
private string tel;
|
||||
private Image photo;
|
||||
|
||||
/// <summary>
|
||||
/// Constructeur
|
||||
/// </summary>
|
||||
/// <param name="nom">nom</param>
|
||||
/// <param name="prenom">prénom</param>
|
||||
/// <param name="tel">téléphone</param>
|
||||
/// <param name="photo">photo</param>
|
||||
public Contact(string nom, string prenom, string tel, Image photo)
|
||||
{
|
||||
this.nom = nom;
|
||||
this.prenom = prenom;
|
||||
this.tel = tel;
|
||||
this.photo = photo;
|
||||
}
|
||||
/// <summary>
|
||||
/// Constructeur pour une entreprise
|
||||
/// </summary>
|
||||
/// <param name="nom">Nom de l'entreprise</param>
|
||||
/// <param name="tel">Numéro de téléphone de l'entreprise</param>
|
||||
/// <param name="photo">Photo de contact de l'entreprise</param>
|
||||
public Contact(string nom, string tel, Image photo)
|
||||
{
|
||||
this.nom = nom;
|
||||
this.tel = tel;
|
||||
this.photo = photo;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indique si une valeur est une entreprise ou non
|
||||
/// </summary>
|
||||
/// <returns>true si c'est une personne, false dans le cas contraire.</returns>
|
||||
public bool IsPersonne()
|
||||
{
|
||||
if(this.getPrenom() == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// getter sur nom
|
||||
/// </summary>
|
||||
/// <returns>nom</returns>
|
||||
public string getNom()
|
||||
{
|
||||
return this.nom;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// getter sur prenom
|
||||
/// </summary>
|
||||
/// <returns>prenom</returns>
|
||||
public string getPrenom()
|
||||
{
|
||||
return this.prenom;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// getter sur tel
|
||||
/// </summary>
|
||||
/// <returns>tel</returns>
|
||||
public string getTel()
|
||||
{
|
||||
return this.tel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// getter sur photo
|
||||
/// </summary>
|
||||
/// <returns>photo</returns>
|
||||
public Image getPhoto()
|
||||
{
|
||||
return this.photo;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// informations sur le contact
|
||||
/// </summary>
|
||||
/// <returns>nom + prenom + (tel)</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return this.nom + " " + this.prenom + " (" + this.tel + ")";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Comparaison des noms pour le tri
|
||||
/// </summary>
|
||||
/// <param name="obj">contact à comparer</param>
|
||||
/// <returns>comparaison sur le nom</returns>
|
||||
public int CompareTo(object obj)
|
||||
{
|
||||
return nom.CompareTo(((Contact)obj).getNom());
|
||||
}
|
||||
}
|
||||
}
|
||||
108
Contacts/Contacts.csproj
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{7A989FF0-CB51-4312-B11C-5F8476E5A113}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<RootNamespace>Contacts</RootNamespace>
|
||||
<AssemblyName>Contacts</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<DocumentationFile>bin\Debug\Contacts.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Contact.cs" />
|
||||
<Compile Include="FrmContacts.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="FrmContacts.Designer.cs">
|
||||
<DependentUpon>FrmContacts.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Serialise.cs" />
|
||||
<EmbeddedResource Include="FrmContacts.resx">
|
||||
<DependentUpon>FrmContacts.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\vide.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\modifier.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\supprimer.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\ajouter.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\annuler.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\playagain.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\standard.png" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
289
Contacts/FrmContacts.Designer.cs
generated
Normal file
|
|
@ -0,0 +1,289 @@
|
|||
namespace Contacts
|
||||
{
|
||||
partial class frmContacts
|
||||
{
|
||||
/// <summary>
|
||||
/// Variable nécessaire au concepteur.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Nettoyage des ressources utilisées.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true si les ressources managées doivent être supprimées ; sinon, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Code généré par le Concepteur Windows Form
|
||||
|
||||
/// <summary>
|
||||
/// Méthode requise pour la prise en charge du concepteur - ne modifiez pas
|
||||
/// le contenu de cette méthode avec l'éditeur de code.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.lblChoixPhoto = new System.Windows.Forms.Label();
|
||||
this.lstContact = new System.Windows.Forms.ListBox();
|
||||
this.grbAjout = new System.Windows.Forms.GroupBox();
|
||||
this.radioEntreprise = new System.Windows.Forms.RadioButton();
|
||||
this.radioPerso = new System.Windows.Forms.RadioButton();
|
||||
this.btnAnnuler = new System.Windows.Forms.Button();
|
||||
this.btnAjouter = new System.Windows.Forms.Button();
|
||||
this.txtTel = new System.Windows.Forms.TextBox();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.txtPrenom = new System.Windows.Forms.TextBox();
|
||||
this.lblPrenom = new System.Windows.Forms.Label();
|
||||
this.txtNom = new System.Windows.Forms.TextBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.btnNouveauContact = new System.Windows.Forms.Button();
|
||||
this.grbContacts = new System.Windows.Forms.GroupBox();
|
||||
this.btnSuppr = new System.Windows.Forms.Button();
|
||||
this.btnModif = new System.Windows.Forms.Button();
|
||||
this.imgPhoto = new System.Windows.Forms.PictureBox();
|
||||
this.grbAjout.SuspendLayout();
|
||||
this.grbContacts.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.imgPhoto)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// lblChoixPhoto
|
||||
//
|
||||
this.lblChoixPhoto.BackColor = System.Drawing.Color.Transparent;
|
||||
this.lblChoixPhoto.Enabled = false;
|
||||
this.lblChoixPhoto.Location = new System.Drawing.Point(31, 186);
|
||||
this.lblChoixPhoto.Name = "lblChoixPhoto";
|
||||
this.lblChoixPhoto.Size = new System.Drawing.Size(125, 32);
|
||||
this.lblChoixPhoto.TabIndex = 14;
|
||||
this.lblChoixPhoto.Text = "Cliquer pour sélectionner une photo";
|
||||
this.lblChoixPhoto.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.lblChoixPhoto.Visible = false;
|
||||
this.lblChoixPhoto.Click += new System.EventHandler(this.LblChoixPhoto_Click);
|
||||
//
|
||||
// lstContact
|
||||
//
|
||||
this.lstContact.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
|
||||
this.lstContact.FormattingEnabled = true;
|
||||
this.lstContact.HorizontalScrollbar = true;
|
||||
this.lstContact.Location = new System.Drawing.Point(6, 19);
|
||||
this.lstContact.Name = "lstContact";
|
||||
this.lstContact.Size = new System.Drawing.Size(318, 329);
|
||||
this.lstContact.TabIndex = 9;
|
||||
this.lstContact.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.lstContact_DrawItem);
|
||||
this.lstContact.SelectedIndexChanged += new System.EventHandler(this.LstContact_SelectedIndexChanged);
|
||||
//
|
||||
// grbAjout
|
||||
//
|
||||
this.grbAjout.Controls.Add(this.radioEntreprise);
|
||||
this.grbAjout.Controls.Add(this.radioPerso);
|
||||
this.grbAjout.Controls.Add(this.btnAnnuler);
|
||||
this.grbAjout.Controls.Add(this.btnAjouter);
|
||||
this.grbAjout.Controls.Add(this.txtTel);
|
||||
this.grbAjout.Controls.Add(this.label3);
|
||||
this.grbAjout.Controls.Add(this.txtPrenom);
|
||||
this.grbAjout.Controls.Add(this.lblPrenom);
|
||||
this.grbAjout.Controls.Add(this.txtNom);
|
||||
this.grbAjout.Controls.Add(this.label1);
|
||||
this.grbAjout.Location = new System.Drawing.Point(12, 265);
|
||||
this.grbAjout.Name = "grbAjout";
|
||||
this.grbAjout.Size = new System.Drawing.Size(170, 177);
|
||||
this.grbAjout.TabIndex = 8;
|
||||
this.grbAjout.TabStop = false;
|
||||
this.grbAjout.Text = "ajout contact";
|
||||
//
|
||||
// radioEntreprise
|
||||
//
|
||||
this.radioEntreprise.AutoSize = true;
|
||||
this.radioEntreprise.ForeColor = System.Drawing.Color.Green;
|
||||
this.radioEntreprise.Location = new System.Drawing.Point(98, 101);
|
||||
this.radioEntreprise.Name = "radioEntreprise";
|
||||
this.radioEntreprise.Size = new System.Drawing.Size(72, 17);
|
||||
this.radioEntreprise.TabIndex = 11;
|
||||
this.radioEntreprise.TabStop = true;
|
||||
this.radioEntreprise.Text = "Entreprise";
|
||||
this.radioEntreprise.UseVisualStyleBackColor = true;
|
||||
this.radioEntreprise.CheckedChanged += new System.EventHandler(this.radioEntreprise_CheckedChanged);
|
||||
//
|
||||
// radioPerso
|
||||
//
|
||||
this.radioPerso.AutoSize = true;
|
||||
this.radioPerso.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(192)))));
|
||||
this.radioPerso.Location = new System.Drawing.Point(22, 101);
|
||||
this.radioPerso.Name = "radioPerso";
|
||||
this.radioPerso.Size = new System.Drawing.Size(52, 17);
|
||||
this.radioPerso.TabIndex = 10;
|
||||
this.radioPerso.TabStop = true;
|
||||
this.radioPerso.Text = "Perso";
|
||||
this.radioPerso.UseVisualStyleBackColor = true;
|
||||
this.radioPerso.CheckedChanged += new System.EventHandler(this.radioPerso_CheckedChanged);
|
||||
//
|
||||
// btnAnnuler
|
||||
//
|
||||
this.btnAnnuler.Image = global::Contacts.Properties.Resources.annuler;
|
||||
this.btnAnnuler.Location = new System.Drawing.Point(115, 126);
|
||||
this.btnAnnuler.Name = "btnAnnuler";
|
||||
this.btnAnnuler.Size = new System.Drawing.Size(45, 45);
|
||||
this.btnAnnuler.TabIndex = 9;
|
||||
this.btnAnnuler.UseVisualStyleBackColor = true;
|
||||
this.btnAnnuler.Click += new System.EventHandler(this.BtnAnnuler_Click);
|
||||
//
|
||||
// btnAjouter
|
||||
//
|
||||
this.btnAjouter.Image = global::Contacts.Properties.Resources.ajouter;
|
||||
this.btnAjouter.Location = new System.Drawing.Point(54, 126);
|
||||
this.btnAjouter.Name = "btnAjouter";
|
||||
this.btnAjouter.Size = new System.Drawing.Size(45, 45);
|
||||
this.btnAjouter.TabIndex = 8;
|
||||
this.btnAjouter.UseVisualStyleBackColor = true;
|
||||
this.btnAjouter.Click += new System.EventHandler(this.BtnAjouter_Click);
|
||||
//
|
||||
// txtTel
|
||||
//
|
||||
this.txtTel.Location = new System.Drawing.Point(54, 75);
|
||||
this.txtTel.Name = "txtTel";
|
||||
this.txtTel.Size = new System.Drawing.Size(106, 20);
|
||||
this.txtTel.TabIndex = 7;
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(7, 78);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(18, 13);
|
||||
this.label3.TabIndex = 6;
|
||||
this.label3.Text = "tel";
|
||||
//
|
||||
// txtPrenom
|
||||
//
|
||||
this.txtPrenom.Location = new System.Drawing.Point(54, 49);
|
||||
this.txtPrenom.Name = "txtPrenom";
|
||||
this.txtPrenom.Size = new System.Drawing.Size(106, 20);
|
||||
this.txtPrenom.TabIndex = 5;
|
||||
//
|
||||
// lblPrenom
|
||||
//
|
||||
this.lblPrenom.AutoSize = true;
|
||||
this.lblPrenom.Location = new System.Drawing.Point(7, 52);
|
||||
this.lblPrenom.Name = "lblPrenom";
|
||||
this.lblPrenom.Size = new System.Drawing.Size(42, 13);
|
||||
this.lblPrenom.TabIndex = 4;
|
||||
this.lblPrenom.Text = "prénom";
|
||||
//
|
||||
// txtNom
|
||||
//
|
||||
this.txtNom.Location = new System.Drawing.Point(54, 23);
|
||||
this.txtNom.Name = "txtNom";
|
||||
this.txtNom.Size = new System.Drawing.Size(106, 20);
|
||||
this.txtNom.TabIndex = 3;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(7, 26);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(27, 13);
|
||||
this.label1.TabIndex = 0;
|
||||
this.label1.Text = "nom";
|
||||
//
|
||||
// btnNouveauContact
|
||||
//
|
||||
this.btnNouveauContact.Location = new System.Drawing.Point(12, 237);
|
||||
this.btnNouveauContact.Name = "btnNouveauContact";
|
||||
this.btnNouveauContact.Size = new System.Drawing.Size(169, 20);
|
||||
this.btnNouveauContact.TabIndex = 10;
|
||||
this.btnNouveauContact.Text = "nouveau contact";
|
||||
this.btnNouveauContact.UseVisualStyleBackColor = true;
|
||||
this.btnNouveauContact.Click += new System.EventHandler(this.btnNouveauContact_Click);
|
||||
//
|
||||
// grbContacts
|
||||
//
|
||||
this.grbContacts.Controls.Add(this.lstContact);
|
||||
this.grbContacts.Controls.Add(this.btnSuppr);
|
||||
this.grbContacts.Controls.Add(this.btnModif);
|
||||
this.grbContacts.Location = new System.Drawing.Point(188, 12);
|
||||
this.grbContacts.Name = "grbContacts";
|
||||
this.grbContacts.Size = new System.Drawing.Size(333, 430);
|
||||
this.grbContacts.TabIndex = 15;
|
||||
this.grbContacts.TabStop = false;
|
||||
this.grbContacts.Text = "les contacts";
|
||||
//
|
||||
// btnSuppr
|
||||
//
|
||||
this.btnSuppr.Image = global::Contacts.Properties.Resources.supprimer;
|
||||
this.btnSuppr.Location = new System.Drawing.Point(279, 354);
|
||||
this.btnSuppr.Name = "btnSuppr";
|
||||
this.btnSuppr.Size = new System.Drawing.Size(45, 45);
|
||||
this.btnSuppr.TabIndex = 10;
|
||||
this.btnSuppr.UseVisualStyleBackColor = true;
|
||||
this.btnSuppr.Click += new System.EventHandler(this.BtnSuppr_Click);
|
||||
//
|
||||
// btnModif
|
||||
//
|
||||
this.btnModif.Image = global::Contacts.Properties.Resources.modifier;
|
||||
this.btnModif.Location = new System.Drawing.Point(228, 354);
|
||||
this.btnModif.Name = "btnModif";
|
||||
this.btnModif.Size = new System.Drawing.Size(45, 45);
|
||||
this.btnModif.TabIndex = 11;
|
||||
this.btnModif.UseVisualStyleBackColor = true;
|
||||
this.btnModif.Click += new System.EventHandler(this.BtnModif_Click);
|
||||
//
|
||||
// imgPhoto
|
||||
//
|
||||
this.imgPhoto.Enabled = false;
|
||||
this.imgPhoto.Image = global::Contacts.Properties.Resources.vide;
|
||||
this.imgPhoto.Location = new System.Drawing.Point(12, 31);
|
||||
this.imgPhoto.Name = "imgPhoto";
|
||||
this.imgPhoto.Size = new System.Drawing.Size(170, 200);
|
||||
this.imgPhoto.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
|
||||
this.imgPhoto.TabIndex = 13;
|
||||
this.imgPhoto.TabStop = false;
|
||||
this.imgPhoto.Click += new System.EventHandler(this.ImgPhoto_Click);
|
||||
//
|
||||
// frmContacts
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(531, 454);
|
||||
this.Controls.Add(this.grbContacts);
|
||||
this.Controls.Add(this.btnNouveauContact);
|
||||
this.Controls.Add(this.lblChoixPhoto);
|
||||
this.Controls.Add(this.imgPhoto);
|
||||
this.Controls.Add(this.grbAjout);
|
||||
this.Name = "frmContacts";
|
||||
this.Text = "Contacts";
|
||||
this.Load += new System.EventHandler(this.FrmContacts_Load);
|
||||
this.grbAjout.ResumeLayout(false);
|
||||
this.grbAjout.PerformLayout();
|
||||
this.grbContacts.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.imgPhoto)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Label lblChoixPhoto;
|
||||
private System.Windows.Forms.PictureBox imgPhoto;
|
||||
private System.Windows.Forms.ListBox lstContact;
|
||||
private System.Windows.Forms.Button btnModif;
|
||||
private System.Windows.Forms.Button btnSuppr;
|
||||
private System.Windows.Forms.GroupBox grbAjout;
|
||||
private System.Windows.Forms.Button btnAnnuler;
|
||||
private System.Windows.Forms.Button btnAjouter;
|
||||
private System.Windows.Forms.TextBox txtTel;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.TextBox txtPrenom;
|
||||
private System.Windows.Forms.Label lblPrenom;
|
||||
private System.Windows.Forms.TextBox txtNom;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Button btnNouveauContact;
|
||||
private System.Windows.Forms.GroupBox grbContacts;
|
||||
private System.Windows.Forms.RadioButton radioEntreprise;
|
||||
private System.Windows.Forms.RadioButton radioPerso;
|
||||
}
|
||||
}
|
||||
|
||||
383
Contacts/FrmContacts.cs
Normal file
|
|
@ -0,0 +1,383 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Contacts
|
||||
{
|
||||
/// <summary>
|
||||
/// Classe frmContacts
|
||||
/// Formulaire des contacts
|
||||
/// </summary>
|
||||
public partial class frmContacts : Form
|
||||
{
|
||||
// liste des contacts
|
||||
private List<Contact> lesContacts = new List<Contact>();
|
||||
// nom du fichier de sérialisation
|
||||
private string fichier = "ficcontact";
|
||||
|
||||
/// <summary>
|
||||
/// Constructeur
|
||||
/// </summary>
|
||||
public frmContacts()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Préparer l'ajout en gérant les objets graphiques
|
||||
/// </summary>
|
||||
private void DebutAjout()
|
||||
{
|
||||
// Gérer les accès aux objets graphiques
|
||||
grbAjout.Enabled = true;
|
||||
grbContacts.Enabled = false;
|
||||
imgPhoto.Enabled = true;
|
||||
btnNouveauContact.Enabled = false;
|
||||
lblChoixPhoto.Visible = true;
|
||||
// désactiver la ligne sélectionnée dans la liste
|
||||
lstContact.SelectedIndex = -1;
|
||||
// affiche la photo standard
|
||||
AffichePhotoStandard();
|
||||
// se positionner sur le nom
|
||||
txtNom.Focus();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Préparer l'après ajout en gérant les objets graphiques
|
||||
/// </summary>
|
||||
private void FinAjout()
|
||||
{
|
||||
// Gérer les accès aux objets graphiques
|
||||
grbAjout.Enabled = false;
|
||||
grbContacts.Enabled = true;
|
||||
imgPhoto.Enabled = false;
|
||||
btnNouveauContact.Enabled = true;
|
||||
lblChoixPhoto.Visible = false;
|
||||
// vider les zones de saisie
|
||||
txtNom.Text = "";
|
||||
txtPrenom.Text = "";
|
||||
txtTel.Text = "";
|
||||
// se positoinner sur la liste
|
||||
lstContact.Focus();
|
||||
radioPerso.Checked = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// se positionner sur la ligne demandée en paramètre ou la 1e ligne si la liste n'est pas vide
|
||||
/// </summary>
|
||||
/// <param name="ligne">ligne à sélectionner</param>
|
||||
private void PositionDansListe(String ligne)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (ligne != null)
|
||||
{
|
||||
int index = lstContact.FindStringExact(ligne);
|
||||
lstContact.SelectedIndex = index;
|
||||
}
|
||||
else
|
||||
{
|
||||
lstContact.SelectedIndex = 0;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
lstContact.SelectedIndex = -1;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Mettre à jour la listbox avec tous les contacts
|
||||
/// et si demandé, se positionner sur la ligne reçue en paramètre
|
||||
/// </summary>
|
||||
/// <param name="ligne">ligne à sélectionner</param>
|
||||
private void MajListBox(String ligne)
|
||||
{
|
||||
// trier la liste
|
||||
lesContacts.Sort();
|
||||
// lier la ListBox avec lesContacts pour la remplir
|
||||
BindingList<Contact> bdlContacts = new BindingList<Contact>(lesContacts);
|
||||
lstContact.DataSource = bdlContacts;
|
||||
// si le dictionnaire est vide, mettre la photo vide
|
||||
if (lesContacts.Count == 0)
|
||||
{
|
||||
VidePhoto();
|
||||
}
|
||||
// sauver la liste dans le fichier
|
||||
Serialise.Sauve(fichier, lesContacts);
|
||||
// se positionner sur la ligne demandée en paramètre ou la 1e ligne si la liste n'est pas vide
|
||||
PositionDansListe(ligne);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Vider l'affichage de la photo (afficher une photo blanche)
|
||||
/// </summary>
|
||||
private void VidePhoto()
|
||||
{
|
||||
imgPhoto.Image = Properties.Resources.vide;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Afficher la photo standard
|
||||
/// </summary>
|
||||
private void AffichePhotoStandard()
|
||||
{
|
||||
imgPhoto.Image = Properties.Resources.standard;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Supprimer le contact donc l'index est reçu en paramètre
|
||||
/// </summary>
|
||||
/// <param name="index">index du contact à supprimer</param>
|
||||
private void SupprContact(int index)
|
||||
{
|
||||
if (index != -1)
|
||||
{
|
||||
lesContacts.RemoveAt(index);
|
||||
MajListBox(null);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Evénement Click sur le bouton bntSuppr
|
||||
/// Supprimer le contact sélectionné
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void BtnSuppr_Click(object sender, EventArgs e)
|
||||
{
|
||||
// contrôler qu'une ligne est bien sélectionnée
|
||||
if (lstContact.SelectedIndex != -1)
|
||||
{
|
||||
// demander une confirmation de suppression
|
||||
if (MessageBox.Show("Supprimer le contact ?", "Confirmation", MessageBoxButtons.OKCancel) == DialogResult.OK)
|
||||
{
|
||||
// supprimer le contact sélectionné
|
||||
SupprContact(lstContact.SelectedIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Evénement sélection d'un contact dans la lstContact
|
||||
/// Charger la photo
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void LstContact_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
// si une ligne est sélectionnée
|
||||
if (lstContact.SelectedIndex != -1)
|
||||
{
|
||||
Contact leContact = lesContacts[lstContact.SelectedIndex];
|
||||
// afficher l'image
|
||||
imgPhoto.Image = leContact.getPhoto();
|
||||
}
|
||||
else
|
||||
{
|
||||
// affiche une image vide
|
||||
VidePhoto();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Evénement clic sur bouton btnAjouter
|
||||
/// Ajouter le contact dans la liste
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void BtnAjouter_Click(object sender, EventArgs e)
|
||||
{
|
||||
// vérifier que le nom, prénom et tel ne sont pas vides
|
||||
if (!txtNom.Text.Equals("") && !txtTel.Text.Equals("") && !txtPrenom.Text.Equals("") || radioEntreprise.Checked)
|
||||
{
|
||||
// créer le contact et l'ajouter dans la collection
|
||||
Contact nouveauContact;
|
||||
if (radioPerso.Checked)
|
||||
{
|
||||
nouveauContact = new Contact(txtNom.Text.ToUpper(), txtPrenom.Text, txtTel.Text, imgPhoto.Image);
|
||||
}
|
||||
else
|
||||
{
|
||||
nouveauContact = new Contact(txtNom.Text.ToUpper(), txtTel.Text, imgPhoto.Image);
|
||||
}
|
||||
lesContacts.Add(nouveauContact);
|
||||
// mettre à jour de la ListBox
|
||||
MajListBox(nouveauContact.ToString());
|
||||
// gérer la fin de l'ajout au niveau des objets graphiques
|
||||
FinAjout();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Toutes les zones sont obligatoires");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Evénement clic sur le bouton btnModif
|
||||
/// Supprimer le contact et transférer ces informations dans la zone d'ajout
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void BtnModif_Click(object sender, EventArgs e)
|
||||
{
|
||||
// contrôler si un contact est sélectionné
|
||||
if (lstContact.SelectedIndex != -1)
|
||||
{
|
||||
// récupérer l'index du contact
|
||||
int index = lstContact.SelectedIndex;
|
||||
// récupérer le contact concerné
|
||||
Contact leContact = lesContacts[index];
|
||||
// supprimer le contact
|
||||
SupprContact(index);
|
||||
// remplir les zones d'ajout avec les informations du contact
|
||||
txtNom.Text = leContact.getNom();
|
||||
txtPrenom.Text = leContact.getPrenom();
|
||||
txtTel.Text = leContact.getTel();
|
||||
// gérer le début de l'ajout au niveau des objets graphiques
|
||||
DebutAjout();
|
||||
// mettre la photo du contact
|
||||
imgPhoto.Image = leContact.getPhoto();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Evénement chargement de frmContacts
|
||||
/// Préparer les composants et récupérer la sérialisation
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void FrmContacts_Load(object sender, EventArgs e)
|
||||
{
|
||||
// préparer les composants graphiques comme pour la fin d'un ajout
|
||||
FinAjout();
|
||||
// récupérer la sauvegarde des contacts, si elle existe
|
||||
Object recupContacts = Serialise.Recup(fichier);
|
||||
if (recupContacts != null)
|
||||
{
|
||||
lesContacts = (List<Contact>)recupContacts;
|
||||
// remplir de la listbox avec les contacts récupérés
|
||||
MajListBox(null);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Evénement Click sur le bouton btnAnnuler
|
||||
/// Annuler la tentative d'ajout
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void BtnAnnuler_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (MessageBox.Show("Attention les informations seront perdues.", "Confirmation", MessageBoxButtons.OKCancel) == DialogResult.OK)
|
||||
{
|
||||
// gérer la fin de l'ajout au niveau des objets graphiques
|
||||
FinAjout();
|
||||
// mettre à jour la listbox
|
||||
MajListBox(null);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Evénement Click sur la photo
|
||||
/// possibilité de sélectionner une photo
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ImgPhoto_Click(object sender, EventArgs e)
|
||||
{
|
||||
// boite de dialogue pour sélectionner un fichier
|
||||
OpenFileDialog rechercheFichier;
|
||||
rechercheFichier = new OpenFileDialog();
|
||||
DialogResult choix = rechercheFichier.ShowDialog();
|
||||
// si un fichier est sélectionné
|
||||
if (choix == DialogResult.OK)
|
||||
{
|
||||
// récupérer le fichier
|
||||
string nomFichier = rechercheFichier.FileName;
|
||||
// tente d'afficher l'image
|
||||
try
|
||||
{
|
||||
imgPhoto.Image = Image.FromFile(nomFichier);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// erreur le fichier n'est pas une image
|
||||
MessageBox.Show("Le fichier n'est pas une image");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Evénement Click sur le label lblChoixPhoto
|
||||
/// mêmes traitements que le clic sur la photo
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void LblChoixPhoto_Click(object sender, EventArgs e)
|
||||
{
|
||||
ImgPhoto_Click(null, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Evénement Click sur le bouton btnNouveauContact
|
||||
/// Permettre d'ajouter un contact
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void btnNouveauContact_Click(object sender, EventArgs e)
|
||||
{
|
||||
DebutAjout();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Evenement lorsque radioPerso est sélectionné
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void radioPerso_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
ChangeTypeContact();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Active/Désactive txtPrenom et lblPrenom selon le choix de l'utilisateur
|
||||
/// </summary>
|
||||
private void ChangeTypeContact()
|
||||
{
|
||||
lblPrenom.Visible = radioPerso.Checked;
|
||||
txtPrenom.Visible = radioPerso.Checked;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Evenement lorsque radioEntreprise est sélectionné
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void radioEntreprise_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
ChangeTypeContact();
|
||||
}
|
||||
|
||||
private void lstContact_DrawItem(object sender, DrawItemEventArgs e)
|
||||
{
|
||||
//Récupérer la couleur du radio correspondant
|
||||
Color couleur;
|
||||
e.DrawBackground();
|
||||
Contact leContacts = lesContacts[e.Index];
|
||||
if (leContacts.IsPersonne())
|
||||
{
|
||||
couleur = radioPerso.ForeColor;
|
||||
}else
|
||||
{
|
||||
couleur = radioEntreprise.ForeColor;
|
||||
}
|
||||
Brush brush = new SolidBrush(couleur);
|
||||
|
||||
e.Graphics.DrawString(lstContact.Items[e.Index].ToString(),
|
||||
e.Font, brush, e.Bounds, StringFormat.GenericDefault);
|
||||
}
|
||||
}
|
||||
}
|
||||
120
Contacts/FrmContacts.resx
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
22
Contacts/Program.cs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Contacts
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// Point d'entrée principal de l'application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new frmContacts());
|
||||
}
|
||||
}
|
||||
}
|
||||
36
Contacts/Properties/AssemblyInfo.cs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// Les informations générales relatives à un assembly dépendent de
|
||||
// l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations
|
||||
// associées à un assembly.
|
||||
[assembly: AssemblyTitle("Contacts")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Contacts")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2020")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly
|
||||
// aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de
|
||||
// COM, affectez la valeur true à l'attribut ComVisible sur ce type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM
|
||||
[assembly: Guid("7a989ff0-cb51-4312-b11c-5f8476e5a113")]
|
||||
|
||||
// Les informations de version pour un assembly se composent des quatre valeurs suivantes :
|
||||
//
|
||||
// Version principale
|
||||
// Version secondaire
|
||||
// Numéro de build
|
||||
// Révision
|
||||
//
|
||||
// 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("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
133
Contacts/Properties/Resources.Designer.cs
generated
Normal file
|
|
@ -0,0 +1,133 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Ce code a été généré par un outil.
|
||||
// Version du runtime :4.0.30319.42000
|
||||
//
|
||||
// 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 Contacts.Properties {
|
||||
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", "16.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <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("Contacts.Properties.Resources", typeof(Resources).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 ressource localisée de type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap ajouter {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("ajouter", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recherche une ressource localisée de type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap annuler {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("annuler", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recherche une ressource localisée de type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap modifier {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("modifier", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recherche une ressource localisée de type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap playagain {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("playagain", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recherche une ressource localisée de type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap standard {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("standard", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recherche une ressource localisée de type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap supprimer {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("supprimer", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recherche une ressource localisée de type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap vide {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("vide", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
142
Contacts/Properties/Resources.resx
Normal file
|
|
@ -0,0 +1,142 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="modifier" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\modifier.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="annuler" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\annuler.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="playagain" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\playagain.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="ajouter" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\ajouter.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="vide" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\vide.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="supprimer" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\supprimer.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="standard" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\standard.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
||||
30
Contacts/Properties/Settings.Designer.cs
generated
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Contacts.Properties
|
||||
{
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
|
||||
{
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default
|
||||
{
|
||||
get
|
||||
{
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
7
Contacts/Properties/Settings.settings
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
||||
BIN
Contacts/Resources/ajouter.png
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
Contacts/Resources/annuler.png
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
BIN
Contacts/Resources/modifier.png
Normal file
|
After Width: | Height: | Size: 4.2 KiB |
BIN
Contacts/Resources/playagain.png
Normal file
|
After Width: | Height: | Size: 4.8 KiB |
BIN
Contacts/Resources/standard.png
Normal file
|
After Width: | Height: | Size: 6 KiB |
BIN
Contacts/Resources/supprimer.png
Normal file
|
After Width: | Height: | Size: 5.1 KiB |
BIN
Contacts/Resources/vide.png
Normal file
|
After Width: | Height: | Size: 664 B |
69
Contacts/Serialise.cs
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
|
||||
namespace Contacts
|
||||
{
|
||||
/// <summary>
|
||||
/// Classe Sérialise
|
||||
/// Permet de sauvegarder en binaire et récupérer des objets
|
||||
/// </summary>
|
||||
public abstract class Serialise
|
||||
{
|
||||
/// <summary>
|
||||
/// Sérialisation
|
||||
/// </summary>
|
||||
/// <param name="fichier">nom du fichier de sauvegarde</param>
|
||||
/// <param name="objet">objet à sérialiser</param>
|
||||
public static void Sauve(string fichier, Object objet)
|
||||
{
|
||||
// si le fichier existe, il faut le supprimer
|
||||
if (File.Exists(fichier))
|
||||
{
|
||||
File.Delete(fichier);
|
||||
}
|
||||
// création du flux pour l'écriture dans le fichier
|
||||
FileStream flux = new FileStream(fichier, FileMode.Create);
|
||||
// création d'un objet pour le formatage en binaire des informations
|
||||
BinaryFormatter fbinaire = new BinaryFormatter();
|
||||
// sérialisation des objets de la collection
|
||||
fbinaire.Serialize(flux, objet);
|
||||
// fermeture du flux
|
||||
flux.Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Désérialisation
|
||||
/// </summary>
|
||||
/// <param name="fichier">nom du fichier de sauvegarde</param>
|
||||
/// <returns>objet désérialisé</returns>
|
||||
public static Object Recup(string fichier)
|
||||
{
|
||||
// Contrôle de l'existance du fichier
|
||||
if (File.Exists(fichier))
|
||||
{
|
||||
// ouverture du flux pour la lecture dans le fichier
|
||||
FileStream flux = new FileStream(fichier, FileMode.Open);
|
||||
// création d'un objet pour le formatage en binaire des informations
|
||||
BinaryFormatter fbinaire = new BinaryFormatter();
|
||||
// récupération de l'objet sérialisé
|
||||
try
|
||||
{
|
||||
Object objet = fbinaire.Deserialize(flux);
|
||||
// fermeture du flux
|
||||
flux.Close();
|
||||
// retour de l'objet
|
||||
return objet;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||