diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2018-07-15 01:04:34 +0300 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2018-07-15 01:04:34 +0300 |
| commit | cc425e019d3a7d3494ac15ffe213b6b47b1c64ed (patch) | |
| tree | 6db5ec969f92f91c2d05af55216bc4a267cc2370 /Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation | |
| parent | 64bcf92608faae31b7cd31ac3da5c7d1d7ebcd0b (diff) | |
| download | Tango-cc425e019d3a7d3494ac15ffe213b6b47b1c64ed.tar.gz Tango-cc425e019d3a7d3494ac15ffe213b6b47b1c64ed.zip | |
Working on PPC.
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation')
| -rw-r--r-- | Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs | 72 |
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 |
