Don't show form if already open

Loop through all openforms to see if any are already open.
This commit is contained in:
Kaphotics
2016-01-29 18:02:54 -08:00
parent b95cbbbfce
commit be2b86e973
2 changed files with 15 additions and 9 deletions

View File

@@ -2799,7 +2799,7 @@ public void InitializeComponent()
this.Menu_Database.ShowShortcutKeys = false;
this.Menu_Database.Size = new System.Drawing.Size(151, 22);
this.Menu_Database.Text = "PK6 &Database";
this.Menu_Database.Click += new System.EventHandler(this.B_OpenDB_Click);
this.Menu_Database.Click += new System.EventHandler(this.mainMenuDatabase);
//
// Menu_Other
//

View File

@@ -294,10 +294,24 @@ private void mainMenuCodeGen(object sender, EventArgs e)
}
private void mainMenuBoxReport(object sender, EventArgs e)
{
if (Application.OpenForms.Cast<Form>().Any(form => form.Name == typeof(frmReport).Name))
{ Util.Alert("Window is already open."); return; }
frmReport ReportForm = new frmReport();
ReportForm.Show();
ReportForm.PopulateData(SAV.Data, SAV.Box);
}
private void mainMenuDatabase(object sender, EventArgs e)
{
if (Application.OpenForms.Cast<Form>().Any(form => form.Name == typeof(SAV_Database).Name))
{ Util.Alert("Window is already open."); return; }
if (Directory.Exists("db"))
new SAV_Database(this).Show();
else
Util.Alert("PKHeX's database was not found",
"Please dump all boxes from a save file, then ensure the 'db' folder exists.");
}
private void mainMenuUnicode(object sender, EventArgs e)
{
unicode = Menu_Unicode.Checked;
@@ -3247,14 +3261,6 @@ private void B_JPEG_Click(object sender, EventArgs e)
}
File.WriteAllBytes(path, jpeg);
}
private void B_OpenDB_Click(object sender, EventArgs e)
{
if (Directory.Exists("db"))
new SAV_Database(this).Show();
else
Util.Alert("PKHeX's database was not found",
"Please dump all boxes from a save file, then ensure the 'db' folder exists.");
}
// Save Folder Related
private void clickSaveFileName(object sender, EventArgs e)
{