44 lines
1.3 KiB
C#
44 lines
1.3 KiB
C#
namespace Password_Manager
|
|
{
|
|
public delegate void NewProfile(string profileName, string profilePath);
|
|
public delegate void ReloadPasswords();
|
|
public partial class NewProfileForm : Form
|
|
{
|
|
public event NewProfile NewProfileRequest;
|
|
public event ReloadPasswords ReloadPasswordsRequest;
|
|
|
|
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);
|
|
ReloadPasswordsRequest?.Invoke();
|
|
this.Close();
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("You must fill in all fields to continue.", "Error: Empty fields", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
|
|
private void Cancel(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
}
|
|
}
|