aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs72
1 files changed, 59 insertions, 13 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs
index 0ede1306f..47450a68e 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs
@@ -11,6 +11,7 @@ using Tango.Core.Commands;
using Tango.PPC.Common;
using Tango.PPC.Common.Modules;
using Tango.PPC.Common.Navigation;
+using Tango.PPC.Common.Threading;
using Tango.PPC.UI.Views;
using Tango.SharedUI.Controls;
@@ -24,6 +25,7 @@ namespace Tango.PPC.UI.Navigation
{
private event Action<Object, Object> NavigationCycleCompleted;
+ private IDispatcherProvider _dispatcherProvider;
private IPPCModuleLoader _moduleLoader;
private Object _currentVM;
private String _lastFullPath;
@@ -56,13 +58,15 @@ namespace Tango.PPC.UI.Navigation
/// Initializes a new instance of the <see cref="DefaultNavigationManager"/> class.
/// </summary>
/// <param name="moduleLoader">The module loader.</param>
- public DefaultNavigationManager(IPPCModuleLoader moduleLoader)
+ public DefaultNavigationManager(IPPCModuleLoader moduleLoader, IDispatcherProvider dispatcherProvider)
{
_navigationHistory = new Stack<String>();
_moduleLoader = moduleLoader;
NavigateToCommand = new RelayCommand<string>(async (x) => await NavigateTo(x));
NavigateBackCommand = new RelayCommand(async () => await NavigateBack());
+
+ _dispatcherProvider = dispatcherProvider;
}
/// <summary>
@@ -204,18 +208,16 @@ namespace Tango.PPC.UI.Navigation
return true;
}
- private Task<bool> NavigateTo(Type moduleType, bool pushToHistory = true, params String[] viewPath)
- {
- if (viewPath != null && viewPath.Length > 0)
- {
- return NavigateTo(moduleType.Name + "." + String.Join(".", viewPath), pushToHistory);
- }
- else
- {
- return NavigateTo(moduleType.Name, pushToHistory);
- }
- }
-
+ /// <summary>
+ /// Navigates for result.
+ /// </summary>
+ /// <typeparam name="TModule">The type of the module.</typeparam>
+ /// <typeparam name="TView">The type of the view.</typeparam>
+ /// <typeparam name="TResult">The type of the result.</typeparam>
+ /// <typeparam name="TObject">The type of the object.</typeparam>
+ /// <param name="obj">The object.</param>
+ /// <param name="pushToHistory">if set to <c>true</c> [push to history].</param>
+ /// <returns></returns>
public Task<TResult> NavigateForResult<TModule, TView, TResult, TObject>(TObject obj, bool pushToHistory = true)
where TModule : IPPCModule
{
@@ -259,6 +261,50 @@ namespace Tango.PPC.UI.Navigation
}
/// <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>
+ public Task<bool> NavigateWithObject<TModule, TView, TPass>(TPass obj, bool pushToHistory = true) where TModule : IPPCModule
+ {
+ TaskCompletionSource<bool> source = new TaskCompletionSource<bool>();
+
+ Action<Object, Object> handler = null;
+
+ handler = (from, to) =>
+ {
+ if (to is INavigationObjectReceiver<TPass>)
+ {
+ (to as INavigationObjectReceiver<TPass>).OnNavigatedToWithObject(obj);
+ }
+
+ NavigationCycleCompleted -= handler;
+ };
+
+ NavigationCycleCompleted += handler;
+
+ NavigateTo<TModule>(typeof(TView).Name, pushToHistory);
+
+ return source.Task;
+ }
+
+ private Task<bool> NavigateTo(Type moduleType, bool pushToHistory = true, params String[] viewPath)
+ {
+ if (viewPath != null && viewPath.Length > 0)
+ {
+ return NavigateTo(moduleType.Name + "." + String.Join(".", viewPath), pushToHistory);
+ }
+ else
+ {
+ return NavigateTo(moduleType.Name, pushToHistory);
+ }
+ }
+
+ /// <summary>
/// Gets a value indicating whether the navigation system is able to navigate to the previous view.
/// </summary>
public bool CanNavigateBack