From 61a68af94273563e1179b49062ac96b8a627a72a Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Thu, 14 Jun 2018 17:32:09 +0300 Subject: Working on PPC. --- .../Navigation/DefaultNavigationManager.cs | 27 ++++++++++++++++++---- 1 file changed, 22 insertions(+), 5 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 82640f899..ae1d29bc2 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Reflection; using System.Text; using System.Threading.Tasks; using System.Windows; @@ -41,6 +42,12 @@ namespace Tango.PPC.UI.Navigation MainView.Instance.NavigationControl.NavigateTo(NavigationView.LayoutView.ToString()); var firstModule = _moduleLoader.UserModules.FirstOrDefault(); LayoutView.Instance.NavigationControl.NavigateTo(firstModule.Name); + var moduleAtt = firstModule.GetType().GetCustomAttribute(); + + if (moduleAtt != null) + { + NavigateTo(firstModule.GetType(), moduleAtt.HomeViewName); + } } else { @@ -87,17 +94,27 @@ namespace Tango.PPC.UI.Navigation /// /// The view path. public void NavigateTo(params String[] viewPath) where T : IPPCModule + { + NavigateTo(typeof(T), viewPath); + } + + /// + /// Navigates to the specified module using the view path (e.g MainView,JobsView). + /// This method makes it easy to do stuff like NavigateTo(nameof(MainView),nameof(JobsView)); + /// + /// The view path. + private void NavigateTo(Type moduleType, params String[] viewPath) { MainView.Instance.NavigationControl.NavigateTo(NavigationView.LayoutView.ToString()); var navigationControl = LayoutView.Instance.NavigationControl; - var module = _moduleLoader.UserModules.SingleOrDefault(x => x.GetType() == typeof(T)); + var module = _moduleLoader.UserModules.SingleOrDefault(x => x.GetType() == moduleType); var moduleView = navigationControl.NavigateTo(module.Name); var moduleNavigation = moduleView.FindChildOffline(); - foreach (var view in viewPath) + moduleNavigation.RegisterForLoadedOrNow(async (x, e) => { - moduleNavigation.RegisterForLoadedOrNow(async (x, e) => + foreach (var view in viewPath) { await Task.Delay(100); var v = moduleNavigation.NavigateTo(view); @@ -106,8 +123,8 @@ namespace Tango.PPC.UI.Navigation { moduleNavigation = v.FindChildOffline(); } - }); - } + } + }); } } } -- cgit v1.3.1