From de099bd3b50b8ea52b212b8d322626582c2648be Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Sun, 22 Apr 2018 13:35:22 +0300 Subject: Implemented new TangoIOC container & TangoMessenger. Got rid of MVVMLite libs ! Got rid of IShutdownRequestBlocker, IShutdownListener, IModuleRequestListener. Implemented IStudioViewModel & StudioViewModel. --- .../Tango.MachineStudio.Common/StudioViewModel.cs | 117 ++++++++++++++++++++- 1 file changed, 112 insertions(+), 5 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioViewModel.cs') diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioViewModel.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioViewModel.cs index 6b7984faf..30e96bd0a 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioViewModel.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioViewModel.cs @@ -7,19 +7,126 @@ using Tango.SharedUI; namespace Tango.MachineStudio.Common { - public abstract class StudioViewModel : ViewModel + /// + /// Represents a Machine Studio view model + /// + /// The type of the module. + /// + /// + public abstract class StudioViewModel : ViewModel, IStudioViewModel where Module : IStudioModule { - public abstract Task RequestShutdown(); + /// + /// Initializes a new instance of the class. + /// + public StudioViewModel() : base() + { + + } + + /// + /// Called when another module has wants to navigate to this module with some arguments. + /// + /// The arguments. + public virtual void OnModuleRequest(params object[] args) + { + + } + + /// + /// Called when the user has navigated out of the module. + /// + public virtual void OnNavigatedFrom() + { + + } + + /// + /// Called when the user has navigated in to the module. + /// + public virtual void OnNavigatedTo() + { + + } + + /// + /// Called before the application is shutting down. + /// Return false to cancel the shutdown in case an important process is in progress. + /// + /// + public virtual Task OnShutdownRequest() + { + return Task.FromResult(true); + } + + /// + /// Called when application is shutting down. + /// + public virtual void OnShuttingDown() + { + + } } - public abstract class StudioViewModel : ViewModel where T : IView + /// + /// Represents a Machine Studio view model. + /// + /// The type of the module. + /// + /// + /// + public abstract class StudioViewModel : ViewModel, IStudioViewModel where Module : IStudioModule where T : IView { - public abstract Task OnShutdownRequest(); - + /// + /// Initializes a new instance of the class. + /// + /// The view. public StudioViewModel(T view) : base(view) { } + + /// + /// Called when another module has wants to navigate to this module with some arguments. + /// + /// The arguments. + public virtual void OnModuleRequest(params object[] args) + { + + } + + /// + /// Called when the user has navigated out of the module. + /// + public virtual void OnNavigatedFrom() + { + + } + + /// + /// Called when the user has navigated in to the module. + /// + public virtual void OnNavigatedTo() + { + + } + + /// + /// Called before the application is shutting down. + /// Return false to cancel the shutdown in case an important process is in progress. + /// + /// + public virtual Task OnShutdownRequest() + { + return Task.FromResult(true); + } + + /// + /// Called when application is shutting down. + /// + public virtual void OnShuttingDown() + { + + } } } -- cgit v1.3.1 From 829a1f93613c09782c4411431de5fb2b79b364d6 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Sun, 22 Apr 2018 16:10:48 +0300 Subject: Implemented graphs rendering control (NavigatedTo/From) on technician module. --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 1572864 -> 1572864 bytes .../ViewModels/MachineTechViewVM.cs | 16 +++++++++++++++- .../Tango.MachineStudio.Common/StudioViewModel.cs | 9 +++++++-- 4 files changed, 22 insertions(+), 3 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioViewModel.cs') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 3cacb7854..d5e200a02 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index b324efdb7..9ece537f2 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs index c1dfe5f8c..91c80a41a 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs @@ -49,6 +49,7 @@ namespace Tango.MachineStudio.Technician.ViewModels private IEventLogger _eventLogger; private DateTime _lastDiagnosticsResponseUpdate; private const int MIN_DIAGNOSTICS_UPDATE_MILI = 500; + private bool _isViewLoaded; #region Properties @@ -243,6 +244,7 @@ namespace Tango.MachineStudio.Technician.ViewModels CurrentDiagnosticsResponseSize = data.CalculateSize(); } + lock (_elementsLock) { var elements = Elements.ToList(); @@ -769,7 +771,7 @@ namespace Tango.MachineStudio.Technician.ViewModels } catch (Exception ex) { - LogManager.Log(ex, String.Format("Error executing technician command '{0}' on item '{1}'.", action,item.TechName)); + LogManager.Log(ex, String.Format("Error executing technician command '{0}' on item '{1}'.", action, item.TechName)); _eventLogger.Log(ex, String.Format("Error executing technician command '{0}' on item '{1}'.", action, item.TechName)); } }; @@ -1207,6 +1209,18 @@ namespace Tango.MachineStudio.Technician.ViewModels #region IStudioModuleVM + public override void OnNavigatedTo() + { + base.OnNavigatedTo(); + _singleControllers.ToList().ForEach(x => x.Value.ChangeRenderMode(true)); + } + + public override void OnNavigatedFrom() + { + base.OnNavigatedFrom(); + _singleControllers.ToList().ForEach(x => x.Value.ChangeRenderMode(false)); + } + public override void OnShuttingDown() { InvokeUINow(() => diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioViewModel.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioViewModel.cs index 30e96bd0a..9c7e52d23 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioViewModel.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioViewModel.cs @@ -15,6 +15,11 @@ namespace Tango.MachineStudio.Common /// public abstract class StudioViewModel : ViewModel, IStudioViewModel where Module : IStudioModule { + /// + /// Gets or sets a value indicating whether this view model studio module is currently loaded. + /// + public bool IsModuleLoaded { get; private set; } + /// /// Initializes a new instance of the class. /// @@ -37,7 +42,7 @@ namespace Tango.MachineStudio.Common /// public virtual void OnNavigatedFrom() { - + IsModuleLoaded = false; } /// @@ -45,7 +50,7 @@ namespace Tango.MachineStudio.Common /// public virtual void OnNavigatedTo() { - + IsModuleLoaded = true; } /// -- cgit v1.3.1