diff options
| author | Shlomo Hecht <shlomo@twine-s.com> | 2018-07-03 13:59:13 +0300 |
|---|---|---|
| committer | Shlomo Hecht <shlomo@twine-s.com> | 2018-07-03 13:59:13 +0300 |
| commit | c22c88086897438466c330d11dc41bfd744be91e (patch) | |
| tree | 15d9e3fe1e6b5da0f3aac97f9af5c9016a953433 /Software/Visual_Studio/PPC/Tango.PPC.UI | |
| parent | 89860193db29baaab6565059b6b90ca3b06ebd54 (diff) | |
| parent | 5ab2e8a2edf1ce487976da347a5e03d18ff307b1 (diff) | |
| download | Tango-c22c88086897438466c330d11dc41bfd744be91e.tar.gz Tango-c22c88086897438466c330d11dc41bfd744be91e.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI')
| -rw-r--r-- | Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs | 46 |
1 files changed, 33 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 c56e0f000..448fc0edc 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs @@ -26,6 +26,8 @@ namespace Tango.PPC.UI.Navigation private IPPCModuleLoader _moduleLoader; private Object _currentVM; + private String _lastFullPath; + private bool _preventHistory; private Stack<String> _navigationHistory; @@ -71,6 +73,7 @@ namespace Tango.PPC.UI.Navigation if (view == NavigationView.HomeModule) { _navigationHistory.Clear(); + _lastFullPath = null; var firstModule = _moduleLoader.UserModules.FirstOrDefault(); var moduleAtt = firstModule.GetType().GetCustomAttribute<PPCModuleAttribute>(); @@ -142,12 +145,14 @@ namespace Tango.PPC.UI.Navigation } } - if (pushToHistory) + if (pushToHistory && _lastFullPath != null && !_preventHistory) { - _navigationHistory.Push(fullPath); + _navigationHistory.Push(_lastFullPath); RaisePropertyChanged(nameof(CanNavigateBack)); } + _lastFullPath = fullPath; + MainView.Instance.NavigationControl.NavigateTo(NavigationView.LayoutView.ToString()); var navigationControl = LayoutView.Instance.NavigationControl; CurrentModule = module; @@ -166,11 +171,18 @@ namespace Tango.PPC.UI.Navigation await Task.Delay(100); var v = moduleNavigation.NavigateTo(view); - _currentVM = v.DataContext; + if (v != null) + { + _currentVM = v.DataContext; - if (view != path.Last()) + if (view != path.Last()) + { + moduleNavigation = v.FindChildOffline<NavigationControl>(); + } + } + else { - moduleNavigation = v.FindChildOffline<NavigationControl>(); + throw new ArgumentNullException("Could not navigate to " + fullPath); } } @@ -193,7 +205,7 @@ namespace Tango.PPC.UI.Navigation } } - public Task<TResult> NavigateForResult<TModule, TView, TResult>(bool pushToHistory = true) + public Task<TResult> NavigateForResult<TModule, TView, TResult, TObject>(TObject obj, bool pushToHistory = true) where TModule : IPPCModule { TaskCompletionSource<TResult> source = new TaskCompletionSource<TResult>(); @@ -204,19 +216,23 @@ namespace Tango.PPC.UI.Navigation Action<Object, Object> handler = null; - handler = (from, to) => + handler = (from, to) => { if (toVM == null) { toVM = to; + if (toVM is INavigationResultProvider<TResult, TObject>) + { + (toVM as INavigationResultProvider<TResult, TObject>).OnNavigationObjectReceived(obj); + } } else { if (to == fromVM && from == toVM) { - if (from is INavigationResultProvider<TResult>) + if (from is INavigationResultProvider<TResult, TObject>) { - source.SetResult((from as INavigationResultProvider<TResult>).GetNavigationResult()); + source.SetResult((from as INavigationResultProvider<TResult, TObject>).GetNavigationResult()); } } @@ -236,7 +252,7 @@ namespace Tango.PPC.UI.Navigation /// </summary> public bool CanNavigateBack { - get { return _navigationHistory.Count > 1; } + get { return _navigationHistory.Count > 0; } } /// <summary> @@ -245,16 +261,20 @@ namespace Tango.PPC.UI.Navigation public async Task<bool> NavigateBack() { String first = _navigationHistory.Pop(); - String second = _navigationHistory.Pop(); + _preventHistory = true; + - if (await NavigateTo(second)) + if (await NavigateTo(first)) { + RaisePropertyChanged(nameof(CanNavigateBack)); + _preventHistory = false; return true; } else { - _navigationHistory.Push(second); _navigationHistory.Push(first); + _preventHistory = false; + RaisePropertyChanged(nameof(CanNavigateBack)); return false; } } |
