From 2c8da378c82e5181f0566a564de529ab7ef96f4f Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Thu, 23 Aug 2018 09:45:01 +0300 Subject: Improvements to machine studio view models and navigation system. Improvements to tech board selection and edit modes handling. --- .../Navigation/INavigationBlocker.cs | 28 +++++++ .../Navigation/INavigationManager.cs | 98 +++++++++++++++++++++- .../Navigation/INavigationObjectReceiver.cs | 21 +++++ .../Navigation/INavigationResultProvider.cs | 28 +++++++ 4 files changed, 173 insertions(+), 2 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation/INavigationBlocker.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation/INavigationObjectReceiver.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation/INavigationResultProvider.cs (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation') diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation/INavigationBlocker.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation/INavigationBlocker.cs new file mode 100644 index 000000000..abd6db172 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation/INavigationBlocker.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.MachineStudio.Common.Navigation +{ + /// + /// Represents an object which can abort the navigation from it. + /// + public interface INavigationBlocker + { + /// + /// Called before the navigation system navigates from this object. + /// Return false to abort the navigation. + /// + /// + Task OnNavigateOutRequest(); + + /// + /// Called before the navigation system navigates back from this object. + /// Return false to abort the navigation. + /// + /// + Task OnNavigateBackRequest(); + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation/INavigationManager.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation/INavigationManager.cs index 4d1cbea8c..e20940c8d 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation/INavigationManager.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation/INavigationManager.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.Core.Commands; namespace Tango.MachineStudio.Common.Navigation { @@ -12,9 +13,102 @@ namespace Tango.MachineStudio.Common.Navigation public interface INavigationManager { /// - /// Navigates to the specified view. + /// Gets the current module. + /// + IStudioModule CurrentModule { get; } + + /// + /// Gets the current view model. + /// + StudioViewModel CurrentVM { get; } + + /// + /// Gets a value indicating whether the navigation system is able to navigate to the previous view. + /// + bool CanNavigateBack { get; } + + /// + /// Navigates to the previous view if is true. + /// + Task NavigateBack(); + + /// + /// Navigates to the previous view.. + /// + RelayCommand NavigateBackCommand { get; } + + /// + /// Navigates to the specified full path in command parameter. + /// + RelayCommand NavigateToCommand { get; } + + /// + /// Navigates to the specified PPC view. /// /// The view. - void NavigateTo(NavigationView view); + Task NavigateTo(NavigationView view, bool pushToHistory = true); + + /// + /// Navigates to the specified PPC view with the specified receive object. + /// + /// The view. + Task NavigateWithObject(NavigationView view, TPass obj, bool pushToHistory = true); + + /// + /// Navigates to the specified module. + /// + /// + Task NavigateTo(bool pushToHistory = true) where T : IStudioModule; + + /// + /// Navigates to the specified module using the view path (e.g MainView.JobsView). + /// + /// + /// The view path. + Task NavigateTo(String viewPath, bool pushToHistory = true) where T : IStudioModule; + + /// + /// Navigates to the specified module using the view path (e.g MainView,JobsView). + /// This method makes it easy to do stuff like NavigateTo(nameof(MainView),nameof(JobsView)); + /// + /// + /// The view path. + Task NavigateTo(bool pushToHistory = true, params String[] viewPath) where T : IStudioModule; + + /// + /// Navigates to the specified module and view by full path (e.g Jobs.JobsView). + /// + /// The full path. + Task NavigateTo(String fullPath, bool pushToHistory = true); + + /// + /// Navigates to the specified module and view with the specified object and expecting a return parameter. + /// The view must be of type INavigationResultProvider. + /// + /// The full path. + Task NavigateForResult(TPass obj, bool pushToHistory = true) + where TModule : IStudioModule; + + /// + /// Navigates to the specified module and view with the specified object. + /// + /// The type of the module. + /// The type of the view. + /// The type of the pass. + /// The object. + /// if set to true [push to history]. + /// + Task NavigateWithObject(TPass obj, bool pushToHistory = true) + where TModule : IStudioModule; + + /// + /// Clears the navigation back history. + /// + void ClearHistory(); + + /// + /// Clears the navigation back history except the specified view type. + /// + void ClearHistoryExcept(); } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation/INavigationObjectReceiver.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation/INavigationObjectReceiver.cs new file mode 100644 index 000000000..5072881d2 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation/INavigationObjectReceiver.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.MachineStudio.Common.Navigation +{ + /// + /// Represents an object which supports receiving an object as part of the navigation to it. + /// + /// + public interface INavigationObjectReceiver + { + /// + /// Called when navigation system is going to navigate to this instance with the specified object. + /// + /// The object. + void OnNavigatedToWithObject(T obj); + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation/INavigationResultProvider.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation/INavigationResultProvider.cs new file mode 100644 index 000000000..dee037432 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation/INavigationResultProvider.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.MachineStudio.Common.Navigation +{ + /// + /// Represents a object which provides a result the navigation system navigates away from it. + /// + /// The type of the result. + /// The type of the pass. + public interface INavigationResultProvider + { + /// + /// Called when the navigation system requests a result when it is navigating away from this instance. + /// + /// + TResult GetNavigationResult(); + + /// + /// Called when navigation system is going to navigate to this instance with the specified object. + /// + /// The object. + void OnNavigationObjectReceived(TPass obj); + } +} -- cgit v1.3.1