From 58762e977fe0fcd2340e36b36938cdaadf5302e9 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Thu, 18 Oct 2018 11:36:44 +0300 Subject: Implemented main window last module loading. --- .../ViewModels/MainViewVM.cs | 35 ++++++++++++++++++---- 1 file changed, 30 insertions(+), 5 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels') diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs index bbd621e65..49a8ca807 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs @@ -66,6 +66,13 @@ namespace Tango.MachineStudio.UI.ViewModels set { _currentModule = value; RaisePropertyChangedAuto(); } } + private bool _isApplicationReady; + public bool IsApplicationReady + { + get { return _isApplicationReady; } + set { _isApplicationReady = value; RaisePropertyChangedAuto(); } + } + private bool _isModuleLoaded; /// /// Gets or sets a value indicating whether any module is loaded at the moment. @@ -651,9 +658,10 @@ namespace Tango.MachineStudio.UI.ViewModels m.IsLoaded = false; } + CurrentModule = module; + if (module != null) { - CurrentModule = module; CurrentModule.IsLoaded = true; IsModuleLoaded = true; @@ -868,14 +876,31 @@ namespace Tango.MachineStudio.UI.ViewModels public override void OnApplicationReady() { - foreach (var item in SettingsManager.Default.GetOrCreate().StudioModulesBounds) + if (!IsApplicationReady) { - var module = StudioModuleLoader.AllModules.SingleOrDefault(x => x.Name == item.Name); + var settings = SettingsManager.Default.GetOrCreate(); + + foreach (var item in settings.StudioModulesBounds) + { + var module = StudioModuleLoader.AllModules.SingleOrDefault(x => x.Name == item.Name); + + if (module != null && !module.InNewWindow) + { + OpenModuleInWindow(module, item.Bounds, item.State); + } + } - if (module != null && !module.InNewWindow) + if (settings.LastMainModuleName != null) { - OpenModuleInWindow(module, item.Bounds, item.State); + var m = StudioModuleLoader.UserModules.SingleOrDefault(x => x.Name == settings.LastMainModuleName); + + if (m != null) + { + StartModule(m); + } } + + IsApplicationReady = true; } } } -- cgit v1.3.1