aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-11-26 05:49:22 +0200
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-11-26 05:49:22 +0200
commita431b1dd895834a517bf65a9cddc88162d432fd2 (patch)
treee65faea4952137e50f3217ac6bebbf6540548abb /Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation
parent01fb003c742e7f7ac086e9340254e8d0bd606214 (diff)
downloadTango-a431b1dd895834a517bf65a9cddc88162d432fd2.tar.gz
Tango-a431b1dd895834a517bf65a9cddc88162d432fd2.zip
Moved job app bar item control to main view model by current navigation vm.
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs61
1 files changed, 39 insertions, 22 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 154ab68a1..d247ab23c 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs
@@ -39,19 +39,36 @@ namespace Tango.PPC.UI.Navigation
private IDispatcherProvider _dispatcherProvider;
private IPPCModuleLoader _moduleLoader;
private INotificationProvider _notificationProvider;
- private Object _currentVM;
private String _lastFullPath;
private bool _preventHistory;
private bool _navigating_back;
+ public event EventHandler<PPCViewModel> CurrentVMChanged;
+
private Stack<String> _navigationHistory;
+ private Object _currentVM;
/// <summary>
/// Gets the current view model.
/// </summary>
public PPCViewModel CurrentVM
{
- get { return _currentVM as PPCViewModel; }
+ set
+ {
+ var previous = _currentVM;
+ _currentVM = value;
+
+ var vm = _currentVM as PPCViewModel;
+
+ if (_currentVM != previous && vm != null)
+ {
+ CurrentVMChanged?.Invoke(this, vm);
+ }
+ }
+ get
+ {
+ return _currentVM as PPCViewModel;
+ }
}
private IPPCModule _currentModule;
@@ -131,12 +148,12 @@ namespace Tango.PPC.UI.Navigation
var fromView = MainView.Instance.NavigationControl.SelectedElement;
FrameworkElement toView = null;
- toView = MainView.Instance.NavigationControl.NavigateTo(view.ToString(), () =>
+ toView = MainView.Instance.NavigationControl.NavigateTo(view.ToString(), (Action)(() =>
{
- _currentVM = toView.DataContext;
+ CurrentVM = toView.DataContext as PPCViewModel;
NotifyOnNavigated(fromView.DataContext, toView.DataContext);
- });
+ }));
NotifyOnBeforeNavigated(fromView.DataContext, toView.DataContext);
@@ -223,13 +240,13 @@ namespace Tango.PPC.UI.Navigation
LogManager.Log($"Navigating to: {fullPath}...");
- var fromVM = _currentVM;
+ var fromVM = CurrentVM;
- if (_currentVM != null && _currentVM is INavigationBlocker)
+ if (CurrentVM != null && CurrentVM is INavigationBlocker)
{
if (_navigating_back)
{
- if (!await (_currentVM as INavigationBlocker).OnNavigateBackRequest())
+ if (!await (CurrentVM as INavigationBlocker).OnNavigateBackRequest())
{
IsNavigating = false;
return false;
@@ -237,7 +254,7 @@ namespace Tango.PPC.UI.Navigation
}
else
{
- if (!await (_currentVM as INavigationBlocker).OnNavigateOutRequest())
+ if (!await (CurrentVM as INavigationBlocker).OnNavigateOutRequest())
{
IsNavigating = false;
return false;
@@ -260,7 +277,7 @@ namespace Tango.PPC.UI.Navigation
CurrentModule = module;
var moduleView = navigationControl.NavigateTo(module.Name);
- _currentVM = moduleView.DataContext;
+ CurrentVM = moduleView.DataContext as PPCViewModel;
if (path.Length > 1)
{
@@ -297,7 +314,7 @@ namespace Tango.PPC.UI.Navigation
if (v != null)
{
- _currentVM = v.DataContext;
+ CurrentVM = v.DataContext as PPCViewModel;
if (view != path.Last())
{
@@ -313,30 +330,30 @@ namespace Tango.PPC.UI.Navigation
}
else
{
- onNavigating?.Invoke(fromVM as PPCViewModel, _currentVM as PPCViewModel);
+ onNavigating?.Invoke(fromVM as PPCViewModel, CurrentVM as PPCViewModel);
- NotifyOnBeforeNavigated(fromVM, _currentVM);
+ NotifyOnBeforeNavigated(fromVM, CurrentVM);
await Task.Delay(navigationControl.TransitionDuration.TimeSpan);
- NotifyOnNavigated(fromVM, _currentVM);
+ NotifyOnNavigated(fromVM, CurrentVM);
- onNavigated?.Invoke(fromVM as PPCViewModel, _currentVM as PPCViewModel);
- NotifyAwaitingVMResults(fromVM as PPCViewModel, _currentVM as PPCViewModel);
+ onNavigated?.Invoke(fromVM as PPCViewModel, CurrentVM as PPCViewModel);
+ NotifyAwaitingVMResults(fromVM as PPCViewModel, CurrentVM as PPCViewModel);
}
}
else
{
- NotifyOnBeforeNavigated(fromVM, _currentVM);
+ NotifyOnBeforeNavigated(fromVM, CurrentVM);
- onNavigating?.Invoke(fromVM as PPCViewModel, _currentVM as PPCViewModel);
+ onNavigating?.Invoke(fromVM as PPCViewModel, CurrentVM as PPCViewModel);
await Task.Delay(navigationControl.TransitionDuration.TimeSpan);
- NotifyOnNavigated(fromVM, _currentVM);
+ NotifyOnNavigated(fromVM, CurrentVM);
- onNavigated?.Invoke(fromVM as PPCViewModel, _currentVM as PPCViewModel);
- NotifyAwaitingVMResults(fromVM as PPCViewModel, _currentVM as PPCViewModel);
+ onNavigated?.Invoke(fromVM as PPCViewModel, CurrentVM as PPCViewModel);
+ NotifyAwaitingVMResults(fromVM as PPCViewModel, CurrentVM as PPCViewModel);
}
return true;
@@ -365,7 +382,7 @@ namespace Tango.PPC.UI.Navigation
{
TaskCompletionSource<TResult> source = new TaskCompletionSource<TResult>();
- var fromVM = _currentVM;
+ var fromVM = CurrentVM;
await NavigateTo(typeof(TModule).Name + "." + typeof(TView).Name, pushToHistory, (from, to) =>
{