From 998cc8d4d91a7f85389cd0918f127257576c2c13 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Mon, 13 Aug 2018 16:12:45 +0300 Subject: Logs and comments for PPC.UI ! --- .../Navigation/DefaultNavigationManager.cs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation') 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 a05d5fc5c..eee37b2e0 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; +using System.Runtime.CompilerServices; using System.Text; using System.Threading.Tasks; using System.Windows; @@ -102,6 +103,8 @@ namespace Tango.PPC.UI.Navigation } else { + + LogManager.Log($"Navigating to: {view.ToString()}..."); MainView.Instance.NavigationControl.NavigateTo(view.ToString()); return Task.FromResult(true); } @@ -116,8 +119,9 @@ namespace Tango.PPC.UI.Navigation /// public Task NavigateWithObject(NavigationView view, TPass obj, bool pushToHistory = true) { + LogManager.Log($"Navigating to: {view.ToString()}, with object {typeof(TPass).Name}..."); MainView.Instance.NavigationControl.NavigateTo(view.ToString()); - INavigationObjectReceiver receiver = MainView.Instance.NavigationControl.Elements.FirstOrDefault(x => (x.GetType().Name == view.ToString() || NavigationControl.GetNavigationName(x) == view.ToString()) && x.DataContext is INavigationObjectReceiver).DataContext as INavigationObjectReceiver; + INavigationObjectReceiver receiver = MainView.Instance.NavigationControl.Elements.FirstOrDefault(x => (x.GetType().Name == view.ToString() || NavigationControl.GetNavigationName(x) == view.ToString()) && x.DataContext is INavigationObjectReceiver).DataContext as INavigationObjectReceiver; if (receiver != null) { @@ -168,6 +172,8 @@ namespace Tango.PPC.UI.Navigation if (path.Length == 1 && path[0] == CurrentModule.Name) return true; + LogManager.Log($"Navigating to: {fullPath}..."); + var fromVM = _currentVM; if (_currentVM != null && _currentVM is INavigationBlocker) @@ -225,7 +231,7 @@ namespace Tango.PPC.UI.Navigation } else { - throw new ArgumentNullException("Could not navigate to " + fullPath); + throw LogManager.Log(new ArgumentNullException("Could not navigate to " + fullPath)); } } @@ -345,6 +351,8 @@ namespace Tango.PPC.UI.Navigation /// public async Task NavigateBack() { + LogManager.Log("Navigating back..."); + _navigating_back = true; String first = _navigationHistory.Pop(); @@ -373,12 +381,19 @@ namespace Tango.PPC.UI.Navigation /// public void ClearHistory() { + LogManager.Log("Navigation history cleared."); _navigationHistory.Clear(); RaisePropertyChanged(nameof(CanNavigateBack)); } + /// + /// Clears the navigation back history except the specified view type. + /// + /// public void ClearHistoryExcept() { + LogManager.Log($"Navigation history cleared except for {typeof(T).Name}."); + var history_list = _navigationHistory.ToList(); history_list = history_list.Where(x => x.Contains(typeof(T).Name)).Distinct().ToList(); _navigationHistory.Clear(); -- cgit v1.3.1