This commit is contained in:
2023-03-27 09:30:41 +02:00
parent 1352624172
commit 60c6982663
6 changed files with 81 additions and 67 deletions

View File

@@ -7,12 +7,12 @@
public abstract class PasswordManagerForm : Form
{
protected abstract ComboBox ProfileSelection { get; }
protected abstract PasswordListBox ResultList { get; }
protected abstract TextBox SearchBox { get; }
protected abstract Button AddProfile { get; }
protected abstract Button DeleteProfile { get; }
protected abstract Button GeneratePassword { get; }
protected abstract ComboBox ProfileSelection { get; set; }
protected abstract PasswordListBox ResultList { get; set; }
protected abstract TextBox SearchBox { get; set; }
protected abstract Button AddProfile { get; set; }
protected abstract Button DeleteProfile { get; set; }
protected abstract Button GeneratePassword { get; set; }
public abstract event ProfileDataRequest CurrentProfilePathRequest;
public abstract event ProfileDataRequest CurrentProfileNameRequest;
@@ -21,41 +21,8 @@
public abstract event Save SaveRequest;
public abstract event NewProfile NewProfileRequest;
public PasswordManagerForm(
ProfileDataRequest CurrentProfileNameRequest,
ProfileDataRequest CurrentProfilePathRequest,
ProfileList CurrentProfileListRequest,
ProfileChange CurrentProfileChanged,
Save SaveRequest,
NewProfile NewProfileRequest)
{
this.CurrentProfileNameRequest = CurrentProfileNameRequest;
this.CurrentProfilePathRequest = CurrentProfilePathRequest;
this.CurrentProfileListRequest = CurrentProfileListRequest;
this.CurrentProfileChanged = CurrentProfileChanged;
this.SaveRequest = SaveRequest;
this.NewProfileRequest = NewProfileRequest;
}
protected virtual void ChangeProfile(object sender, EventArgs e)
{
CurrentProfileChanged(ProfileSelection.Text);
}
public virtual void RefreshCurrentProfile()
{
ProfileSelection.SelectedIndex = -1;
string[] items = CurrentProfileListRequest();
for (int i = 0; i < items.Length; i++)
{
ProfileSelection.Items.Add(items[i]);
if (items[i] == CurrentProfileNameRequest())
{
ProfileSelection.SelectedIndex = i;
}
}
this.Text = CurrentProfileNameRequest();
ResultList.ReloadResults();
}
protected abstract void ChangeProfile(object sender, EventArgs e);
public abstract void RefreshCurrentProfile();
}
}