From 1c531b067346022640bb7bef3ec16ae5a009dca0 Mon Sep 17 00:00:00 2001 From: Kaphotics Date: Thu, 7 Apr 2016 22:16:08 -0700 Subject: [PATCH] Bring popup to front instead of alert Any call to open a form that is already open (special characters, box report, database) would alert that it's already open. Just bring it to the front. Since it may be hidden, just move it back into view (align to main program's top-left location) --- PKX/f1-Main.cs | 15 +++++++++------ SAV/SAV_Trainer.cs | 5 +++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/PKX/f1-Main.cs b/PKX/f1-Main.cs index 11ccb44fa..4ebcc24e4 100644 --- a/PKX/f1-Main.cs +++ b/PKX/f1-Main.cs @@ -302,8 +302,9 @@ namespace PKHeX } private void mainMenuBoxReport(object sender, EventArgs e) { - if (Application.OpenForms.Cast
().Any(form => form.Name == typeof(frmReport).Name)) - { Util.Alert("Window is already open."); return; } + var z = Application.OpenForms.Cast().FirstOrDefault(form => form.Name == typeof(frmReport).Name) as frmReport; + if (z != null) + { z.Location = Location; z.BringToFront(); return; } frmReport ReportForm = new frmReport(); ReportForm.Show(); @@ -311,8 +312,9 @@ namespace PKHeX } private void mainMenuDatabase(object sender, EventArgs e) { - if (Application.OpenForms.Cast().Any(form => form.Name == typeof(SAV_Database).Name)) - { Util.Alert("Window is already open."); return; } + var z = Application.OpenForms.Cast().FirstOrDefault(form => form.Name == typeof(SAV_Database).Name) as SAV_Database; + if (z != null) + { z.Location = Location; z.BringToFront(); return; } if (Directory.Exists("db")) new SAV_Database(this).Show(); @@ -1986,8 +1988,9 @@ namespace PKHeX if (ModifierKeys != Keys.Control) return; - if (Application.OpenForms.Cast().Any(form => form.Name == typeof(f2_Text).Name)) - { Util.Alert("Window is already open."); return; } + var z = Application.OpenForms.Cast().FirstOrDefault(form => form.Name == typeof(f2_Text).Name) as f2_Text; + if (z != null) + { z.Location = Location; z.BringToFront(); return; } new f2_Text(tb).Show(); } private void updateNotOT(object sender, EventArgs e) diff --git a/SAV/SAV_Trainer.cs b/SAV/SAV_Trainer.cs index de6d7b0d7..6987f50ec 100644 --- a/SAV/SAV_Trainer.cs +++ b/SAV/SAV_Trainer.cs @@ -547,8 +547,9 @@ namespace PKHeX if (ModifierKeys != Keys.Control) return; - if (Application.OpenForms.Cast().Any(form => form.Name == typeof(f2_Text).Name)) - { Util.Alert("Window is already open."); return; } + var z = Application.OpenForms.Cast().FirstOrDefault(form => form.Name == typeof(f2_Text).Name) as f2_Text; + if (z != null) + { z.Location = Location; z.BringToFront(); return; } new f2_Text(tb).Show(); } private void showTSV(object sender, EventArgs e)