aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioViewModel.cs
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-08-23 09:45:01 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-08-23 09:45:01 +0300
commit2c8da378c82e5181f0566a564de529ab7ef96f4f (patch)
treed450472402b15fc30d8bd482da348826caf487c5 /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioViewModel.cs
parent774da535e732ecd5a3737550ef1d35819a1e7fc6 (diff)
downloadTango-2c8da378c82e5181f0566a564de529ab7ef96f4f.tar.gz
Tango-2c8da378c82e5181f0566a564de529ab7ef96f4f.zip
Improvements to machine studio view models and navigation system.
Improvements to tech board selection and edit modes handling.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioViewModel.cs')
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioViewModel.cs180
1 files changed, 27 insertions, 153 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioViewModel.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioViewModel.cs
index 08ddbc073..63ff2119a 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioViewModel.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioViewModel.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using Tango.Core.DI;
using Tango.SharedUI;
namespace Tango.MachineStudio.Common
@@ -10,128 +11,42 @@ namespace Tango.MachineStudio.Common
/// <summary>
/// Represents a Machine Studio view model
/// </summary>
- /// <typeparam name="Module">The type of the module.</typeparam>
/// <seealso cref="Tango.SharedUI.ViewModel" />
/// <seealso cref="Tango.MachineStudio.Common.IStudioViewModel" />
- public abstract class StudioViewModelInternal : ViewModel, IStudioViewModel
+ public abstract class StudioViewModel : ViewModel, IStudioViewModel
{
- public bool IsVisible { get; private set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether this view model studio module is currently loaded.
- /// </summary>
- public bool IsModuleLoaded { get; private set; }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="StudioViewModel{Module}"/> class.
- /// </summary>
- public StudioViewModelInternal() : base()
- {
-
- }
-
- /// <summary>
- /// Called when another module has wants to navigate to this module with some arguments.
- /// </summary>
- /// <param name="args">The arguments.</param>
- public virtual void OnModuleRequest(params object[] args)
- {
-
- }
-
+ private bool _isVisible;
/// <summary>
- /// Called when the user has navigated out of the module.
+ /// Gets or sets a value indicating whether this view model view's is visible.
/// </summary>
- public virtual void OnNavigatedFrom()
+ public bool IsVisible
{
- IsVisible = false;
- IsModuleLoaded = false;
+ get { return _isVisible; }
+ set { _isVisible = value; RaisePropertyChangedAuto(); }
}
/// <summary>
- /// Called when the user has navigated in to the module.
- /// </summary>
- public virtual void OnNavigatedTo()
- {
- IsVisible = true;
- IsModuleLoaded = true;
- }
-
- /// <summary>
- /// Called before the application is shutting down.
- /// Return false to cancel the shutdown in case an important process is in progress.
- /// </summary>
- /// <returns></returns>
- public virtual Task<bool> OnShutdownRequest()
- {
- return Task.FromResult(true);
- }
-
- /// <summary>
- /// Called when application is shutting down.
- /// </summary>
- public virtual void OnShuttingDown()
- {
-
- }
-
- /// <summary>
- /// Called when the application has been started
- /// </summary>
- public virtual void OnApplicationStarted()
- {
-
- }
-
- /// <summary>
- /// Called when the application is ready and all modules are loaded.
- /// </summary>
- public virtual void OnApplicationReady()
- {
-
- }
- }
-
- /// <summary>
- /// Represents a Machine Studio view model
- /// </summary>
- /// <typeparam name="Module">The type of the module.</typeparam>
- /// <seealso cref="Tango.SharedUI.ViewModel" />
- /// <seealso cref="Tango.MachineStudio.Common.IStudioViewModel" />
- public abstract class StudioViewModel<Module> : ViewModel, IStudioViewModel where Module : IStudioModule
- {
- public bool IsVisible { get; private set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether this view model studio module is currently loaded.
- /// </summary>
- public bool IsModuleLoaded { get; private set; }
-
- /// <summary>
- /// Called when another module has wants to navigate to this module with some arguments.
+ /// Initializes a new instance of the <see cref="StudioViewModel{Module}"/> class.
/// </summary>
- /// <param name="args">The arguments.</param>
- public virtual void OnModuleRequest(params object[] args)
+ public StudioViewModel() : base()
{
}
/// <summary>
- /// Called when the user has navigated out of the module.
+ /// Called when the user has navigated out of this view model.
/// </summary>
public virtual void OnNavigatedFrom()
{
IsVisible = false;
- IsModuleLoaded = false;
}
/// <summary>
- /// Called when the user has navigated in to the module.
+ /// Called when the user has navigated in to this view model.
/// </summary>
public virtual void OnNavigatedTo()
{
IsVisible = true;
- IsModuleLoaded = true;
}
/// <summary>
@@ -163,79 +78,38 @@ namespace Tango.MachineStudio.Common
/// <summary>
/// Called when the application is ready and all modules are loaded.
/// </summary>
- public virtual void OnApplicationReady()
- {
-
- }
+ public abstract void OnApplicationReady();
}
/// <summary>
- /// Represents a Machine Studio view model.
+ /// Represents a Machine Studio view model with a support for a view contract.
/// </summary>
- /// <typeparam name="Module">The type of the module.</typeparam>
- /// <typeparam name="T"></typeparam>
+ /// <typeparam name="TView"></typeparam>
/// <seealso cref="Tango.SharedUI.ViewModel" />
- /// <seealso cref="Tango.MachineStudio.Common.IStudioViewModel" />
- public abstract class StudioViewModel<Module, T> : ViewModel<T>, IStudioViewModel where Module : IStudioModule where T : IView
+ public abstract class StudioViewModel<TView> : StudioViewModel where TView : IView
{
/// <summary>
- /// Called when the application has been started
- /// </summary>
- public virtual void OnApplicationStarted()
- {
-
- }
-
- /// <summary>
- /// Called when the application is ready and all modules are loaded.
- /// </summary>
- public virtual void OnApplicationReady()
- {
-
- }
-
- /// <summary>
- /// Called when another module has wants to navigate to this module with some arguments.
+ /// Gets the view model's view.
/// </summary>
- /// <param name="args">The arguments.</param>
- public virtual void OnModuleRequest(params object[] args)
- {
-
- }
+ public TView View { get; private set; }
/// <summary>
- /// Called when the user has navigated out of the module.
+ /// Initializes a new instance of the <see cref="StudioViewModel{TView}"/> class.
/// </summary>
- public virtual void OnNavigatedFrom()
+ public StudioViewModel() : base()
{
-
+ TangoIOC.Default.GetInstanceWhenAvailable<TView>((view) =>
+ {
+ View = view;
+ OnViewAttached(view);
+ });
}
/// <summary>
- /// Called when the user has navigated in to the module.
+ /// Called when the view has been attached
/// </summary>
- public virtual void OnNavigatedTo()
- {
-
- }
-
- /// <summary>
- /// Called before the application is shutting down.
- /// Return false to cancel the shutdown in case an important process is in progress.
- /// </summary>
- /// <returns></returns>
- public virtual Task<bool> OnShutdownRequest()
- {
- return Task.FromResult(true);
- }
-
- /// <summary>
- /// Called when application is shutting down.
- /// </summary>
- public virtual void OnShuttingDown()
- {
-
- }
+ /// <param name="view">The view.</param>
+ protected abstract void OnViewAttached(TView view);
}
}