diff --git a/CSharp/Environments/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/WindowsFormsEngine.cs b/CSharp/Environments/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/WindowsFormsEngine.cs
index bdd8402a..ba42a502 100644
--- a/CSharp/Environments/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/WindowsFormsEngine.cs
+++ b/CSharp/Environments/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/WindowsFormsEngine.cs
@@ -378,7 +378,7 @@ namespace UniversalEditor.UserInterface.WindowsForms
}
}
- public override void OpenWindow(params string[] FileNames)
+ protected override IHostApplicationWindow OpenWindowInternal(params string[] FileNames)
{
MainWindow mw = new MainWindow();
@@ -387,8 +387,7 @@ namespace UniversalEditor.UserInterface.WindowsForms
mw.OpenFile(FileNames);
}
mw.Show();
-
- Windows.Add(mw);
+ return mw;
}
public override void ExitApplication()
diff --git a/CSharp/Libraries/UniversalEditor.UserInterface/Engine.cs b/CSharp/Libraries/UniversalEditor.UserInterface/Engine.cs
index 937d3387..a84bd1ea 100644
--- a/CSharp/Libraries/UniversalEditor.UserInterface/Engine.cs
+++ b/CSharp/Libraries/UniversalEditor.UserInterface/Engine.cs
@@ -259,15 +259,33 @@ namespace UniversalEditor.UserInterface
public void OpenFile(params string[] FileNames)
{
+ if (LastWindow == null)
+ {
+ OpenWindow(FileNames);
+ return;
+ }
LastWindow.OpenFile(FileNames);
}
+
///
/// Opens a new window, optionally loading the specified documents.
///
/// The file name(s) of the document(s) to load.
- public virtual void OpenWindow(params string[] FileNames)
- {
+ /// An representing the window that was created.
+ protected abstract IHostApplicationWindow OpenWindowInternal(params string[] FileNames);
+ ///
+ /// Opens a new window, optionally loading the specified documents.
+ ///
+ /// The file name(s) of the document(s) to load.
+ public void OpenWindow(params string[] FileNames)
+ {
+ IHostApplicationWindow window = OpenWindowInternal(FileNames);
+ window.WindowClosed += delegate(object sender, EventArgs e)
+ {
+ mvarWindows.Remove(window);
+ };
+ mvarWindows.Add(window);
}
// UniversalDataStorage.Editor.WindowsForms.Program