kill me
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user