Added warning when closing PKHeX with unsaved changes (#327)

* Added warning when closing PKHeX with unsaved changes

* Changed to MessageBox.Show to Util.Prompt
This commit is contained in:
Evan Dixon 2016-10-18 12:44:36 -05:00 committed by Kaphotics
parent 0b7d108245
commit 475aad5480
2 changed files with 13 additions and 0 deletions

View file

@ -5647,6 +5647,7 @@
this.Name = "Main";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "PKHeX";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Main_FormClosing);
this.DragDrop += new System.Windows.Forms.DragEventHandler(this.tabMain_DragDrop);
this.DragEnter += new System.Windows.Forms.DragEventHandler(this.tabMain_DragEnter);
this.tabMain.ResumeLayout(false);

View file

@ -2994,6 +2994,17 @@ namespace PKHeX
Cursor = DefaultCursor;
}
private void Main_FormClosing(object sender, FormClosingEventArgs e)
{
if (SAV.Edited)
{
if (Util.Prompt(MessageBoxButtons.YesNo, "Any unsaved changes will be lost. Are you sure you want to close PKHeX?") != DialogResult.Yes)
{
e.Cancel = true;
}
}
}
#endregion
#region //// SAVE FILE FUNCTIONS ////
@ -3054,6 +3065,7 @@ namespace PKHeX
bool dsv = Path.GetExtension(main.FileName)?.ToLower() == ".dsv";
File.WriteAllBytes(main.FileName, SAV.Write(dsv));
SAV.Edited = false;
Util.Alert("SAV exported to:", main.FileName);
}