Converting to file-scoped namespaces
This commit is contained in:
@@ -1,56 +1,55 @@
|
||||
namespace GUI
|
||||
namespace GUI;
|
||||
|
||||
public delegate void MethodRequest();
|
||||
public partial class GeneratePassword : Form
|
||||
{
|
||||
public delegate void MethodRequest();
|
||||
public partial class GeneratePassword : Form
|
||||
private string currentPath;
|
||||
private string recipient;
|
||||
public event MethodRequest ReloadRequest;
|
||||
|
||||
public GeneratePassword(string currentPath, string recipient, MethodRequest ReloadRequest, string? name)
|
||||
{
|
||||
private string currentPath;
|
||||
private string recipient;
|
||||
public event MethodRequest ReloadRequest;
|
||||
InitializeComponent();
|
||||
passwordName.Text = name;
|
||||
this.currentPath = currentPath;
|
||||
this.recipient = recipient;
|
||||
this.ReloadRequest = ReloadRequest;
|
||||
}
|
||||
|
||||
public GeneratePassword(string currentPath, string recipient, MethodRequest ReloadRequest, string? name)
|
||||
public void Generate(object sender, EventArgs e)
|
||||
{
|
||||
if (passwordName.Text == "" || passwordLength.Text == "")
|
||||
{
|
||||
InitializeComponent();
|
||||
passwordName.Text = name;
|
||||
this.currentPath = currentPath;
|
||||
this.recipient = recipient;
|
||||
this.ReloadRequest = ReloadRequest;
|
||||
MessageBox.Show("You must fill in all fields to continue.", "Error: Empty fields", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
public void Generate(object sender, EventArgs e)
|
||||
else
|
||||
{
|
||||
if (passwordName.Text == "" || passwordLength.Text == "")
|
||||
try
|
||||
{
|
||||
MessageBox.Show("You must fill in all fields to continue.", "Error: Empty fields", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
string filePath = $"{currentPath}\\{passwordName.Text}";
|
||||
File.WriteAllText(
|
||||
currentPath + $"\\{passwordName.Text}.gpg",
|
||||
PasswordGenerator.New(
|
||||
recipient,
|
||||
Convert.ToInt32(passwordLength.Text),
|
||||
noSymbols.Checked)
|
||||
);
|
||||
}
|
||||
else
|
||||
catch (FormatException)
|
||||
{
|
||||
try
|
||||
{
|
||||
string filePath = $"{currentPath}\\{passwordName.Text}";
|
||||
File.WriteAllText(
|
||||
currentPath + $"\\{passwordName.Text}.gpg",
|
||||
PasswordGenerator.New(
|
||||
recipient,
|
||||
Convert.ToInt32(passwordLength.Text),
|
||||
noSymbols.Checked)
|
||||
);
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
MessageBox.Show("Please enter a valid number for the password's length.", "Error: Invalid field", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
catch (IOException error)
|
||||
{
|
||||
MessageBox.Show(error.ToString(), "IO Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
MessageBox.Show("Please enter a valid number for the password's length.", "Error: Invalid field", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
catch (IOException error)
|
||||
{
|
||||
MessageBox.Show(error.ToString(), "IO Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
ReloadRequest();
|
||||
Close();
|
||||
}
|
||||
ReloadRequest();
|
||||
Close();
|
||||
}
|
||||
|
||||
private void cancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
private void cancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user