Code review

This commit is contained in:
Alexander 2018-12-17 13:04:26 +02:00
parent 5fab54873a
commit 27a40f08fa
5 changed files with 10 additions and 19 deletions

View file

@ -14,10 +14,10 @@ public ChangeKeyForm()
private async void button1_Click(object sender, EventArgs e) private async void button1_Click(object sender, EventArgs e)
{ {
if (textBox1.Text == publicVar.encryptionKey.Get() & textBox1.Text != textBox2.Text) if (textBox1.Text == PublicVar.encryptionKey.Get() & textBox1.Text != textBox2.Text)
{ {
publicVar.encryptionKey.Set(textBox2.Text); PublicVar.encryptionKey.Set(textBox2.Text);
publicVar.keyChanged = true; PublicVar.keyChanged = true;
textBox1.Text = ""; textBox1.Text = "";
textBox2.Text = ""; textBox2.Text = "";
statusLabel.Text = "Key was successfully changed"; statusLabel.Text = "Key was successfully changed";
@ -25,11 +25,10 @@ private async void button1_Click(object sender, EventArgs e)
button1.Enabled = false; button1.Enabled = false;
await Task.Delay(2000); await Task.Delay(2000);
statusLabel.Text = ""; statusLabel.Text = "";
//this.Close();
return; return;
} }
if (textBox1.Text != publicVar.encryptionKey.Get()) if (textBox1.Text != PublicVar.encryptionKey.Get())
{ {
SystemSounds.Beep.Play(); SystemSounds.Beep.Play();
statusLabel.Text = "Invalid old key"; statusLabel.Text = "Invalid old key";

View file

@ -1,8 +1,4 @@
using System; using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Security.Cryptography; using System.Security.Cryptography;
namespace Crypto_Notepad namespace Crypto_Notepad

View file

@ -133,13 +133,12 @@ private void InitializeComponent()
} }
#endregion #endregion
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button1;
private System.Windows.Forms.PictureBox pictureBox1; private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.ToolTip toolTip1; private System.Windows.Forms.ToolTip toolTip1;
private System.Windows.Forms.Panel panel1; private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label1;
private System.Windows.Forms.PictureBox pictureBox2; private System.Windows.Forms.PictureBox pictureBox2;
public System.Windows.Forms.TextBox textBox1;
} }
} }

View file

@ -8,16 +8,15 @@ public partial class Form2 : Form
public Form2() public Form2()
{ {
// Initialize to false in case user presses the exit button // Initialize to false in case user presses the exit button
publicVar.okPressed = false; PublicVar.okPressed = false;
InitializeComponent(); InitializeComponent();
} }
private void button1_Click(object sender, EventArgs e) private void button1_Click(object sender, EventArgs e)
{ {
publicVar.encryptionKey.Set(textBox1.Text); TypedPassword.Value = textBox1.Text;
textBox1.Focus(); textBox1.Focus();
textBox1.Text = ""; PublicVar.okPressed = true;
publicVar.okPressed = true;
this.Hide(); this.Hide();
} }
@ -57,12 +56,11 @@ private void pictureBox1_Click(object sender, EventArgs e)
private void Form2_FormClosed(object sender, FormClosedEventArgs e) private void Form2_FormClosed(object sender, FormClosedEventArgs e)
{ {
textBox1.Focus(); textBox1.Focus();
textBox1.Text = "";
} }
private void Form2_Load(object sender, EventArgs e) private void Form2_Load(object sender, EventArgs e)
{ {
this.Text = publicVar.openFileName; this.Text = PublicVar.openFileName;
} }
} }
} }

View file

@ -17,7 +17,6 @@ static void Main()
} }
} }
static class publicVar
static class PublicVar static class PublicVar
{ {
public static EncryptedString encryptionKey = new EncryptedString(); public static EncryptedString encryptionKey = new EncryptedString();