2016-01-07 16:45:32 +00:00
|
|
|
|
using System;
|
2016-01-25 18:22:58 +00:00
|
|
|
|
using System.Media;
|
2016-01-25 12:49:40 +00:00
|
|
|
|
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();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-12-25 15:55:15 +00:00
|
|
|
|
/*Buttons*/
|
|
|
|
|
|
private async void AcceptButton_Click(object sender, EventArgs e)
|
2016-01-07 16:45:32 +00:00
|
|
|
|
{
|
2019-09-28 19:57:03 +00:00
|
|
|
|
if (oldKeyTextBox.Text == PublicVar.encryptionKey.Get() && oldKeyTextBox.Text != newKeyTextBox.Text)
|
2016-01-07 16:45:32 +00:00
|
|
|
|
{
|
2019-09-28 19:57:03 +00:00
|
|
|
|
PublicVar.encryptionKey.Set(newKeyTextBox.Text);
|
2018-12-17 11:04:26 +00:00
|
|
|
|
PublicVar.keyChanged = true;
|
2019-09-28 19:57:03 +00:00
|
|
|
|
oldKeyTextBox.Text = "";
|
|
|
|
|
|
newKeyTextBox.Text = "";
|
|
|
|
|
|
statusLabel.Text = "Key was successfully changed";
|
|
|
|
|
|
statusLabel.Visible = true;
|
|
|
|
|
|
acceptButton.Enabled = false;
|
2016-01-25 12:49:40 +00:00
|
|
|
|
await Task.Delay(2000);
|
2019-09-28 19:57:03 +00:00
|
|
|
|
statusLabel.Text = "";
|
2016-01-22 19:41:31 +00:00
|
|
|
|
return;
|
2016-01-07 16:45:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2019-09-28 19:57:03 +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();
|
2019-09-28 19:57:03 +00:00
|
|
|
|
statusLabel.Text = "Invalid old key";
|
|
|
|
|
|
statusLabel.Visible = true;
|
|
|
|
|
|
oldKeyTextBox.Text = "";
|
|
|
|
|
|
newKeyTextBox.Text = "";
|
2016-01-22 17:42:13 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-09-28 19:57:03 +00:00
|
|
|
|
if (oldKeyTextBox.Text == newKeyTextBox.Text)
|
2016-01-22 17:42:13 +00:00
|
|
|
|
{
|
2016-01-25 18:22:58 +00:00
|
|
|
|
SystemSounds.Beep.Play();
|
2019-09-28 19:57:03 +00:00
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-12-25 15:55:15 +00:00
|
|
|
|
/*Buttons*/
|
2016-01-07 16:45:32 +00:00
|
|
|
|
|
2018-12-25 15:55:15 +00:00
|
|
|
|
|
|
|
|
|
|
/*Enter keys area*/
|
2019-09-28 19:57:03 +00:00
|
|
|
|
private void OldKeyEyeIcon_Click(object sender, EventArgs e)
|
2016-01-07 16:45:32 +00:00
|
|
|
|
{
|
2019-09-28 19:57:03 +00:00
|
|
|
|
if (oldKeyTextBox.UseSystemPasswordChar)
|
2016-01-07 16:45:32 +00:00
|
|
|
|
{
|
2019-09-28 19:57:03 +00:00
|
|
|
|
oldKeyTextBox.UseSystemPasswordChar = false;
|
|
|
|
|
|
oldKeyEyeIcon.Image = Properties.Resources.eye;
|
2016-01-07 16:45:32 +00:00
|
|
|
|
}
|
2018-12-25 15:55:15 +00:00
|
|
|
|
else
|
2016-01-07 16:45:32 +00:00
|
|
|
|
{
|
2019-09-28 19:57:03 +00:00
|
|
|
|
oldKeyTextBox.UseSystemPasswordChar = true;
|
|
|
|
|
|
oldKeyEyeIcon.Image = Properties.Resources.eye_half;
|
2016-01-07 16:45:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-09-28 19:57:03 +00:00
|
|
|
|
private void NewKeyEyeIcon_Click(object sender, EventArgs e)
|
2016-01-07 16:45:32 +00:00
|
|
|
|
{
|
2019-09-28 19:57:03 +00:00
|
|
|
|
if (newKeyTextBox.UseSystemPasswordChar)
|
2016-01-07 16:45:32 +00:00
|
|
|
|
{
|
2019-09-28 19:57:03 +00:00
|
|
|
|
newKeyTextBox.UseSystemPasswordChar = false;
|
|
|
|
|
|
newKeyEyeIcon.Image = Properties.Resources.eye;
|
2016-01-07 16:45:32 +00:00
|
|
|
|
}
|
2018-12-25 15:55:15 +00:00
|
|
|
|
else
|
2016-01-07 16:45:32 +00:00
|
|
|
|
{
|
2019-09-28 19:57:03 +00:00
|
|
|
|
newKeyTextBox.UseSystemPasswordChar = true;
|
|
|
|
|
|
newKeyEyeIcon.Image = Properties.Resources.eye_half;
|
2016-01-07 16:45:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2016-01-10 12:29:19 +00:00
|
|
|
|
|
2018-12-25 15:55:15 +00:00
|
|
|
|
private void OldKeyTextBox_TextChanged(object sender, EventArgs e)
|
2016-01-20 19:24:04 +00:00
|
|
|
|
{
|
2019-09-28 19:57:03 +00:00
|
|
|
|
if (oldKeyTextBox.Text.Length > 0 && newKeyTextBox.Text.Length > 0)
|
2016-01-20 19:24:04 +00:00
|
|
|
|
{
|
2019-09-28 19:57:03 +00:00
|
|
|
|
acceptButton.Enabled = true;
|
2016-01-20 19:24:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2019-09-28 19:57:03 +00:00
|
|
|
|
acceptButton.Enabled = false;
|
2016-01-20 19:24:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-12-25 15:55:15 +00:00
|
|
|
|
private void NewKeyTextBox_TextChanged(object sender, EventArgs e)
|
2016-01-20 19:24:04 +00:00
|
|
|
|
{
|
2019-09-28 19:57:03 +00:00
|
|
|
|
if (newKeyTextBox.Text.Length > 0 && oldKeyTextBox.Text.Length > 0)
|
2016-01-20 19:24:04 +00:00
|
|
|
|
{
|
2019-09-28 19:57:03 +00:00
|
|
|
|
acceptButton.Enabled = true;
|
2016-01-20 19:24:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2019-09-28 19:57:03 +00:00
|
|
|
|
acceptButton.Enabled = false;
|
2016-01-20 19:24:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-12-25 15:55:15 +00:00
|
|
|
|
/*Enter keys area*/
|
2016-01-07 16:45:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|