Pass recipient to PasswordGenerator.cs
This commit is contained in:
@@ -5,12 +5,14 @@ namespace Password_Manager
|
|||||||
public partial class GeneratePassword : Form
|
public partial class GeneratePassword : Form
|
||||||
{
|
{
|
||||||
private string currentPath;
|
private string currentPath;
|
||||||
|
private string recipient;
|
||||||
|
|
||||||
public GeneratePassword(string name, string currentPath)
|
public GeneratePassword(string name, string currentPath, string recipient)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
passwordName.Text = name;
|
passwordName.Text = name;
|
||||||
this.currentPath = currentPath;
|
this.currentPath = currentPath;
|
||||||
|
this.recipient = recipient;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Generate(object sender, EventArgs e)
|
public void Generate(object sender, EventArgs e)
|
||||||
@@ -27,6 +29,7 @@ namespace Password_Manager
|
|||||||
File.WriteAllText(
|
File.WriteAllText(
|
||||||
currentPath + $"\\{passwordName.Text}.gpg",
|
currentPath + $"\\{passwordName.Text}.gpg",
|
||||||
PasswordGenerator.New(
|
PasswordGenerator.New(
|
||||||
|
recipient,
|
||||||
Convert.ToInt32(passwordLength.Text),
|
Convert.ToInt32(passwordLength.Text),
|
||||||
noSymbols.Checked)
|
noSymbols.Checked)
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -5,10 +5,12 @@ namespace Password_Manager
|
|||||||
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 MainForm(DataRequest PathRequest)
|
public MainForm(DataRequest PathRequest, DataRequest RecipientRequest = null)
|
||||||
{
|
{
|
||||||
this.PathRequest = PathRequest;
|
this.PathRequest = PathRequest;
|
||||||
|
this.RecipientRequest = RecipientRequest;
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
ResultList.SearchQueryRequest += () => SearchBox.Text;
|
ResultList.SearchQueryRequest += () => SearchBox.Text;
|
||||||
@@ -22,8 +24,15 @@ namespace Password_Manager
|
|||||||
|
|
||||||
private void OpenPasswordGenerator(object sender, EventArgs e)
|
private void OpenPasswordGenerator(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
GeneratePassword gp = new GeneratePassword(SearchBox.Text, PathRequest());
|
if (RecipientRequest != null)
|
||||||
gp.ShowDialog();
|
{
|
||||||
|
GeneratePassword gp = new GeneratePassword(SearchBox.Text, PathRequest(), RecipientRequest());
|
||||||
|
gp.ShowDialog();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new InvalidOperationExpression("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)
|
||||||
|
|||||||
Reference in New Issue
Block a user