diff --git a/.vs/Password Manager/DesignTimeBuild/.dtbcache.v2 b/.vs/Password Manager/DesignTimeBuild/.dtbcache.v2 index e392b5a..cea98f0 100644 Binary files a/.vs/Password Manager/DesignTimeBuild/.dtbcache.v2 and b/.vs/Password Manager/DesignTimeBuild/.dtbcache.v2 differ diff --git a/.vs/Password Manager/v17/.suo b/.vs/Password Manager/v17/.suo index 65fd6d0..7cf3bb7 100644 Binary files a/.vs/Password Manager/v17/.suo and b/.vs/Password Manager/v17/.suo differ diff --git a/Password Manager/Fields.cs b/Password Manager/Fields.cs new file mode 100644 index 0000000..e9d82c3 --- /dev/null +++ b/Password Manager/Fields.cs @@ -0,0 +1,10 @@ +using System; + +namespace Password_Manager +{ + static class Fields + { + public static Profile CurrentProfile; + public static ProfileList ListOfProfiles; + } +} diff --git a/Password Manager/Form1.Designer.cs b/Password Manager/Form1.Designer.cs index 4cd56c2..75fd00a 100644 --- a/Password Manager/Form1.Designer.cs +++ b/Password Manager/Form1.Designer.cs @@ -76,8 +76,8 @@ #endregion - private TextBox searchBox; - private ListBox resultList; - private ComboBox profileSelection; + public TextBox searchBox; + public ListBox resultList; + public ComboBox profileSelection; } } \ No newline at end of file diff --git a/Password Manager/Form1.cs b/Password Manager/Form1.cs index 8a55f13..1d6c11f 100644 --- a/Password Manager/Form1.cs +++ b/Password Manager/Form1.cs @@ -9,12 +9,15 @@ namespace Password_Manager private void ChangeProfile(object sender, EventArgs e) { + ComboBox cb = (ComboBox)sender; + Fields.CurrentProfile = Fields.ListOfProfiles.SearchByName(cb.Text); + } private void UpdateResultList(object sender, EventArgs args) { - + //TODO: } } } \ No newline at end of file diff --git a/Password Manager/IList.cs b/Password Manager/IList.cs new file mode 100644 index 0000000..34fa6d4 --- /dev/null +++ b/Password Manager/IList.cs @@ -0,0 +1,38 @@ +using System; + +namespace Password_Manager +{ + abstract class IList + { + protected T[] list; + + public int Length + { + get + { + return list.Length; + } + } + + public T this[int index] + { + get + { + return list[index]; + } + } + + public IList() + { + this.list = new T[0]; + } + + public abstract void Add(T item); + public abstract void Remove(T item); + public abstract T SearchByName(string name); + public void Clear() + { + list = new T[0]; + } + } +} diff --git a/Password Manager/PasswordList.cs b/Password Manager/PasswordList.cs new file mode 100644 index 0000000..22747b1 --- /dev/null +++ b/Password Manager/PasswordList.cs @@ -0,0 +1,14 @@ +using System; + +namespace Password_Manager +{ + sealed class PasswordListBox : ListBox + { + public PasswordListBox() : base() { } + + public void ReadFromPath() + { + //read all files from + } + } +} diff --git a/Password Manager/Profile.cs b/Password Manager/Profile.cs index 43a591e..74ce88a 100644 --- a/Password Manager/Profile.cs +++ b/Password Manager/Profile.cs @@ -8,6 +8,14 @@ namespace Password_Manager { 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 + private Password[] Passwords; public event PasswordStoreChange Change; //runs if a new password is added, or if one is removed + + public Profile(string name, string path, PasswordStoreChange change) + { + Name = name; + Path = path; + Change = change; + } } } diff --git a/Password Manager/ProfileList.cs b/Password Manager/ProfileList.cs index 597c120..025f102 100644 --- a/Password Manager/ProfileList.cs +++ b/Password Manager/ProfileList.cs @@ -2,32 +2,12 @@ namespace Password_Manager { - sealed class ProfileList + sealed class ProfileList : IList { - private Profile[] list; - public int Length - { - get - { - return this.list.Length; - } - } + public ProfileList() : base() { } - public Profile this[int index] - { - get - { - return this.list[index]; - } - } - - public ProfileList() - { - this.list = new Profile[0]; - } - - public void Add(Profile p) + public override void Add(Profile p) { //grow the list by 1 and copy all existing items Profile[] tmp = new Profile[this.Length + 1]; @@ -44,7 +24,7 @@ namespace Password_Manager list[this.Length - 1] = p; } - public void Remove(Profile p) + public override void Remove(Profile p) { Profile[] tmp = new Profile[this.Length - 1]; @@ -58,5 +38,27 @@ namespace Password_Manager this.list = tmp; } + + public override Profile SearchByName(string name) + { + Profile result = null; + + for (int i = 0; i < this.Length; i++) + { + if (this[i].Name == name) + { + result = this[i]; + } + } + + if (result == null) + { + throw new ProfileNotFoundException(); + } + else + { + return result; + } + } } } diff --git a/Password Manager/ProfileNotFoundException.cs b/Password Manager/ProfileNotFoundException.cs new file mode 100644 index 0000000..bda9248 --- /dev/null +++ b/Password Manager/ProfileNotFoundException.cs @@ -0,0 +1,13 @@ +using System; +using System.Runtime.CompilerServices; + +namespace Password_Manager +{ + sealed class ProfileNotFoundException : Exception + { + public ProfileNotFoundException() : base() { } + public ProfileNotFoundException(string message) : base(message) { } + public ProfileNotFoundException(string message, Exception inner) : base(message, inner) { } + + } +}