aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2018-06-30 19:34:49 +0300
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2018-06-30 19:34:49 +0300
commit1303ac651e1990447612e139d02d5844c05fb31c (patch)
treedd29d160ef2e4f82f326fc468cde18dd186fe620 /Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation
parent010535f3064bbf69f063c5f329b7689c070a4ea8 (diff)
downloadTango-1303ac651e1990447612e139d02d5844c05fb31c.tar.gz
Tango-1303ac651e1990447612e139d02d5844c05fb31c.zip
Implemented INavigationResultProvider & GetNavigationResult.
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs45
1 files changed, 44 insertions, 1 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 9e51d7252..c56e0f000 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs
@@ -22,6 +22,8 @@ namespace Tango.PPC.UI.Navigation
/// <seealso cref="Tango.PPC.Common.Navigation.INavigationManager" />
public class DefaultNavigationManager : ExtendedObject, INavigationManager
{
+ private event Action<Object, Object> NavigationCycleCompleted;
+
private IPPCModuleLoader _moduleLoader;
private Object _currentVM;
@@ -130,6 +132,8 @@ namespace Tango.PPC.UI.Navigation
if (path.Length == 1 && path[0] == CurrentModule.Name) return true;
+ var fromVM = _currentVM;
+
if (_currentVM != null && _currentVM is INavigationBlocker)
{
if (!await (_currentVM as INavigationBlocker).OnNavigateOutRequest())
@@ -169,6 +173,8 @@ namespace Tango.PPC.UI.Navigation
moduleNavigation = v.FindChildOffline<NavigationControl>();
}
}
+
+ NavigationCycleCompleted?.Invoke(fromVM, _currentVM);
});
}
@@ -187,6 +193,44 @@ namespace Tango.PPC.UI.Navigation
}
}
+ public Task<TResult> NavigateForResult<TModule, TView, TResult>(bool pushToHistory = true)
+ where TModule : IPPCModule
+ {
+ TaskCompletionSource<TResult> source = new TaskCompletionSource<TResult>();
+
+ var fromVM = _currentVM;
+ Object toVM = null;
+
+
+ Action<Object, Object> handler = null;
+
+ handler = (from, to) =>
+ {
+ if (toVM == null)
+ {
+ toVM = to;
+ }
+ else
+ {
+ if (to == fromVM && from == toVM)
+ {
+ if (from is INavigationResultProvider<TResult>)
+ {
+ source.SetResult((from as INavigationResultProvider<TResult>).GetNavigationResult());
+ }
+ }
+
+ NavigationCycleCompleted -= handler;
+ }
+ };
+
+ NavigationCycleCompleted += handler;
+
+ NavigateTo<TModule>(typeof(TView).Name, pushToHistory);
+
+ return source.Task;
+ }
+
/// <summary>
/// Gets a value indicating whether the navigation system is able to navigate to the previous view.
/// </summary>
@@ -198,7 +242,6 @@ namespace Tango.PPC.UI.Navigation
/// <summary>
/// Navigates to the previous view if <see cref="P:Tango.PPC.Common.Navigation.INavigationManager.CanNavigateBack" /> is true.
/// </summary>
- /// <exception cref="NotImplementedException"></exception>
public async Task<bool> NavigateBack()
{
String first = _navigationHistory.Pop();