From 16a07484b9e32c8aff278a8c70174dfbc091dc30 Mon Sep 17 00:00:00 2001 From: Alexander Date: Sat, 9 Nov 2019 21:36:51 +0200 Subject: [PATCH] Source code was simplified --- Crypto Notepad/MainForm.cs | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/Crypto Notepad/MainForm.cs b/Crypto Notepad/MainForm.cs index 1269e0d..0c029d3 100644 --- a/Crypto Notepad/MainForm.cs +++ b/Crypto Notepad/MainForm.cs @@ -98,9 +98,7 @@ private async Task DecryptAES() richTextBox.Text = await AES.Decrypt(openedFileText, TypedPassword.Value, null, settings.HashAlgorithm, Convert.ToInt32(settings.PasswordIterations), Convert.ToInt32(settings.KeySize)); ; } - - string NameWithotPath = Path.GetFileName(openFileDialog.FileName); - Text = NameWithotPath + " – " + PublicVar.appName; + Text = Path.GetFileName(openFileDialog.FileName) + " – " + PublicVar.appName; filePath = openFileDialog.FileName; PublicVar.openFileName = Path.GetFileName(openFileDialog.FileName); PublicVar.encryptionKey.Set(TypedPassword.Value); @@ -163,11 +161,9 @@ private async void OpenAsotiations() MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (res == DialogResult.No) { - string opnfile = File.ReadAllText(args[1]); - string NameWithotPath = Path.GetFileName(args[1]); - richTextBox.Text = opnfile; + richTextBox.Text = File.ReadAllText(args[1]); ; filePath = args[1]; - Text = NameWithotPath + " – " + PublicVar.appName; + Text = Path.GetFileName(args[1]) + " – " + PublicVar.appName; StatusPanelFileInfo(); return; } @@ -191,11 +187,9 @@ private async void SendTo() MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (res == DialogResult.No) { - string opnfile = File.ReadAllText(argsPath); - string NameWithotPath = Path.GetFileName(argsPath); - richTextBox.Text = opnfile; + richTextBox.Text = File.ReadAllText(argsPath); filePath = argsPath; - Text = NameWithotPath + " – " + PublicVar.appName; + Text = Path.GetFileName(argsPath) + " – " + PublicVar.appName; StatusPanelFileInfo(); return; } @@ -948,10 +942,8 @@ private async void RichTextBox_DragDrop(object sender, DragEventArgs e) MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (res == DialogResult.No) { - string opnfile = File.ReadAllText(openFileDialog.FileName); - string NameWithotPath = Path.GetFileName(openFileDialog.FileName); - richTextBox.Text = opnfile; - Text = NameWithotPath + " – " + PublicVar.appName; + richTextBox.Text = File.ReadAllText(openFileDialog.FileName); + Text = Path.GetFileName(openFileDialog.FileName) + " – " + PublicVar.appName; filePath = openFileDialog.FileName; StatusPanelFileInfo(); return; @@ -1065,8 +1057,7 @@ private void NewMainMenu_Click(object sender, EventArgs e) saveFileDialog.FileName = "Unnamed.cnp"; PublicVar.encryptionKey.Set(TypedPassword.Value); StreamWriter sw = new StreamWriter(saveFileDialog.FileName); - string NameWithotPath = Path.GetFileName(saveFileDialog.FileName); - Text = NameWithotPath + " – " + PublicVar.appName; + Text = Path.GetFileName(saveFileDialog.FileName) + " – " + PublicVar.appName; filePath = saveFileDialog.FileName; PublicVar.openFileName = Path.GetFileName(saveFileDialog.FileName); sw.Close(); @@ -1098,10 +1089,8 @@ private async void OpenMainMenu_Click(object sender, EventArgs e) MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (res == DialogResult.No) { - string opnfile = File.ReadAllText(openFileDialog.FileName); - string NameWithotPath = Path.GetFileName(openFileDialog.FileName); - richTextBox.Text = opnfile; - Text = NameWithotPath + " – " + PublicVar.appName; + richTextBox.Text = File.ReadAllText(openFileDialog.FileName); + Text = Path.GetFileName(openFileDialog.FileName) + " – " + PublicVar.appName; filePath = openFileDialog.FileName; StatusPanelFileInfo(); return;