Fixed bug when did not appear save dialog on app close #46

This commit is contained in:
Alexander 2019-11-11 19:42:18 +02:00
parent 1ad5ddbb4e
commit 0a52852435

View file

@ -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))