46 lines
1.3 KiB
C#
46 lines
1.3 KiB
C#
namespace Password_Manager
|
|
{
|
|
public delegate void ReloadPasswords();
|
|
public partial class NewProfileForm : Form
|
|
{
|
|
public event NewProfile? NewProfileRequest;
|
|
public event ReloadPasswords? ReloadMainFormRequest;
|
|
public event Save? SaveRequest;
|
|
|
|
public NewProfileForm()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void ChooseFolder(object sender, EventArgs e)
|
|
{
|
|
FolderBrowserDialog dialog = new FolderBrowserDialog();
|
|
if (dialog.ShowDialog() == DialogResult.OK)
|
|
{
|
|
pathTextBox.Text = dialog.SelectedPath;
|
|
}
|
|
}
|
|
|
|
private void Save(object sender, EventArgs e)
|
|
{
|
|
if (nameTextBox.Text != "" && pathTextBox.Text != "")
|
|
{
|
|
NewProfileRequest?.Invoke(nameTextBox.Text, pathTextBox.Text);
|
|
ReloadMainFormRequest?.Invoke();
|
|
this.Close();
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("You must fill in all fields to continue.", "Error: Empty fields", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
|
|
SaveRequest?.Invoke();
|
|
}
|
|
|
|
private void Cancel(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
}
|
|
}
|