Changing key notifications were changed

This commit is contained in:
Sigmanor 2016-01-25 14:49:40 +02:00
parent 7efb253534
commit f809796645
2 changed files with 30 additions and 11 deletions

View file

@ -37,6 +37,7 @@ private void InitializeComponent()
this.pictureBox3 = new System.Windows.Forms.PictureBox();
this.pictureBox2 = new System.Windows.Forms.PictureBox();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.statusLabel = new System.Windows.Forms.Label();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox3)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit();
@ -82,9 +83,9 @@ private void InitializeComponent()
// button1
//
this.button1.Enabled = false;
this.button1.Location = new System.Drawing.Point(182, 82);
this.button1.Location = new System.Drawing.Point(206, 82);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.Size = new System.Drawing.Size(53, 23);
this.button1.TabIndex = 4;
this.button1.Text = "Accept";
this.button1.UseVisualStyleBackColor = true;
@ -142,11 +143,24 @@ private void InitializeComponent()
this.pictureBox1.TabStop = false;
this.pictureBox1.Click += new System.EventHandler(this.pictureBox1_Click);
//
// statusLabel
//
this.statusLabel.AutoSize = true;
this.statusLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
this.statusLabel.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(35)))));
this.statusLabel.Location = new System.Drawing.Point(5, 88);
this.statusLabel.Name = "statusLabel";
this.statusLabel.Size = new System.Drawing.Size(35, 13);
this.statusLabel.TabIndex = 7;
this.statusLabel.Text = "status";
this.statusLabel.Visible = false;
//
// ChangeKeyForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(263, 111);
this.Controls.Add(this.statusLabel);
this.Controls.Add(this.panel1);
this.Controls.Add(this.button1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
@ -162,6 +176,7 @@ private void InitializeComponent()
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
@ -176,5 +191,6 @@ private void InitializeComponent()
private System.Windows.Forms.PictureBox pictureBox2;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.PictureBox pictureBox3;
private System.Windows.Forms.Label statusLabel;
}
}

View file

@ -1,4 +1,5 @@
using System;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Crypto_Notepad
@ -10,22 +11,26 @@ public ChangeKeyForm()
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
private async void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text == MainWindow.key & textBox1.Text != textBox2.Text)
{
MainWindow.key = textBox2.Text;
MainWindow.keyChanged = true;
textBox1.Text = "";
textBox2.Text = "";
statusLabel.Text = "Key was successfully changed!";
statusLabel.Visible = true;
button1.Enabled = false;
await Task.Delay(2000);
this.Close();
return;
}
if (textBox1.Text != MainWindow.key)
{
using (new CenterWinDialog(this))
{
MessageBox.Show("Invalid old key!", "Change Key", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
statusLabel.Text = "Invalid old key!";
statusLabel.Visible = true;
textBox1.Text = "";
textBox2.Text = "";
return;
@ -33,10 +38,8 @@ private void button1_Click(object sender, EventArgs e)
if (textBox1.Text == textBox2.Text)
{
using (new CenterWinDialog(this))
{
MessageBox.Show("New key is the same as old!", "Change Key", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
statusLabel.Text = "New key is the same as old!";
statusLabel.Visible = true;
textBox1.Text = "";
textBox2.Text = "";
return;