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();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-01-25 12:49:40 +00:00
|
|
|
|
private async void button1_Click(object sender, EventArgs e)
|
2016-01-07 16:45:32 +00:00
|
|
|
|
{
|
2018-12-01 02:29:19 +00:00
|
|
|
|
if (textBox1.Text == publicVar.encryptionKey.Get() & textBox1.Text != textBox2.Text)
|
2016-01-07 16:45:32 +00:00
|
|
|
|
{
|
2018-12-01 02:29:19 +00:00
|
|
|
|
publicVar.encryptionKey.Set(textBox2.Text);
|
2016-01-26 17:07:17 +00:00
|
|
|
|
publicVar.keyChanged = true;
|
2016-01-25 12:49:40 +00:00
|
|
|
|
textBox1.Text = "";
|
|
|
|
|
|
textBox2.Text = "";
|
|
|
|
|
|
statusLabel.Text = "Key was successfully changed!";
|
|
|
|
|
|
statusLabel.Visible = true;
|
|
|
|
|
|
button1.Enabled = false;
|
|
|
|
|
|
await Task.Delay(2000);
|
2016-01-07 16:45:32 +00:00
|
|
|
|
this.Close();
|
2016-01-22 19:41:31 +00:00
|
|
|
|
return;
|
2016-01-07 16:45:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-12-01 02:29:19 +00:00
|
|
|
|
if (textBox1.Text != publicVar.encryptionKey.Get())
|
2016-01-07 16:45:32 +00:00
|
|
|
|
{
|
2016-01-25 18:22:58 +00:00
|
|
|
|
SystemSounds.Beep.Play();
|
2016-01-25 12:49:40 +00:00
|
|
|
|
statusLabel.Text = "Invalid old key!";
|
|
|
|
|
|
statusLabel.Visible = true;
|
2016-01-22 17:42:13 +00:00
|
|
|
|
textBox1.Text = "";
|
|
|
|
|
|
textBox2.Text = "";
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (textBox1.Text == textBox2.Text)
|
|
|
|
|
|
{
|
2016-01-25 18:22:58 +00:00
|
|
|
|
SystemSounds.Beep.Play();
|
2016-01-25 12:49:40 +00:00
|
|
|
|
statusLabel.Text = "New key is the same as old!";
|
|
|
|
|
|
statusLabel.Visible = true;
|
2016-01-22 17:42:13 +00:00
|
|
|
|
textBox1.Text = "";
|
|
|
|
|
|
textBox2.Text = "";
|
|
|
|
|
|
return;
|
2016-01-07 16:45:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void pictureBox1_Click(object sender, EventArgs e)
|
|
|
|
|
|
{
|
2018-12-09 14:08:07 +00:00
|
|
|
|
if (textBox1.UseSystemPasswordChar)
|
2016-01-07 16:45:32 +00:00
|
|
|
|
{
|
|
|
|
|
|
textBox1.UseSystemPasswordChar = false;
|
2018-12-09 14:08:07 +00:00
|
|
|
|
pictureBox1.Image = Properties.Resources.eye;
|
2016-01-07 16:45:32 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-12-09 14:08:07 +00:00
|
|
|
|
if (!textBox1.UseSystemPasswordChar)
|
2016-01-07 16:45:32 +00:00
|
|
|
|
{
|
|
|
|
|
|
textBox1.UseSystemPasswordChar = true;
|
2018-12-09 14:08:07 +00:00
|
|
|
|
pictureBox1.Image = Properties.Resources.eye_half;
|
2016-01-07 16:45:32 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void pictureBox2_Click(object sender, EventArgs e)
|
|
|
|
|
|
{
|
2018-12-09 14:08:07 +00:00
|
|
|
|
if (textBox2.UseSystemPasswordChar)
|
2016-01-07 16:45:32 +00:00
|
|
|
|
{
|
|
|
|
|
|
textBox2.UseSystemPasswordChar = false;
|
2018-12-09 14:08:07 +00:00
|
|
|
|
pictureBox2.Image = Properties.Resources.eye;
|
2016-01-07 16:45:32 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-12-09 14:08:07 +00:00
|
|
|
|
if (!textBox2.UseSystemPasswordChar)
|
2016-01-07 16:45:32 +00:00
|
|
|
|
{
|
|
|
|
|
|
textBox2.UseSystemPasswordChar = true;
|
2018-12-09 14:08:07 +00:00
|
|
|
|
pictureBox2.Image = Properties.Resources.eye_half;
|
2016-01-07 16:45:32 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2016-01-10 12:29:19 +00:00
|
|
|
|
|
2016-01-20 19:24:04 +00:00
|
|
|
|
private void textBox1_TextChanged(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (textBox1.Text.Length > 0 & textBox2.Text.Length > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
button1.Enabled = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
button1.Enabled = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void textBox2_TextChanged(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (textBox1.Text.Length > 0 & textBox2.Text.Length > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
button1.Enabled = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
button1.Enabled = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-01-07 16:45:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|