From 911b3fc819be11a909c4d68d9cb9c8105cdac5dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miskolczi=20Rich=C3=A1rd?= Date: Fri, 24 Mar 2023 11:14:49 +0100 Subject: [PATCH] Adding Profile and ProfileList class --- .gitignore | 2 +- .vs/Password Manager/v17/.suo | Bin 26112 -> 26112 bytes Password Manager/Form1.Designer.cs | 49 +++++++++----- Password Manager/Form1.cs | 14 +++- .../{Password_Store.cs => Profile.cs} | 2 +- Password Manager/ProfileList.cs | 62 ++++++++++++++++++ Password Manager/Program.cs | 10 +-- 7 files changed, 109 insertions(+), 30 deletions(-) rename Password Manager/{Password_Store.cs => Profile.cs} (92%) create mode 100644 Password Manager/ProfileList.cs diff --git a/.gitignore b/.gitignore index 8b27cdc..defecbd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ Password\ Manager/bin Password\ Manager/obj -.vs +.vs/ diff --git a/.vs/Password Manager/v17/.suo b/.vs/Password Manager/v17/.suo index 5752c4703b35ad16bcdc79a9064dcccf5e1c6527..65fd6d039bc92a4932dda1bfad3a79ff9487f3df 100644 GIT binary patch delta 1069 zcmaKrZAep57{|}K-l^s8oSWvRYi83hE!)bbz4^jKq6w)4X*PAKSYcFZ&D0MQi);>w zd%j50+cGfw63!%{LUM?NB-JOOcOe2(BHagj*?P|19gLDL{O@zlbN=Ufe)pbx?bFyk zjUO~JvRh5#S=m*yH~}G)uO@9w8?JMEnJA1S31$;3q988^DM3EJ-@g_j1mTJi$8iwj z#jy;c8ngzK2~vR~K)etM! zMOTwoT@~HOAl8D@=8`eI#zQ=e-o31mVwk#O8D5=&caUTzk>smc;tAJFEZ~1eR#X|- z7|1KKBv#0clTxLb6e=I{3KNIv^KOPLjj)hHT2wO}N`s6(Br7R}$&^rRXRwKs9s)g# z;8w{Im^>9sA_;U1P>3B#jk3_~QSW7j6DDvNHXtG^&E(5je2A>X9QYs1w$MJS!BATI z?*E2~HcRPVUC0t?ksss)GySB38{Ersc$Xo#8i5 z5L4_vmk#qKZ??xTmib10evCcS(Oz>kZ$51IY|qR3a;~?m|Mq>`y`@2@A#|ag1{j2{ zMG%?gyGzgVX?EOA3Q8`e)}m&#uu{Bmvw61AIXO0#V|i}S>ZT^Ye(rG&bq_T} zf9TJ4+z17sFn+(w$TD#5j5b%ks5zW8W|?_idD&b|{9V2DV{o@KIYAQ^Uci8+xi~V_u%a#;mB(* ze=Xko4#y3{_;L)l#1`Dq2O*;cOj=Xt-{$TEcBi}D|D}xyfo?!+3Tm=GsFmf8~QOZlIJ6z$y z1Vz$>q&N3U4$sGT?mafR|I>Ri>AgT~nNT4t5_<1~OVG?zVUoXt58GSB+$OAZ#!m3M znRy8KJo{wlfg3qOooQQViQx^g0)u=>cTQQL3O=?(1;auEH}X}i=08O_!HPe`z6~tp z;Sy;oAm=L;S=H_06`^EXcm_HP^SUD~XnH=NfBCbLEgQW5r2Pyv+d_YK6Q}2XL?u%# z)#Xojed^=p{=kb3cC8W8o*Zh6;Y1@kCn8t;E${}f=a#i7_YNt~NB_i4 zy}kSxqKl?-CCbuyyFWDl70K`zmTDHSeQG$^p&-BD%y2NAsbO1`Qz;6X*e%}RUFp!R UL4TY4u1Qt3VZxg3ULEy*1DiwV=l}o! diff --git a/Password Manager/Form1.Designer.cs b/Password Manager/Form1.Designer.cs index 6531c6b..4cd56c2 100644 --- a/Password Manager/Form1.Designer.cs +++ b/Password Manager/Form1.Designer.cs @@ -1,6 +1,6 @@ namespace Password_Manager { - partial class Form1 + partial class MainForm { /// /// Required designer variable. @@ -28,34 +28,46 @@ /// private void InitializeComponent() { - textBox1 = new TextBox(); - listBox1 = new ListBox(); + searchBox = new TextBox(); + resultList = new ListBox(); + profileSelection = new ComboBox(); SuspendLayout(); // // textBox1 // - textBox1.Location = new Point(23, 27); - textBox1.Name = "textBox1"; - textBox1.PlaceholderText = "Search for a password"; - textBox1.Size = new Size(257, 27); - textBox1.TabIndex = 0; + searchBox.Location = new Point(12, 27); + searchBox.Name = "textBox1"; + searchBox.PlaceholderText = "Search for a password"; + searchBox.Size = new Size(257, 27); + searchBox.TabIndex = 0; + searchBox.TextChanged += UpdateResultList; // // listBox1 // - listBox1.FormattingEnabled = true; - listBox1.ItemHeight = 20; - listBox1.Location = new Point(23, 99); - listBox1.Name = "listBox1"; - listBox1.Size = new Size(150, 104); - listBox1.TabIndex = 1; + resultList.FormattingEnabled = true; + resultList.ItemHeight = 20; + resultList.Location = new Point(12, 99); + resultList.Name = "listBox1"; + resultList.Size = new Size(150, 104); + resultList.TabIndex = 1; + // + // comboBox1 + // + profileSelection.FormattingEnabled = true; + profileSelection.Location = new Point(637, 26); + profileSelection.Name = "comboBox1"; + profileSelection.Size = new Size(151, 28); + profileSelection.TabIndex = 2; + profileSelection.SelectedIndexChanged += ChangeProfile; // // Form1 // AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleMode = AutoScaleMode.Font; ClientSize = new Size(800, 450); - Controls.Add(listBox1); - Controls.Add(textBox1); + Controls.Add(profileSelection); + Controls.Add(resultList); + Controls.Add(searchBox); Name = "Form1"; Text = "Form1"; ResumeLayout(false); @@ -64,7 +76,8 @@ #endregion - private TextBox textBox1; - private ListBox listBox1; + private TextBox searchBox; + private ListBox resultList; + private ComboBox profileSelection; } } \ No newline at end of file diff --git a/Password Manager/Form1.cs b/Password Manager/Form1.cs index 87f1a45..8a55f13 100644 --- a/Password Manager/Form1.cs +++ b/Password Manager/Form1.cs @@ -1,10 +1,20 @@ namespace Password_Manager { - public partial class Form1 : Form + public partial class MainForm : Form { - public Form1() + public MainForm() { InitializeComponent(); } + + private void ChangeProfile(object sender, EventArgs e) + { + + } + + private void UpdateResultList(object sender, EventArgs args) + { + + } } } \ No newline at end of file diff --git a/Password Manager/Password_Store.cs b/Password Manager/Profile.cs similarity index 92% rename from Password Manager/Password_Store.cs rename to Password Manager/Profile.cs index 3b915bd..43a591e 100644 --- a/Password Manager/Password_Store.cs +++ b/Password Manager/Profile.cs @@ -4,7 +4,7 @@ namespace Password_Manager { public delegate void PasswordStoreChange(); - sealed class Password_Store + sealed class Profile { public string Name { get; } //the name of the password store profile ("personal", "work", or similar) public string Path { get; } //path of the folder containing the password store diff --git a/Password Manager/ProfileList.cs b/Password Manager/ProfileList.cs new file mode 100644 index 0000000..597c120 --- /dev/null +++ b/Password Manager/ProfileList.cs @@ -0,0 +1,62 @@ +using System; + +namespace Password_Manager +{ + sealed class ProfileList + { + private Profile[] list; + + public int Length + { + get + { + return this.list.Length; + } + } + + public Profile this[int index] + { + get + { + return this.list[index]; + } + } + + public ProfileList() + { + this.list = new Profile[0]; + } + + public void Add(Profile p) + { + //grow the list by 1 and copy all existing items + Profile[] tmp = new Profile[this.Length + 1]; + + for (int i = 0; i < this.Length; i++) + { + tmp[i] = this[i]; + } + + this.list = tmp; + + //-------------------------------------------------------- + + list[this.Length - 1] = p; + } + + public void Remove(Profile p) + { + Profile[] tmp = new Profile[this.Length - 1]; + + for (int i = 0; i < tmp.Length; i++) + { + if (this[i] != p) + { + tmp[i] = this[i]; + } + } + + this.list = tmp; + } + } +} diff --git a/Password Manager/Program.cs b/Password Manager/Program.cs index 2d53eb4..2c557ae 100644 --- a/Password Manager/Program.cs +++ b/Password Manager/Program.cs @@ -2,7 +2,6 @@ namespace Password_Manager { internal static class Program { - /// /// The main entry point for the application. /// @@ -12,12 +11,7 @@ namespace Password_Manager // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new Form1()); - } - - static void UpdateList(TextBox textbox, ListBox listbox) - { - - } + Application.Run(new MainForm()); + } } } \ No newline at end of file