aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs')
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs44
1 files changed, 32 insertions, 12 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs
index 886985c92..ee1724435 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs
@@ -17,6 +17,7 @@ using Tango.Logging;
using Tango.MachineStudio.Common.Modules;
using Tango.MachineStudio.Common;
using Tango.Settings;
+using System.Windows;
namespace Tango.MachineStudio.UI.StudioApplication
{
@@ -29,6 +30,7 @@ namespace Tango.MachineStudio.UI.StudioApplication
{
private INavigationManager _navigationManager;
private IStudioModuleLoader _moduleLoader;
+ private List<Window> _openedWindows;
/// <summary>
/// Initializes a new instance of the <see cref="DefaultStudioApplicationManager" /> class.
@@ -38,6 +40,7 @@ namespace Tango.MachineStudio.UI.StudioApplication
{
_moduleLoader = moduleLoader;
_navigationManager = navigationManager;
+ _openedWindows = new List<Window>();
}
/// <summary>
@@ -137,35 +140,45 @@ namespace Tango.MachineStudio.UI.StudioApplication
}
}
+ foreach (var vm in ServiceLocator.Current.GetAllInstancesByBase<IShutdownListener>())
+ {
+ vm.OnShuttingDown();
+ }
+
try
{
- if (ConnectedMachine != null)
- {
- ConnectedMachine.Disconnect().Wait();
- }
+ SettingsManager.SaveDefaultSettings();
}
catch (Exception ex)
{
- LogManager.Log(ex, "Error disconnecting from machine.");
+ LogManager.Log(ex, "Error saving settings.");
}
- foreach (var vm in ServiceLocator.Current.GetAllInstancesByBase<IShutdownListener>())
+ _navigationManager.NavigateTo(NavigationView.ShutdownView);
+
+ Thread.Sleep(1500);
+
+ foreach (var window in _openedWindows)
{
- vm.OnShuttingDown();
+ ThreadsHelper.InvokeUI(() =>
+ {
+ window.Close();
+ });
}
try
{
- SettingsManager.SaveDefaultSettings();
+ if (ConnectedMachine != null)
+ {
+ ConnectedMachine.Disconnect().Wait();
+ }
}
catch (Exception ex)
{
- LogManager.Log(ex, "Error saving settings.");
+ LogManager.Log(ex, "Error disconnecting from machine.");
}
- _navigationManager.NavigateTo(NavigationView.ShutdownView);
-
- Thread.Sleep(3000);
+ Thread.Sleep(1500);
Environment.Exit(0);
@@ -196,5 +209,12 @@ namespace Tango.MachineStudio.UI.StudioApplication
throw new InvalidOperationException("The module was not found or you do not have sufficient privileges.");
}
}
+
+ public void RegisterOpenedWindow(Window window)
+ {
+ _openedWindows.Add(window);
+
+ window.Closed += (x, y) => { _openedWindows.Remove(window); };
+ }
}
}