I don't even know anymore
This commit is contained in:
Binary file not shown.
Binary file not shown.
10
Password Manager/Fields.cs
Normal file
10
Password Manager/Fields.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using System;
|
||||
|
||||
namespace Password_Manager
|
||||
{
|
||||
static class Fields
|
||||
{
|
||||
public static Profile CurrentProfile;
|
||||
public static ProfileList ListOfProfiles;
|
||||
}
|
||||
}
|
||||
6
Password Manager/Form1.Designer.cs
generated
6
Password Manager/Form1.Designer.cs
generated
@@ -76,8 +76,8 @@
|
||||
|
||||
#endregion
|
||||
|
||||
private TextBox searchBox;
|
||||
private ListBox resultList;
|
||||
private ComboBox profileSelection;
|
||||
public TextBox searchBox;
|
||||
public ListBox resultList;
|
||||
public ComboBox profileSelection;
|
||||
}
|
||||
}
|
||||
@@ -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:
|
||||
}
|
||||
}
|
||||
}
|
||||
38
Password Manager/IList.cs
Normal file
38
Password Manager/IList.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
|
||||
namespace Password_Manager
|
||||
{
|
||||
abstract class IList<T>
|
||||
{
|
||||
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];
|
||||
}
|
||||
}
|
||||
}
|
||||
14
Password Manager/PasswordList.cs
Normal file
14
Password Manager/PasswordList.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
|
||||
namespace Password_Manager
|
||||
{
|
||||
sealed class PasswordListBox : ListBox
|
||||
{
|
||||
public PasswordListBox() : base() { }
|
||||
|
||||
public void ReadFromPath()
|
||||
{
|
||||
//read all files from
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,32 +2,12 @@
|
||||
|
||||
namespace Password_Manager
|
||||
{
|
||||
sealed class ProfileList
|
||||
sealed class ProfileList : IList<Profile>
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
13
Password Manager/ProfileNotFoundException.cs
Normal file
13
Password Manager/ProfileNotFoundException.cs
Normal file
@@ -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) { }
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user