Code refactoring

This commit is contained in:
2023-04-02 22:50:51 +02:00
parent 5a0c6d8c6a
commit 47f320f2d3
5 changed files with 10 additions and 11 deletions

View File

@@ -1,11 +1,10 @@
using Common; using Common;
namespace GUI; namespace GUI;
sealed public partial class MainForm : Form sealed public partial class MainForm : Form
{ {
public event DataRequest PathRequest; public event DataRequest PathRequest;
public event DataRequest? RecipientRequest; public event DataRequest? RecipientRequest;
public MainForm(DataRequest PathRequest, DataRequest? RecipientRequest = null) public MainForm(DataRequest PathRequest, DataRequest? RecipientRequest = null)
{ {
@@ -29,15 +28,15 @@ sealed public partial class MainForm : Form
private void OpenPasswordGenerator(object sender, EventArgs e) private void OpenPasswordGenerator(object sender, EventArgs e)
{ {
if (RecipientRequest != null) if (RecipientRequest != null)
{ {
GeneratePassword gp = new GeneratePassword(PathRequest(), RecipientRequest(), ReloadResults, SearchBox.Text); GeneratePassword gp = new GeneratePassword(PathRequest(), RecipientRequest(), ReloadResults, SearchBox.Text);
gp.ShowDialog(); gp.ShowDialog();
} }
else else
{ {
throw new InvalidOperationException("You cannot use the OpenPasswordGenerator method if you instantiated this form without a RecipientRequest event handler."); throw new InvalidOperationException("You cannot use the OpenPasswordGenerator method if you instantiated this form without a RecipientRequest event handler.");
} }
} }
private void CancelPressed(object sender, EventArgs e) private void CancelPressed(object sender, EventArgs e)