aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation
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/Navigation
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/Navigation')
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation/INavigationBlocker.cs28
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation/INavigationManager.cs98
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation/INavigationObjectReceiver.cs21
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation/INavigationResultProvider.cs28
4 files changed, 173 insertions, 2 deletions
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
+{
+ /// <summary>
+ /// Represents an object which can abort the navigation from it.
+ /// </summary>
+ public interface INavigationBlocker
+ {
+ /// <summary>
+ /// Called before the navigation system navigates from this object.
+ /// Return false to abort the navigation.
+ /// </summary>
+ /// <returns></returns>
+ Task<bool> OnNavigateOutRequest();
+
+ /// <summary>
+ /// Called before the navigation system navigates back from this object.
+ /// Return false to abort the navigation.
+ /// </summary>
+ /// <returns></returns>
+ Task<bool> 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
{
/// <summary>
- /// Navigates to the specified view.
+ /// Gets the current module.
+ /// </summary>
+ IStudioModule CurrentModule { get; }
+
+ /// <summary>
+ /// Gets the current view model.
+ /// </summary>
+ StudioViewModel CurrentVM { get; }
+
+ /// <summary>
+ /// Gets a value indicating whether the navigation system is able to navigate to the previous view.
+ /// </summary>
+ bool CanNavigateBack { get; }
+
+ /// <summary>
+ /// Navigates to the previous view if <see cref="CanNavigateBack"/> is true.
+ /// </summary>
+ Task<bool> NavigateBack();
+
+ /// <summary>
+ /// Navigates to the previous view..
+ /// </summary>
+ RelayCommand NavigateBackCommand { get; }
+
+ /// <summary>
+ /// Navigates to the specified full path in command parameter.
+ /// </summary>
+ RelayCommand<String> NavigateToCommand { get; }
+
+ /// <summary>
+ /// Navigates to the specified PPC view.
/// </summary>
/// <param name="view">The view.</param>
- void NavigateTo(NavigationView view);
+ Task<bool> NavigateTo(NavigationView view, bool pushToHistory = true);
+
+ /// <summary>
+ /// Navigates to the specified PPC view with the specified receive object.
+ /// </summary>
+ /// <param name="view">The view.</param>
+ Task<bool> NavigateWithObject<TPass>(NavigationView view, TPass obj, bool pushToHistory = true);
+
+ /// <summary>
+ /// Navigates to the specified module.
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ Task<bool> NavigateTo<T>(bool pushToHistory = true) where T : IStudioModule;
+
+ /// <summary>
+ /// Navigates to the specified module using the view path (e.g MainView.JobsView).
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <param name="viewPath">The view path.</param>
+ Task<bool> NavigateTo<T>(String viewPath, bool pushToHistory = true) where T : IStudioModule;
+
+ /// <summary>
+ /// 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));
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <param name="viewPath">The view path.</param>
+ Task<bool> NavigateTo<T>(bool pushToHistory = true, params String[] viewPath) where T : IStudioModule;
+
+ /// <summary>
+ /// Navigates to the specified module and view by full path (e.g Jobs.JobsView).
+ /// </summary>
+ /// <param name="fullPath">The full path.</param>
+ Task<bool> NavigateTo(String fullPath, bool pushToHistory = true);
+
+ /// <summary>
+ /// Navigates to the specified module and view with the specified object and expecting a return parameter.
+ /// The view must be of type INavigationResultProvider<TResult>.
+ /// </summary>
+ /// <param name="fullPath">The full path.</param>
+ Task<TResult> NavigateForResult<TModule, TView, TResult, TPass>(TPass obj, bool pushToHistory = true)
+ where TModule : IStudioModule;
+
+ /// <summary>
+ /// Navigates to the specified module and view with the specified object.
+ /// </summary>
+ /// <typeparam name="TModule">The type of the module.</typeparam>
+ /// <typeparam name="TView">The type of the view.</typeparam>
+ /// <typeparam name="TPass">The type of the pass.</typeparam>
+ /// <param name="obj">The object.</param>
+ /// <param name="pushToHistory">if set to <c>true</c> [push to history].</param>
+ /// <returns></returns>
+ Task<bool> NavigateWithObject<TModule, TView, TPass>(TPass obj, bool pushToHistory = true)
+ where TModule : IStudioModule;
+
+ /// <summary>
+ /// Clears the navigation back history.
+ /// </summary>
+ void ClearHistory();
+
+ /// <summary>
+ /// Clears the navigation back history except the specified view type.
+ /// </summary>
+ void ClearHistoryExcept<T>();
}
}
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
+{
+ /// <summary>
+ /// Represents an object which supports receiving an object as part of the navigation to it.
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ public interface INavigationObjectReceiver<T>
+ {
+ /// <summary>
+ /// Called when navigation system is going to navigate to this instance with the specified object.
+ /// </summary>
+ /// <param name="obj">The object.</param>
+ 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
+{
+ /// <summary>
+ /// Represents a object which provides a result the navigation system navigates away from it.
+ /// </summary>
+ /// <typeparam name="TResult">The type of the result.</typeparam>
+ /// <typeparam name="TPass">The type of the pass.</typeparam>
+ public interface INavigationResultProvider<TResult, TPass>
+ {
+ /// <summary>
+ /// Called when the navigation system requests a result when it is navigating away from this instance.
+ /// </summary>
+ /// <returns></returns>
+ TResult GetNavigationResult();
+
+ /// <summary>
+ /// Called when navigation system is going to navigate to this instance with the specified object.
+ /// </summary>
+ /// <param name="obj">The object.</param>
+ void OnNavigationObjectReceived(TPass obj);
+ }
+}