Crypto-Notepad/Crypto Notepad/ChangeKeyForm.cs

117 lines
3.3 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();
}
private async void button1_Click(object sender, EventArgs e)
2016-01-07 16:45:32 +00:00
{
if (textBox1.Text == publicVar.encryptionKey & textBox1.Text != textBox2.Text)
2016-01-07 16:45:32 +00:00
{
publicVar.encryptionKey = textBox2.Text;
publicVar.keyChanged = true;
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
}
if (textBox1.Text != publicVar.encryptionKey)
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;
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();
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)
{
if (textBox1.UseSystemPasswordChar == true)
{
textBox1.UseSystemPasswordChar = false;
2016-01-11 17:56:14 +00:00
pictureBox1.Image = Properties.Resources.eye_half;
2016-01-07 16:45:32 +00:00
return;
}
if (textBox1.UseSystemPasswordChar == false)
{
textBox1.UseSystemPasswordChar = true;
2016-01-11 17:56:14 +00:00
pictureBox1.Image = Properties.Resources.eye;
2016-01-07 16:45:32 +00:00
return;
}
}
private void pictureBox2_Click(object sender, EventArgs e)
{
if (textBox2.UseSystemPasswordChar == true)
{
textBox2.UseSystemPasswordChar = false;
2016-01-11 17:56:14 +00:00
pictureBox2.Image = Properties.Resources.eye_half;
2016-01-07 16:45:32 +00:00
return;
}
if (textBox2.UseSystemPasswordChar == false)
{
textBox2.UseSystemPasswordChar = true;
2016-01-11 17:56:14 +00:00
pictureBox2.Image = Properties.Resources.eye;
2016-01-07 16:45:32 +00:00
return;
}
}
2016-01-10 12:29:19 +00:00
private void ChangeKeyForm_Load(object sender, EventArgs e)
{
}
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
}
}