From 28de564b35207886d181e4a3870f70c3bde04c3d Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Mon, 17 Sep 2018 16:06:27 +0300 Subject: Implemented keep modules windows states and bounds after restart. --- .../DefaultStudioApplicationManager.cs | 33 ++++++++++++++++++---- 1 file changed, 28 insertions(+), 5 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 29bb459ee..8eff9ea4e 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs @@ -21,6 +21,7 @@ using Tango.BL.Enumerations; using Tango.Core.DI; using Tango.BL.Entities; using Tango.BL; +using Tango.MachineStudio.UI.ViewModels; namespace Tango.MachineStudio.UI.StudioApplication { @@ -45,7 +46,7 @@ namespace Tango.MachineStudio.UI.StudioApplication _navigationManager = navigationManager; _openedWindows = new List(); - Application.Current.MainWindow.ContentRendered += (_, __) => + Application.Current.MainWindow.ContentRendered += (_, __) => { TangoIOC.Default.GetAllInstancesByBase().ToList().ForEach(x => x.OnApplicationStarted()); }; @@ -150,8 +151,8 @@ namespace Tango.MachineStudio.UI.StudioApplication await Task.Factory.StartNew(async () => { - //Do Shutdown Procedures... - foreach (var vm in TangoIOC.Default.GetAllInstancesByBase()) + //Do Shutdown Procedures... + foreach (var vm in TangoIOC.Default.GetAllInstancesByBase()) { try { @@ -173,7 +174,29 @@ namespace Tango.MachineStudio.UI.StudioApplication vm.OnShuttingDown(); } - SettingsManager.Default.GetOrCreate().LastBounds = r; + + var settings = SettingsManager.Default.GetOrCreate(); + settings.LastBounds = r; + settings.StudioModulesBounds.Clear(); + + + foreach (var window in _openedWindows.OfType()) + { + window.Invoke(() => + { + var context = window.ModuleContext; + + if (context != null) + { + settings.StudioModulesBounds.Add(new MachineStudioSettings.StudioModuleBounds() + { + Bounds = window.RestoreBounds, + State = window.WindowState, + Name = context.Module.Name, + }); + } + }); + } try { @@ -224,7 +247,7 @@ namespace Tango.MachineStudio.UI.StudioApplication catch (Exception ex) { IsShuttingDown = false; - LogManager.Log(ex,"An error occurred while shutting down machine studio."); + LogManager.Log(ex, "An error occurred while shutting down machine studio."); } } -- cgit v1.3.1