diff --git a/Core/FormManager.cs b/Core/FormManager.cs
index 568cd6ff..eab58f45 100644
--- a/Core/FormManager.cs
+++ b/Core/FormManager.cs
@@ -1,6 +1,5 @@
using System.Linq;
using System.Windows.Forms;
-using TweetDuck.Core.Other;
namespace TweetDuck.Core{
static class FormManager{
@@ -18,12 +17,14 @@ namespace TweetDuck.Core{
else return false;
}
+ public static bool HasAnyDialogs => Application.OpenForms.OfType<IAppDialog>().Any();
+
public static void CloseAllDialogs(){
- foreach(Form form in Application.OpenForms.Cast<Form>().Reverse()){
- if (form is FormSettings || form is FormPlugins || form is FormAbout || form is FormGuide){
- form.Close();
- }
+ foreach(IAppDialog dialog in Application.OpenForms.OfType<IAppDialog>().Reverse()){
+ ((Form)dialog).Close();
}
}
+
+ public interface IAppDialog{}
}
}
diff --git a/Core/Other/FormAbout.cs b/Core/Other/FormAbout.cs
index edf06b41..7bb7fcab 100644
--- a/Core/Other/FormAbout.cs
+++ b/Core/Other/FormAbout.cs
@@ -5,7 +5,7 @@ using System.Windows.Forms;
using TweetDuck.Core.Utils;
namespace TweetDuck.Core.Other{
- sealed partial class FormAbout : Form{
+ sealed partial class FormAbout : Form, FormManager.IAppDialog{
private const string TipsLink = "https://github.com/chylex/TweetDuck/wiki";
private const string IssuesLink = "https://github.com/chylex/TweetDuck/issues";
diff --git a/Core/Other/FormGuide.cs b/Core/Other/FormGuide.cs
index 42ae7e84..0d11c656 100644
--- a/Core/Other/FormGuide.cs
+++ b/Core/Other/FormGuide.cs
@@ -12,7 +12,7 @@ using TweetDuck.Data;
using TweetDuck.Resources;
namespace TweetDuck.Core.Other{
- sealed partial class FormGuide : Form{
+ sealed partial class FormGuide : Form, FormManager.IAppDialog{
private const string GuideUrl = "https://tweetduck.chylex.com/guide/v2/";
private const string GuidePathRegex = @"^guide(?:/v\d+)?(?:/(#.*))?";
diff --git a/Core/Other/FormPlugins.cs b/Core/Other/FormPlugins.cs
index 7f5a9255..c3c99da6 100644
--- a/Core/Other/FormPlugins.cs
+++ b/Core/Other/FormPlugins.cs
@@ -7,7 +7,7 @@ using TweetDuck.Plugins;
using TweetDuck.Plugins.Controls;
namespace TweetDuck.Core.Other{
- sealed partial class FormPlugins : Form{
+ sealed partial class FormPlugins : Form, FormManager.IAppDialog{
private readonly PluginManager pluginManager;
public FormPlugins(){
diff --git a/Core/Other/FormSettings.cs b/Core/Other/FormSettings.cs
index 0cd5bbd1..beef313b 100644
--- a/Core/Other/FormSettings.cs
+++ b/Core/Other/FormSettings.cs
@@ -13,7 +13,7 @@ using TweetDuck.Plugins;
using TweetDuck.Updates;
namespace TweetDuck.Core.Other{
- sealed partial class FormSettings : Form{
+ sealed partial class FormSettings : Form, FormManager.IAppDialog{
private readonly FormBrowser browser;
private readonly PluginManager plugins;