From 0a52852435d0ee6b1d5376a60ac32e504e5fc4a9 Mon Sep 17 00:00:00 2001 From: Alexander Date: Mon, 11 Nov 2019 19:42:18 +0200 Subject: [PATCH] Fixed bug when did not appear save dialog on app close #46 --- Crypto Notepad/MainForm.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Crypto Notepad/MainForm.cs b/Crypto Notepad/MainForm.cs index 9e50738..6b51c7d 100644 --- a/Crypto Notepad/MainForm.cs +++ b/Crypto Notepad/MainForm.cs @@ -789,6 +789,28 @@ private void MainWindow_FormClosing(object sender, FormClosingEventArgs e) DialogResult res = MessageBox.Show(this, messageBoxText, PublicVar.appName, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (res == DialogResult.Yes) { + if (string.IsNullOrEmpty(filePath)) + { + saveFileDialog.FileName = "Unnamed.cnp"; + if (saveFileDialog.ShowDialog() != DialogResult.OK) + { + e.Cancel = true; + return; + } + EnterKeyForm enterKeyForm = new EnterKeyForm + { + Owner = this + }; + enterKeyForm.ShowDialog(); + if (!PublicVar.okPressed) + { + PublicVar.openFileName = Path.GetFileName(filePath); + e.Cancel = true; + return; + } + PublicVar.encryptionKey.Set(TypedPassword.Value); + filePath = saveFileDialog.FileName; + } Hide(); trayIcon.Visible = false; using (StreamWriter writer = new StreamWriter(filePath))