From d866652d38d2366c333a1ff5092aff1cc4b85dfa Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Mon, 2 Jul 2018 16:27:32 +0300 Subject: Implemented Twine's catalog control, Twine's catalog viewer, Twines catalog color correction view. Added INavigationResultProvider OnNavigationObjectReceived method.. Improved navigation system history. --- .../Navigation/DefaultNavigationManager.cs | 33 +++++++++++++++------- 1 file changed, 23 insertions(+), 10 deletions(-) (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs') 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..d26f4d396 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 _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(); @@ -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; @@ -193,7 +198,7 @@ namespace Tango.PPC.UI.Navigation } } - public Task NavigateForResult(bool pushToHistory = true) + public Task NavigateForResult(TObject obj, bool pushToHistory = true) where TModule : IPPCModule { TaskCompletionSource source = new TaskCompletionSource(); @@ -204,19 +209,23 @@ namespace Tango.PPC.UI.Navigation Action handler = null; - handler = (from, to) => + handler = (from, to) => { if (toVM == null) { toVM = to; + if (toVM is INavigationResultProvider) + { + (toVM as INavigationResultProvider).OnNavigationObjectReceived(obj); + } } else { if (to == fromVM && from == toVM) { - if (from is INavigationResultProvider) + if (from is INavigationResultProvider) { - source.SetResult((from as INavigationResultProvider).GetNavigationResult()); + source.SetResult((from as INavigationResultProvider).GetNavigationResult()); } } @@ -236,7 +245,7 @@ namespace Tango.PPC.UI.Navigation /// public bool CanNavigateBack { - get { return _navigationHistory.Count > 1; } + get { return _navigationHistory.Count > 0; } } /// @@ -245,16 +254,20 @@ namespace Tango.PPC.UI.Navigation public async Task 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; } } -- cgit v1.3.1