Adding Profile and ProfileList class
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,3 +1,3 @@
|
||||
Password\ Manager/bin
|
||||
Password\ Manager/obj
|
||||
.vs
|
||||
.vs/
|
||||
|
||||
Binary file not shown.
49
Password Manager/Form1.Designer.cs
generated
49
Password Manager/Form1.Designer.cs
generated
@@ -1,6 +1,6 @@
|
||||
namespace Password_Manager
|
||||
{
|
||||
partial class Form1
|
||||
partial class MainForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
@@ -28,34 +28,46 @@
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
62
Password Manager/ProfileList.cs
Normal file
62
Password Manager/ProfileList.cs
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@ namespace Password_Manager
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user