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

View file

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

View file

@ -133,13 +133,12 @@ private void InitializeComponent()
}
#endregion
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.ToolTip toolTip1;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Label label1;
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()
{
// Initialize to false in case user presses the exit button
publicVar.okPressed = false;
PublicVar.okPressed = false;
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
publicVar.encryptionKey.Set(textBox1.Text);
TypedPassword.Value = textBox1.Text;
textBox1.Focus();
textBox1.Text = "";
publicVar.okPressed = true;
PublicVar.okPressed = true;
this.Hide();
}
@ -57,12 +56,11 @@ private void pictureBox1_Click(object sender, EventArgs e)
private void Form2_FormClosed(object sender, FormClosedEventArgs e)
{
textBox1.Focus();
textBox1.Text = "";
}
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
{
public static EncryptedString encryptionKey = new EncryptedString();