mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-27 14:30:56 +00:00
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:
parent
0b7d108245
commit
475aad5480
2 changed files with 13 additions and 0 deletions
1
PKHeX/MainWindow/Main.Designer.cs
generated
1
PKHeX/MainWindow/Main.Designer.cs
generated
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue