diff --git a/.vs/Password Manager/DesignTimeBuild/.dtbcache.v2 b/.vs/Password Manager/DesignTimeBuild/.dtbcache.v2
index 03c9a09..b6703d9 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/.futdcache.v2 b/.vs/Password Manager/v17/.futdcache.v2
index 84f93c6..a34e419 100644
Binary files a/.vs/Password Manager/v17/.futdcache.v2 and b/.vs/Password Manager/v17/.futdcache.v2 differ
diff --git a/.vs/Password Manager/v17/.suo b/.vs/Password Manager/v17/.suo
index 532e0ff..22215e2 100644
Binary files a/.vs/Password Manager/v17/.suo and b/.vs/Password Manager/v17/.suo differ
diff --git a/.vs/ProjectEvaluation/password manager.metadata.v6.1 b/.vs/ProjectEvaluation/password manager.metadata.v6.1
index 041f23e..642a145 100644
Binary files a/.vs/ProjectEvaluation/password manager.metadata.v6.1 and b/.vs/ProjectEvaluation/password manager.metadata.v6.1 differ
diff --git a/.vs/ProjectEvaluation/password manager.projects.v6.1 b/.vs/ProjectEvaluation/password manager.projects.v6.1
index a33f314..c653756 100644
Binary files a/.vs/ProjectEvaluation/password manager.projects.v6.1 and b/.vs/ProjectEvaluation/password manager.projects.v6.1 differ
diff --git a/Password Manager/GeneratePassword.Designer.cs b/Password Manager/GeneratePassword.Designer.cs
new file mode 100644
index 0000000..186a1cb
--- /dev/null
+++ b/Password Manager/GeneratePassword.Designer.cs
@@ -0,0 +1,135 @@
+namespace Password_Manager
+{
+ partial class GeneratePassword
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ passwordName = new TextBox();
+ label1 = new Label();
+ label2 = new Label();
+ passwordLength = new TextBox();
+ noSymbols = new CheckBox();
+ generate = new Button();
+ cancel = new Button();
+ SuspendLayout();
+ //
+ // textBox1
+ //
+ passwordName.Location = new Point(12, 33);
+ passwordName.Name = "textBox1";
+ passwordName.PlaceholderText = "website.com";
+ passwordName.Size = new Size(156, 23);
+ passwordName.TabIndex = 0;
+ //
+ // label1
+ //
+ label1.AutoSize = true;
+ label1.Location = new Point(12, 15);
+ label1.Name = "label1";
+ label1.Size = new Size(39, 15);
+ label1.TabIndex = 1;
+ label1.Text = "Name";
+ //
+ // label2
+ //
+ label2.AutoSize = true;
+ label2.Location = new Point(12, 59);
+ label2.Name = "label2";
+ label2.Size = new Size(44, 15);
+ label2.TabIndex = 2;
+ label2.Text = "Length";
+ //
+ // textBox2
+ //
+ passwordLength.Location = new Point(12, 77);
+ passwordLength.Name = "textBox2";
+ passwordLength.PlaceholderText = "16";
+ passwordLength.Size = new Size(156, 23);
+ passwordLength.TabIndex = 3;
+ //
+ // checkBox1
+ //
+ noSymbols.AutoSize = true;
+ noSymbols.Location = new Point(12, 106);
+ noSymbols.Name = "checkBox1";
+ noSymbols.Size = new Size(89, 19);
+ noSymbols.TabIndex = 4;
+ noSymbols.Text = "No symbols";
+ noSymbols.UseVisualStyleBackColor = true;
+ //
+ // button1
+ //
+ generate.Location = new Point(93, 131);
+ generate.Name = "button1";
+ generate.Size = new Size(75, 23);
+ generate.TabIndex = 5;
+ generate.Text = "Generate";
+ generate.UseVisualStyleBackColor = true;
+ generate.Click += Generate;
+ //
+ // button2
+ //
+ cancel.Location = new Point(12, 131);
+ cancel.Name = "button2";
+ cancel.Size = new Size(75, 23);
+ cancel.TabIndex = 6;
+ cancel.Text = "Cancel";
+ cancel.UseVisualStyleBackColor = true;
+ //
+ // GeneratePassword
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(187, 173);
+ Controls.Add(cancel);
+ Controls.Add(generate);
+ Controls.Add(noSymbols);
+ Controls.Add(passwordLength);
+ Controls.Add(label2);
+ Controls.Add(label1);
+ Controls.Add(passwordName);
+ Name = "GeneratePassword";
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ private void Generate_Click(object sender, EventArgs e)
+ {
+ throw new NotImplementedException();
+ }
+
+ #endregion
+
+ private TextBox passwordName;
+ private Label label1;
+ private Label label2;
+ private TextBox passwordLength;
+ private CheckBox noSymbols;
+ private Button generate;
+ private Button cancel;
+ }
+}
\ No newline at end of file
diff --git a/Password Manager/GeneratePassword.cs b/Password Manager/GeneratePassword.cs
new file mode 100644
index 0000000..a2f59e2
--- /dev/null
+++ b/Password Manager/GeneratePassword.cs
@@ -0,0 +1,48 @@
+using Password_Generator;
+
+namespace Password_Manager
+{
+ public partial class GeneratePassword : Form
+ {
+ private string currentPath;
+
+ public GeneratePassword(string name, string currentPath)
+ {
+ InitializeComponent();
+ passwordName.Text = name;
+ this.currentPath = currentPath;
+ }
+
+ public void Generate(object sender, EventArgs e)
+ {
+ if (passwordName.Text == "" && passwordLength.Text == "")
+ {
+ MessageBox.Show("You must fill in all fields to continue.", "Error: Empty fields", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+
+ bool valid = false;
+ while (!valid)
+ {
+ try
+ {
+ StreamWriter sw = new StreamWriter(currentPath + $"{passwordName.Text}.txt"); //TODO: rename to .gpg when encryption is possible
+ valid = true;
+ sw.Write(Generator.New(Convert.ToInt32(passwordLength.Text), noSymbols.Checked));
+ sw.Close();
+ }
+ catch (FormatException)
+ {
+ MessageBox.Show("Please enter a valid number for the password's length.", "Error: Invalid field", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ catch (ArgumentNullException error)
+ {
+ MessageBox.Show(error.ToString(), "Error: No profile path", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ catch (IOException error)
+ {
+ MessageBox.Show(error.ToString(), "IO Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ }
+}
diff --git a/Password Manager/GeneratePassword.resx b/Password Manager/GeneratePassword.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/Password Manager/GeneratePassword.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/Password Manager/MainForm.Designer.cs b/Password Manager/MainForm.Designer.cs
index cf66e95..2f7fbb8 100644
--- a/Password Manager/MainForm.Designer.cs
+++ b/Password Manager/MainForm.Designer.cs
@@ -29,29 +29,34 @@
private void InitializeComponent()
{
searchBox = new TextBox();
- resultList = new ResultListBox();
+ resultList = new PasswordListBox();
profileSelection = new ComboBox();
addProfile = new Button();
removeProfile = new Button();
+ generatePassword = new Button();
SuspendLayout();
//
// searchBox
//
- searchBox.Location = new Point(12, 27);
+ searchBox.Location = new Point(10, 20);
+ searchBox.Margin = new Padding(3, 2, 3, 2);
searchBox.Name = "searchBox";
searchBox.PlaceholderText = "Search for a password";
- searchBox.Size = new Size(257, 27);
+ searchBox.Size = new Size(225, 23);
searchBox.TabIndex = 0;
searchBox.TextChanged += resultList.ReloadResults;
//
// resultList
//
resultList.FormattingEnabled = true;
- resultList.ItemHeight = 20;
- resultList.Location = new Point(12, 60);
+ resultList.ItemHeight = 15;
+ resultList.Location = new Point(10, 45);
+ resultList.Margin = new Padding(3, 2, 3, 2);
resultList.Name = "resultList";
- resultList.Size = new Size(257, 364);
+ resultList.Size = new Size(225, 274);
resultList.TabIndex = 1;
+ resultList.CurrentProfilePathRequest += CurrentProfilePathRequest;
+ resultList.SearchQueryRequest += () => searchBox.Text;
//
// profileSelection
//
@@ -60,17 +65,19 @@
profileSelection.DropDownWidth = 200;
profileSelection.FormattingEnabled = true;
profileSelection.IntegralHeight = false;
- profileSelection.Location = new Point(586, 26);
+ profileSelection.Location = new Point(513, 20);
+ profileSelection.Margin = new Padding(3, 2, 3, 2);
profileSelection.Name = "profileSelection";
- profileSelection.Size = new Size(200, 28);
+ profileSelection.Size = new Size(176, 23);
profileSelection.TabIndex = 2;
- profileSelection.SelectedIndexChanged += ProfileHandler.ProfileChange;
+ profileSelection.SelectionChangeCommitted += ChangeProfile;
//
// addProfile
//
- addProfile.Location = new Point(586, 60);
+ addProfile.Location = new Point(513, 45);
+ addProfile.Margin = new Padding(3, 2, 3, 2);
addProfile.Name = "addProfile";
- addProfile.Size = new Size(95, 29);
+ addProfile.Size = new Size(83, 22);
addProfile.TabIndex = 3;
addProfile.Text = "Add";
addProfile.UseVisualStyleBackColor = true;
@@ -78,23 +85,36 @@
//
// removeProfile
//
- removeProfile.Location = new Point(691, 60);
+ removeProfile.Location = new Point(605, 45);
+ removeProfile.Margin = new Padding(3, 2, 3, 2);
removeProfile.Name = "removeProfile";
- removeProfile.Size = new Size(95, 29);
+ removeProfile.Size = new Size(83, 22);
removeProfile.TabIndex = 4;
removeProfile.Text = "Delete";
removeProfile.UseVisualStyleBackColor = true;
//
+ // button1
+ //
+ generatePassword.Location = new Point(241, 20);
+ generatePassword.Name = "button1";
+ generatePassword.Size = new Size(75, 23);
+ generatePassword.TabIndex = 5;
+ generatePassword.Text = "Generate";
+ generatePassword.UseVisualStyleBackColor = true;
+ generatePassword.Click += Generate;
+ //
// MainForm
//
- AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
- ClientSize = new Size(800, 450);
+ ClientSize = new Size(700, 338);
+ Controls.Add(generatePassword);
Controls.Add(removeProfile);
Controls.Add(addProfile);
Controls.Add(profileSelection);
Controls.Add(resultList);
Controls.Add(searchBox);
+ Margin = new Padding(3, 2, 3, 2);
Name = "MainForm";
Text = "Password Manager";
ResumeLayout(false);
@@ -103,10 +123,11 @@
#endregion
- public TextBox searchBox;
- public ResultListBox resultList;
- public ComboBox profileSelection;
- public Button addProfile;
- public Button removeProfile;
+ private TextBox searchBox;
+ private PasswordListBox resultList;
+ private ComboBox profileSelection;
+ private Button addProfile;
+ private Button removeProfile;
+ private Button generatePassword;
}
}
\ No newline at end of file
diff --git a/Password Manager/MainForm.cs b/Password Manager/MainForm.cs
index d33ce4c..0bdf045 100644
--- a/Password Manager/MainForm.cs
+++ b/Password Manager/MainForm.cs
@@ -1,24 +1,61 @@
namespace Password_Manager
{
+ public delegate void ProfileChanges(string profileName);
+ public delegate string[] ProfileList();
+ public delegate void Save();
public partial class MainForm : Form
{
- public MainForm()
+ public event ProfileDataRequest? CurrentProfilePathRequest;
+ public event ProfileDataRequest? CurrentProfileNameRequest;
+ public event ProfileList? CurrentProfileListRequest;
+ public event ProfileChanges? CurrentProfileChanged;
+ public event Save? SaveRequest;
+
+ public MainForm(ProfileDataRequest CurrentProfileNameRequest, ProfileDataRequest CurrentProfilePathRequest, ProfileList CurrentProfileListRequest, ProfileChanges CurrentProfileChanged)
{
+ this.CurrentProfileNameRequest = CurrentProfileNameRequest;
+ this.CurrentProfilePathRequest = CurrentProfilePathRequest;
+ this.CurrentProfileListRequest = CurrentProfileListRequest;
+ this.CurrentProfileChanged = CurrentProfileChanged;
InitializeComponent();
+ LoadCurrentProfile();
+
+ foreach (string s in CurrentProfileListRequest?.Invoke())
+ {
+ profileSelection.Items.Add(s);
+ }
+ profileSelection.SelectedIndex = 0;
+
+ SaveRequest?.Invoke();
+ }
+
+ private void LoadCurrentProfile()
+ {
+ this.Text = CurrentProfileNameRequest?.Invoke();
+ resultList.ReloadResults();
}
private void ChangeProfile(object sender, EventArgs e)
{
- ComboBox cb = (ComboBox)sender;
- ProfileHandler.CurrentProfile = ProfileHandler.ListOfProfiles.SearchByName(cb.Text);
- searchBox.Clear();
- this.Text = ProfileHandler.CurrentProfile == null ? "Password Manager" : $"Current profile: {ProfileHandler.CurrentProfile.Name}";
+ CurrentProfileChanged?.Invoke(profileSelection.Text);
+
+ foreach (string s in CurrentProfileListRequest?.Invoke())
+ {
+ profileSelection.Items.Add(s);
+ }
}
private void AddProfile(object sender, EventArgs e)
{
NewProfileForm npf = new NewProfileForm();
+ npf.ReloadPasswordsRequest += () => resultList.ReloadResults();
npf.Show();
}
+
+ private void Generate(object sender, EventArgs e)
+ {
+ GeneratePassword gp = new GeneratePassword(searchBox.Text, CurrentProfilePathRequest?.Invoke());
+ gp.Show();
+ }
}
}
\ No newline at end of file
diff --git a/Password Manager/NewProfileForm.cs b/Password Manager/NewProfileForm.cs
index 7b0407b..f3d1222 100644
--- a/Password Manager/NewProfileForm.cs
+++ b/Password Manager/NewProfileForm.cs
@@ -1,17 +1,12 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Drawing;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Forms;
-
-namespace Password_Manager
+namespace Password_Manager
{
+ public delegate void NewProfile(string profileName, string profilePath);
+ public delegate void ReloadPasswords();
public partial class NewProfileForm : Form
{
+ public event NewProfile NewProfileRequest;
+ public event ReloadPasswords ReloadPasswordsRequest;
+
public NewProfileForm()
{
InitializeComponent();
@@ -30,10 +25,8 @@ namespace Password_Manager
{
if (nameTextBox.Text != "" && pathTextBox.Text != "")
{
- Profile profile = new Profile(nameTextBox.Text, pathTextBox.Text);
- ProfileHandler.ListOfProfiles.Add(profile);
- ProfileHandler.CurrentProfile = profile;
- Program.mainForm.resultList.ReloadResults();
+ NewProfileRequest?.Invoke(nameTextBox.Text, pathTextBox.Text);
+ ReloadPasswordsRequest?.Invoke();
this.Close();
}
else
diff --git a/Password Manager/Password Manager.csproj.user b/Password Manager/Password Manager.csproj.user
index d61e8d1..b307696 100644
--- a/Password Manager/Password Manager.csproj.user
+++ b/Password Manager/Password Manager.csproj.user
@@ -1,13 +1,16 @@
+
+ Form
+
Form
Form
-
+
Component
diff --git a/Password Manager/PasswordGenerator.cs b/Password Manager/PasswordGenerator.cs
new file mode 100644
index 0000000..4a2394c
--- /dev/null
+++ b/Password Manager/PasswordGenerator.cs
@@ -0,0 +1,34 @@
+using System.Text;
+
+namespace Password_Generator
+{
+ static class Generator
+ {
+ public static string New(int length, bool no_symbols = false)
+ {
+ StringBuilder builder = new StringBuilder();
+ Random rnd = new Random();
+ for (int i = 0; i < length; i++)
+ {
+ if (rnd.Next(0, 101) <= 60) //60% chance for a character
+ {
+ char c = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * rnd.NextDouble() + 65))); //random character
+ if (no_symbols && Char.IsSymbol(c))
+ {
+ while (Char.IsSymbol(c))
+ {
+ c = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * rnd.NextDouble() + 65))); //random character
+ }
+ }
+ builder.Append(c);
+ }
+ else //40% change for number
+ {
+ builder.Append(Convert.ToChar(rnd.Next(0, 10)));
+ }
+ }
+
+ return builder.ToString();
+ }
+ }
+}
diff --git a/Password Manager/PasswordListBox.cs b/Password Manager/PasswordListBox.cs
new file mode 100644
index 0000000..c5773a4
--- /dev/null
+++ b/Password Manager/PasswordListBox.cs
@@ -0,0 +1,47 @@
+namespace Password_Manager
+{
+ public delegate string SearchQuery();
+ public class PasswordListBox : ListBox
+ {
+ public event ProfileDataRequest? CurrentProfilePathRequest;
+ public event SearchQuery? SearchQueryRequest;
+
+ public PasswordListBox() : base() { }
+
+ public void ReloadResults(object sender = null, EventArgs arg = null)
+ {
+ DirectoryInfo d;
+ FileInfo[] files = new FileInfo[0];
+ try
+ {
+ d = new DirectoryInfo(CurrentProfilePathRequest?.Invoke());
+ files = d.GetFiles("*.gpg");
+ } catch (ArgumentNullException e)
+ {
+ MessageBox.Show(e.ToString(), "Error: Invalid profile path", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+
+ string[] arrayTmp = new string[files.Length];
+ for (int i = 0; i < arrayTmp.Length; i++)
+ {
+ arrayTmp[i] = files[i].Name;
+ }
+ List elements = new List(arrayTmp);
+
+ string[] copy = elements.ToArray();
+ string searchQuery = SearchQueryRequest?.Invoke();
+ if (searchQuery != "") //we have a search query
+ {
+ foreach (string s in copy)
+ {
+ if (!s.Contains(searchQuery))
+ {
+ elements.Remove(s);
+ }
+ }
+ }
+
+ this.DataSource = elements;
+ }
+ }
+}
diff --git a/Password Manager/IList.cs b/Password Manager/Profiles/IList.cs
similarity index 93%
rename from Password Manager/IList.cs
rename to Password Manager/Profiles/IList.cs
index 34fa6d4..0d89055 100644
--- a/Password Manager/IList.cs
+++ b/Password Manager/Profiles/IList.cs
@@ -1,6 +1,4 @@
-using System;
-
-namespace Password_Manager
+namespace Profiles
{
abstract class IList
{
diff --git a/Password Manager/Profiles/Profile.cs b/Password Manager/Profiles/Profile.cs
index fddb468..fcbec87 100644
--- a/Password Manager/Profiles/Profile.cs
+++ b/Password Manager/Profiles/Profile.cs
@@ -1,10 +1,6 @@
-using System;
-
-namespace Password_Manager
+namespace Profiles
{
- public delegate void PasswordStoreChange();
-
- sealed class Profile
+ public 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/Profiles/ProfileHandler.cs b/Password Manager/Profiles/ProfileHandler.cs
index 60a1a7f..d14d3f2 100644
--- a/Password Manager/Profiles/ProfileHandler.cs
+++ b/Password Manager/Profiles/ProfileHandler.cs
@@ -1,17 +1,89 @@
-using System;
+using Password_Manager;
+using Microsoft.VisualBasic.FileIO;
-namespace Password_Manager
+namespace Profiles
{
static class ProfileHandler
{
public static Profile CurrentProfile;
public static ProfileList ListOfProfiles;
+ private static string filePath = SpecialDirectories.CurrentUserApplicationData + "Profiles.csv";
- public static void ProfileChange(object sender, EventArgs e)
+ public static void ChangeProfiles(string profileName)
{
- Program.mainForm.searchBox.Clear();
- Program.mainForm.resultList.ReloadResults();
- Program.mainForm.profileSelection.DataSource = ListOfProfiles;
+ CurrentProfile = ListOfProfiles.SearchByName(profileName);
+ }
+
+ public static void Init()
+ {
+ ListOfProfiles = new ProfileList();
+
+ if (File.Exists(filePath))
+ {
+ LoadProfiles();
+ }
+ else
+ {
+ CreateProfiles();
+ }
+ }
+ private static void LoadProfiles()
+ {
+ try
+ {
+ StreamReader sr = new StreamReader(filePath);
+ string[] lines = sr.ReadToEnd().Split("\n");
+ foreach (string line in lines)
+ {
+ string[] fields = line.Split(',');
+ try
+ {
+ ListOfProfiles.Add(new Profile(fields[0], fields[1]));
+ } catch (IndexOutOfRangeException)
+ {
+ //File is messed up, creating new one
+ sr.Close();
+ CreateProfiles();
+ break;
+ }
+ }
+ sr.Close();
+ } catch (IOException e)
+ {
+ MessageBox.Show(e.ToString(), "IO Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private static void TrimLastLine()
+ {
+ List lines = File.ReadAllLines(filePath).ToList();
+ File.WriteAllLines(filePath, lines.GetRange(0, lines.Count - 1).ToArray());
+ }
+
+ private static void CreateProfiles()
+ {
+ try
+ {
+ StreamWriter sw = new StreamWriter(filePath);
+
+ string[] parameters = new string[2];
+
+ NewProfileForm np = new NewProfileForm();
+ Profile firstProfile = null;
+ np.NewProfileRequest += (string profileName, string profilePath) =>
+ {
+ firstProfile = new Profile(profileName, profilePath);
+ ListOfProfiles.Add(firstProfile);
+ ChangeProfiles(firstProfile.Name);
+ sw.WriteLine($"{firstProfile.Name},{firstProfile.Path}");
+ sw.Close();
+ TrimLastLine();
+ };
+ np.ShowDialog();
+ } catch (IOException e)
+ {
+ MessageBox.Show(e.ToString(), "IO Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
}
}
}
diff --git a/Password Manager/Profiles/ProfileList.cs b/Password Manager/Profiles/ProfileList.cs
index a8eac2c..ee8073e 100644
--- a/Password Manager/Profiles/ProfileList.cs
+++ b/Password Manager/Profiles/ProfileList.cs
@@ -1,6 +1,4 @@
-using System;
-
-namespace Password_Manager
+namespace Profiles
{
sealed class ProfileList : IList
{
@@ -59,5 +57,15 @@ namespace Password_Manager
return result;
}
}
+
+ public string[] GetNameList()
+ {
+ string[] array = new string[this.Length];
+ for (int i = 0; i < this.Length; i++)
+ {
+ array[i] = this[i].Name;
+ }
+ return array;
+ }
}
}
diff --git a/Password Manager/Profiles/ProfileNotFoundException.cs b/Password Manager/Profiles/ProfileNotFoundException.cs
index bda9248..afcffd5 100644
--- a/Password Manager/Profiles/ProfileNotFoundException.cs
+++ b/Password Manager/Profiles/ProfileNotFoundException.cs
@@ -1,7 +1,4 @@
-using System;
-using System.Runtime.CompilerServices;
-
-namespace Password_Manager
+namespace Profiles
{
sealed class ProfileNotFoundException : Exception
{
diff --git a/Password Manager/Program.cs b/Password Manager/Program.cs
index f0634cd..6e90c91 100644
--- a/Password Manager/Program.cs
+++ b/Password Manager/Program.cs
@@ -1,5 +1,8 @@
+using Profiles;
+
namespace Password_Manager
{
+ public delegate string ProfileDataRequest();
internal static class Program
{
///
@@ -8,11 +11,17 @@ namespace Password_Manager
[STAThread]
static void Main()
{
- ProfileHandler.ListOfProfiles = new ProfileList();
ApplicationConfiguration.Initialize();
+ ProfileHandler.Init();
+
Application.Run(mainForm);
}
- public static MainForm mainForm = new MainForm();
+ public static MainForm mainForm = new MainForm(
+ () => ProfileHandler.CurrentProfile.Name,
+ () => ProfileHandler.CurrentProfile.Path,
+ () => ProfileHandler.ListOfProfiles.GetNameList(),
+ (profileName) => ProfileHandler.ChangeProfiles(profileName)
+ ); //needed at creation so that MainForm may pass this method down to other classes in its constructor
}
}
\ No newline at end of file
diff --git a/Password Manager/ResultListBox.cs b/Password Manager/ResultListBox.cs
deleted file mode 100644
index 1cb2027..0000000
--- a/Password Manager/ResultListBox.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-using System;
-
-namespace Password_Manager
-{
- public class ResultListBox : ListBox
- {
- public ResultListBox() : base() { }
-
- public void ReloadResults()
- {
- DirectoryInfo d = new DirectoryInfo(ProfileHandler.CurrentProfile.Path);
- FileInfo[] files = d.GetFiles("*.gpg");
- string[] arrayTmp = new string[files.Length];
- for (int i = 0; i < arrayTmp.Length; i++)
- {
- arrayTmp[i] = files[i].Name;
- }
- List elements = new List(arrayTmp);
-
- string[] copy = elements.ToArray();
- if (Program.mainForm.searchBox.Text != "") //we have a search query
- {
- foreach (string s in copy)
- {
- if (!s.Contains(Program.mainForm.searchBox.Text))
- {
- elements.Remove(s);
- }
- }
- }
-
- this.DataSource = elements;
- }
-
- public void ReloadResults(object o, EventArgs e) //needed so that I can subscribe this method to a delegate in MainForm
- {
- ReloadResults();
- }
- }
-}
diff --git a/Password Manager/obj/Debug/net7.0-windows/Password Manager.GeneratedMSBuildEditorConfig.editorconfig b/Password Manager/obj/Debug/net7.0-windows/Password Manager.GeneratedMSBuildEditorConfig.editorconfig
index 3affcda..76747c7 100644
--- a/Password Manager/obj/Debug/net7.0-windows/Password Manager.GeneratedMSBuildEditorConfig.editorconfig
+++ b/Password Manager/obj/Debug/net7.0-windows/Password Manager.GeneratedMSBuildEditorConfig.editorconfig
@@ -14,4 +14,4 @@ build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = Password_Manager
-build_property.ProjectDir = C:\Users\RichardMiskolczi\Password Manager\Password Manager\
+build_property.ProjectDir = C:\Users\Typo\Projects\Windows-Password-Manager\Password Manager\
diff --git a/Password Manager/obj/Debug/net7.0-windows/Password Manager.assets.cache b/Password Manager/obj/Debug/net7.0-windows/Password Manager.assets.cache
index 0f81bb2..83257b2 100644
Binary files a/Password Manager/obj/Debug/net7.0-windows/Password Manager.assets.cache and b/Password Manager/obj/Debug/net7.0-windows/Password Manager.assets.cache differ
diff --git a/Password Manager/obj/Debug/net7.0-windows/Password Manager.designer.runtimeconfig.json b/Password Manager/obj/Debug/net7.0-windows/Password Manager.designer.runtimeconfig.json
index 0ffbf74..d45f1d2 100644
--- a/Password Manager/obj/Debug/net7.0-windows/Password Manager.designer.runtimeconfig.json
+++ b/Password Manager/obj/Debug/net7.0-windows/Password Manager.designer.runtimeconfig.json
@@ -12,8 +12,8 @@
}
],
"additionalProbingPaths": [
- "C:\\Users\\RichardMiskolczi\\.dotnet\\store\\|arch|\\|tfm|",
- "C:\\Users\\RichardMiskolczi\\.nuget\\packages"
+ "C:\\Users\\Typo\\.dotnet\\store\\|arch|\\|tfm|",
+ "C:\\Users\\Typo\\.nuget\\packages"
],
"configProperties": {
"Microsoft.NETCore.DotNetHostPolicy.SetAppPaths": true
diff --git a/Password Manager/obj/Password Manager.csproj.nuget.dgspec.json b/Password Manager/obj/Password Manager.csproj.nuget.dgspec.json
index 3f32255..9319f2d 100644
--- a/Password Manager/obj/Password Manager.csproj.nuget.dgspec.json
+++ b/Password Manager/obj/Password Manager.csproj.nuget.dgspec.json
@@ -1,20 +1,20 @@
{
"format": 1,
"restore": {
- "C:\\Users\\RichardMiskolczi\\Password Manager\\Password Manager\\Password Manager.csproj": {}
+ "C:\\Users\\Typo\\Projects\\Windows-Password-Manager\\Password Manager\\Password Manager.csproj": {}
},
"projects": {
- "C:\\Users\\RichardMiskolczi\\Password Manager\\Password Manager\\Password Manager.csproj": {
+ "C:\\Users\\Typo\\Projects\\Windows-Password-Manager\\Password Manager\\Password Manager.csproj": {
"version": "1.0.0",
"restore": {
- "projectUniqueName": "C:\\Users\\RichardMiskolczi\\Password Manager\\Password Manager\\Password Manager.csproj",
+ "projectUniqueName": "C:\\Users\\Typo\\Projects\\Windows-Password-Manager\\Password Manager\\Password Manager.csproj",
"projectName": "Password Manager",
- "projectPath": "C:\\Users\\RichardMiskolczi\\Password Manager\\Password Manager\\Password Manager.csproj",
- "packagesPath": "C:\\Users\\RichardMiskolczi\\.nuget\\packages\\",
- "outputPath": "C:\\Users\\RichardMiskolczi\\Password Manager\\Password Manager\\obj\\",
+ "projectPath": "C:\\Users\\Typo\\Projects\\Windows-Password-Manager\\Password Manager\\Password Manager.csproj",
+ "packagesPath": "C:\\Users\\Typo\\.nuget\\packages\\",
+ "outputPath": "C:\\Users\\Typo\\Projects\\Windows-Password-Manager\\Password Manager\\obj\\",
"projectStyle": "PackageReference",
"configFilePaths": [
- "C:\\Users\\RichardMiskolczi\\AppData\\Roaming\\NuGet\\NuGet.Config",
+ "C:\\Users\\Typo\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
diff --git a/Password Manager/obj/Password Manager.csproj.nuget.g.props b/Password Manager/obj/Password Manager.csproj.nuget.g.props
index c4b0128..adb2bed 100644
--- a/Password Manager/obj/Password Manager.csproj.nuget.g.props
+++ b/Password Manager/obj/Password Manager.csproj.nuget.g.props
@@ -5,11 +5,11 @@
NuGet
$(MSBuildThisFileDirectory)project.assets.json
$(UserProfile)\.nuget\packages\
- C:\Users\RichardMiskolczi\.nuget\packages\
+ C:\Users\Typo\.nuget\packages\
PackageReference
6.5.0
-
+
\ No newline at end of file
diff --git a/Password Manager/obj/project.assets.json b/Password Manager/obj/project.assets.json
index 45f1b26..b9d987f 100644
--- a/Password Manager/obj/project.assets.json
+++ b/Password Manager/obj/project.assets.json
@@ -8,19 +8,19 @@
"net7.0-windows7.0": []
},
"packageFolders": {
- "C:\\Users\\RichardMiskolczi\\.nuget\\packages\\": {}
+ "C:\\Users\\Typo\\.nuget\\packages\\": {}
},
"project": {
"version": "1.0.0",
"restore": {
- "projectUniqueName": "C:\\Users\\RichardMiskolczi\\Password Manager\\Password Manager\\Password Manager.csproj",
+ "projectUniqueName": "C:\\Users\\Typo\\Projects\\Windows-Password-Manager\\Password Manager\\Password Manager.csproj",
"projectName": "Password Manager",
- "projectPath": "C:\\Users\\RichardMiskolczi\\Password Manager\\Password Manager\\Password Manager.csproj",
- "packagesPath": "C:\\Users\\RichardMiskolczi\\.nuget\\packages\\",
- "outputPath": "C:\\Users\\RichardMiskolczi\\Password Manager\\Password Manager\\obj\\",
+ "projectPath": "C:\\Users\\Typo\\Projects\\Windows-Password-Manager\\Password Manager\\Password Manager.csproj",
+ "packagesPath": "C:\\Users\\Typo\\.nuget\\packages\\",
+ "outputPath": "C:\\Users\\Typo\\Projects\\Windows-Password-Manager\\Password Manager\\obj\\",
"projectStyle": "PackageReference",
"configFilePaths": [
- "C:\\Users\\RichardMiskolczi\\AppData\\Roaming\\NuGet\\NuGet.Config",
+ "C:\\Users\\Typo\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
diff --git a/Password Manager/obj/project.nuget.cache b/Password Manager/obj/project.nuget.cache
index c3c051c..6a33339 100644
--- a/Password Manager/obj/project.nuget.cache
+++ b/Password Manager/obj/project.nuget.cache
@@ -1,8 +1,8 @@
{
"version": 2,
- "dgSpecHash": "j+Af3msCh5F346C/nQWI7qovMW8Vd2PEbp7ynx42JtS4tfpFIR2p1HtRmEyrqVdFgQ1kz/RvVO6rZ8LL+kAtoA==",
+ "dgSpecHash": "pORlMyjnmPISFrdLakbVEwbRIXTIF7StLLdawRpMvRY01tBOhcBNA+U3VV7qwceV2a898Rx6Vw+s/NGbmgKQVQ==",
"success": true,
- "projectFilePath": "C:\\Users\\RichardMiskolczi\\Password Manager\\Password Manager\\Password Manager.csproj",
+ "projectFilePath": "C:\\Users\\Typo\\Projects\\Windows-Password-Manager\\Password Manager\\Password Manager.csproj",
"expectedPackageFiles": [],
"logs": []
}
\ No newline at end of file