Crypto-Notepad/Crypto Notepad/ChangeKeyForm.cs

110 lines
3.2 KiB
C#
Raw Normal View History

2016-01-07 16:45:32 +00:00
using System;
2016-01-25 18:22:58 +00:00
using System.Media;
using System.Threading.Tasks;
2016-01-07 16:45:32 +00:00
using System.Windows.Forms;
2016-01-09 20:46:25 +00:00
namespace Crypto_Notepad
2016-01-07 16:45:32 +00:00
{
public partial class ChangeKeyForm : Form
{
public ChangeKeyForm()
{
InitializeComponent();
}
/*Buttons*/
private async void AcceptButton_Click(object sender, EventArgs e)
2016-01-07 16:45:32 +00:00
{
if (OldKeyTextBox.Text == PublicVar.encryptionKey.Get() && OldKeyTextBox.Text != NewKeyTextBox.Text)
2016-01-07 16:45:32 +00:00
{
PublicVar.encryptionKey.Set(NewKeyTextBox.Text);
2018-12-17 11:04:26 +00:00
PublicVar.keyChanged = true;
OldKeyTextBox.Text = "";
NewKeyTextBox.Text = "";
StatusLabel.Text = "Key was successfully changed";
StatusLabel.Visible = true;
AcceptButton.Enabled = false;
await Task.Delay(2000);
StatusLabel.Text = "";
2016-01-22 19:41:31 +00:00
return;
2016-01-07 16:45:32 +00:00
}
if (OldKeyTextBox.Text != PublicVar.encryptionKey.Get())
2016-01-07 16:45:32 +00:00
{
2016-01-25 18:22:58 +00:00
SystemSounds.Beep.Play();
StatusLabel.Text = "Invalid old key";
StatusLabel.Visible = true;
OldKeyTextBox.Text = "";
NewKeyTextBox.Text = "";
2016-01-22 17:42:13 +00:00
return;
}
if (OldKeyTextBox.Text == NewKeyTextBox.Text)
2016-01-22 17:42:13 +00:00
{
2016-01-25 18:22:58 +00:00
SystemSounds.Beep.Play();
StatusLabel.Text = "New key is the same as old";
StatusLabel.Visible = true;
OldKeyTextBox.Text = "";
NewKeyTextBox.Text = "";
2016-01-22 17:42:13 +00:00
return;
2016-01-07 16:45:32 +00:00
}
}
/*Buttons*/
2016-01-07 16:45:32 +00:00
/*Enter keys area*/
private void EyePictureBox1_Click(object sender, EventArgs e)
2016-01-07 16:45:32 +00:00
{
if (OldKeyTextBox.UseSystemPasswordChar)
2016-01-07 16:45:32 +00:00
{
OldKeyTextBox.UseSystemPasswordChar = false;
EyePictureBox1.Image = Properties.Resources.eye;
2016-01-07 16:45:32 +00:00
}
else
2016-01-07 16:45:32 +00:00
{
OldKeyTextBox.UseSystemPasswordChar = true;
EyePictureBox1.Image = Properties.Resources.eye_half;
2016-01-07 16:45:32 +00:00
}
}
private void EyePictureBox2_Click(object sender, EventArgs e)
2016-01-07 16:45:32 +00:00
{
if (NewKeyTextBox.UseSystemPasswordChar)
2016-01-07 16:45:32 +00:00
{
NewKeyTextBox.UseSystemPasswordChar = false;
EyePictureBox2.Image = Properties.Resources.eye;
2016-01-07 16:45:32 +00:00
}
else
2016-01-07 16:45:32 +00:00
{
NewKeyTextBox.UseSystemPasswordChar = true;
EyePictureBox2.Image = Properties.Resources.eye_half;
2016-01-07 16:45:32 +00:00
}
}
2016-01-10 12:29:19 +00:00
private void OldKeyTextBox_TextChanged(object sender, EventArgs e)
{
if (OldKeyTextBox.Text.Length > 0)
{
AcceptButton.Enabled = true;
}
else
{
AcceptButton.Enabled = false;
}
}
private void NewKeyTextBox_TextChanged(object sender, EventArgs e)
{
if (NewKeyTextBox.Text.Length > 0)
{
AcceptButton.Enabled = true;
}
else
{
AcceptButton.Enabled = false;
}
}
/*Enter keys area*/
2016-01-07 16:45:32 +00:00
}
}