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*/
|
2019-10-11 10:39:15 +00:00
|
|
|
|
private async void BtnAccept_Click(object sender, EventArgs e)
|
2016-01-07 16:45:32 +00:00
|
|
|
|
{
|
2019-10-11 10:39:15 +00:00
|
|
|
|
if (txtOldKey.Text == PublicVar.encryptionKey.Get() && txtOldKey.Text != txtNewKey.Text)
|
2016-01-07 16:45:32 +00:00
|
|
|
|
{
|
2019-10-11 10:39:15 +00:00
|
|
|
|
PublicVar.encryptionKey.Set(txtNewKey.Text);
|
2018-12-17 11:04:26 +00:00
|
|
|
|
PublicVar.keyChanged = true;
|
2019-10-11 10:39:15 +00:00
|
|
|
|
txtOldKey.Text = "";
|
|
|
|
|
|
txtNewKey.Text = "";
|
|
|
|
|
|
lblStatus.Text = "Key was successfully changed";
|
|
|
|
|
|
lblStatus.Visible = true;
|
|
|
|
|
|
btnAccept.Enabled = false;
|
2016-01-25 12:49:40 +00:00
|
|
|
|
await Task.Delay(2000);
|
2019-10-11 10:39:15 +00:00
|
|
|
|
lblStatus.Text = "";
|
2016-01-22 19:41:31 +00:00
|
|
|
|
return;
|
2016-01-07 16:45:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2019-10-11 10:39:15 +00:00
|
|
|
|
if (txtOldKey.Text != PublicVar.encryptionKey.Get())
|
2016-01-07 16:45:32 +00:00
|
|
|
|
{
|
2016-01-25 18:22:58 +00:00
|
|
|
|
SystemSounds.Beep.Play();
|
2019-10-11 10:39:15 +00:00
|
|
|
|
lblStatus.Text = "Invalid old key";
|
|
|
|
|
|
lblStatus.Visible = true;
|
|
|
|
|
|
txtOldKey.Text = "";
|
|
|
|
|
|
txtNewKey.Text = "";
|
2016-01-22 17:42:13 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-10-11 10:39:15 +00:00
|
|
|
|
if (txtOldKey.Text == txtNewKey.Text)
|
2016-01-22 17:42:13 +00:00
|
|
|
|
{
|
2016-01-25 18:22:58 +00:00
|
|
|
|
SystemSounds.Beep.Play();
|
2019-10-11 10:39:15 +00:00
|
|
|
|
lblStatus.Text = "New key is the same as old";
|
|
|
|
|
|
lblStatus.Visible = true;
|
|
|
|
|
|
txtOldKey.Text = "";
|
|
|
|
|
|
txtNewKey.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-10-11 10:39:15 +00:00
|
|
|
|
private void PicOldKeyEyeIcon_Click(object sender, EventArgs e)
|
2016-01-07 16:45:32 +00:00
|
|
|
|
{
|
2019-10-11 10:39:15 +00:00
|
|
|
|
if (txtOldKey.UseSystemPasswordChar)
|
2016-01-07 16:45:32 +00:00
|
|
|
|
{
|
2019-10-11 10:39:15 +00:00
|
|
|
|
txtOldKey.UseSystemPasswordChar = false;
|
|
|
|
|
|
picOldKey.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-10-11 10:39:15 +00:00
|
|
|
|
txtOldKey.UseSystemPasswordChar = true;
|
|
|
|
|
|
picOldKey.Image = Properties.Resources.eye_half;
|
2016-01-07 16:45:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-10-11 10:39:15 +00:00
|
|
|
|
private void PicNewKeyEyeIcon_Click(object sender, EventArgs e)
|
2016-01-07 16:45:32 +00:00
|
|
|
|
{
|
2019-10-11 10:39:15 +00:00
|
|
|
|
if (txtNewKey.UseSystemPasswordChar)
|
2016-01-07 16:45:32 +00:00
|
|
|
|
{
|
2019-10-11 10:39:15 +00:00
|
|
|
|
txtNewKey.UseSystemPasswordChar = false;
|
|
|
|
|
|
picNewKey.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-10-11 10:39:15 +00:00
|
|
|
|
txtNewKey.UseSystemPasswordChar = true;
|
|
|
|
|
|
picNewKey.Image = Properties.Resources.eye_half;
|
2016-01-07 16:45:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2016-01-10 12:29:19 +00:00
|
|
|
|
|
2019-10-11 10:39:15 +00:00
|
|
|
|
private void TxtOldKey_TextChanged(object sender, EventArgs e)
|
2016-01-20 19:24:04 +00:00
|
|
|
|
{
|
2019-10-11 10:39:15 +00:00
|
|
|
|
if (txtOldKey.Text.Length > 0 && txtNewKey.Text.Length > 0)
|
2016-01-20 19:24:04 +00:00
|
|
|
|
{
|
2019-10-11 10:39:15 +00:00
|
|
|
|
btnAccept.Enabled = true;
|
2016-01-20 19:24:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2019-10-11 10:39:15 +00:00
|
|
|
|
btnAccept.Enabled = false;
|
2016-01-20 19:24:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-10-11 10:39:15 +00:00
|
|
|
|
private void TxtNewKey_TextChanged(object sender, EventArgs e)
|
2016-01-20 19:24:04 +00:00
|
|
|
|
{
|
2019-10-11 10:39:15 +00:00
|
|
|
|
if (txtNewKey.Text.Length > 0 && txtOldKey.Text.Length > 0)
|
2016-01-20 19:24:04 +00:00
|
|
|
|
{
|
2019-10-11 10:39:15 +00:00
|
|
|
|
btnAccept.Enabled = true;
|
2016-01-20 19:24:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2019-10-11 10:39:15 +00:00
|
|
|
|
btnAccept.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
|
|
|
|
}
|
|
|
|
|
|
}
|