mirror of
https://github.com/Crypto-Notepad/Crypto-Notepad.git
synced 2026-03-11 08:55:25 +00:00
Repeatable code was moved to a separate method
This commit is contained in:
parent
9435d311c2
commit
da954934f9
1 changed files with 20 additions and 25 deletions
|
|
@ -14,40 +14,38 @@ public ChangeKeyForm()
|
||||||
statusLabel.Text = "";
|
statusLabel.Text = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Buttons*/
|
#region Methods
|
||||||
private async void AcceptButton_Click(object sender, EventArgs e)
|
private async void ChangePasswordStatus(string message, Color color)
|
||||||
|
{
|
||||||
|
statusLabel.ForeColor = color;
|
||||||
|
statusLabel.Text = message;
|
||||||
|
oldKeyTextBox.Text = "";
|
||||||
|
newKeyTextBox.Text = "";
|
||||||
|
await Task.Delay(2500);
|
||||||
|
statusLabel.Text = "";
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region Event Handlers
|
||||||
|
private void AcceptButton_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
oldKeyTextBox.Focus();
|
oldKeyTextBox.Focus();
|
||||||
if (oldKeyTextBox.Text == PublicVar.password.Get() & oldKeyTextBox.Text != newKeyTextBox.Text)
|
if (oldKeyTextBox.Text == PublicVar.password.Get() & oldKeyTextBox.Text != newKeyTextBox.Text)
|
||||||
{
|
{
|
||||||
PublicVar.password.Set(newKeyTextBox.Text);
|
PublicVar.password.Set(newKeyTextBox.Text);
|
||||||
PublicVar.passwordChanged = true;
|
PublicVar.passwordChanged = true;
|
||||||
statusLabel.ForeColor = Color.Green;
|
ChangePasswordStatus("Password was successfully changed", Color.Green);
|
||||||
statusLabel.Text = "Password was successfully changed";
|
|
||||||
oldKeyTextBox.Text = "";
|
|
||||||
newKeyTextBox.Text = "";
|
|
||||||
await Task.Delay(3000);
|
|
||||||
statusLabel.Text = "";
|
|
||||||
}
|
}
|
||||||
else if (oldKeyTextBox.Text != PublicVar.password.Get())
|
else if (oldKeyTextBox.Text != PublicVar.password.Get())
|
||||||
{
|
{
|
||||||
SystemSounds.Hand.Play();
|
SystemSounds.Hand.Play();
|
||||||
statusLabel.ForeColor = Color.Red;
|
ChangePasswordStatus("Invalid old password", Color.Red);
|
||||||
statusLabel.Text = "Invalid old password";
|
|
||||||
oldKeyTextBox.Text = "";
|
|
||||||
newKeyTextBox.Text = "";
|
|
||||||
await Task.Delay(2000);
|
|
||||||
statusLabel.Text = "";
|
|
||||||
}
|
}
|
||||||
else if(oldKeyTextBox.Text == newKeyTextBox.Text)
|
else if (oldKeyTextBox.Text == newKeyTextBox.Text)
|
||||||
{
|
{
|
||||||
SystemSounds.Hand.Play();
|
SystemSounds.Hand.Play();
|
||||||
statusLabel.ForeColor = Color.Red;
|
ChangePasswordStatus("New password is the same as old", Color.Red);
|
||||||
statusLabel.Text = "New password is the same as old";
|
|
||||||
oldKeyTextBox.Text = "";
|
|
||||||
newKeyTextBox.Text = "";
|
|
||||||
await Task.Delay(2000);
|
|
||||||
statusLabel.Text = "";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -60,10 +58,7 @@ private void PasswordGeneratorButton_Click(object sender, EventArgs e)
|
||||||
passwordGeneratorFrom.Show(this);
|
passwordGeneratorFrom.Show(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*Buttons*/
|
|
||||||
|
|
||||||
|
|
||||||
/*Enter keys area*/
|
|
||||||
private void ShowOldKeyPictureBox_Click(object sender, EventArgs e)
|
private void ShowOldKeyPictureBox_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (oldKeyTextBox.UseSystemPasswordChar)
|
if (oldKeyTextBox.UseSystemPasswordChar)
|
||||||
|
|
@ -148,7 +143,7 @@ private void OldKeyTextBox_KeyDown(object sender, KeyEventArgs e)
|
||||||
AcceptButton_Click(sender, e);
|
AcceptButton_Click(sender, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*Enter keys area*/
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue