From db89412e079e151a3217ed2a108820ebe6ba2f30 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Tue, 20 Feb 2018 15:53:44 +0200 Subject: Improved module popout.. --- .../DefaultStudioApplicationManager.cs | 44 ++++++++++++++++------ 1 file changed, 32 insertions(+), 12 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication') 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 _openedWindows; /// /// Initializes a new instance of the class. @@ -38,6 +40,7 @@ namespace Tango.MachineStudio.UI.StudioApplication { _moduleLoader = moduleLoader; _navigationManager = navigationManager; + _openedWindows = new List(); } /// @@ -137,35 +140,45 @@ namespace Tango.MachineStudio.UI.StudioApplication } } + foreach (var vm in ServiceLocator.Current.GetAllInstancesByBase()) + { + 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()) + _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); }; + } } } -- cgit v1.3.1