diff options
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation')
| -rw-r--r-- | Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs | 27 |
1 files changed, 22 insertions, 5 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 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<PPCModuleAttribute>(); + + if (moduleAtt != null) + { + NavigateTo(firstModule.GetType(), moduleAtt.HomeViewName); + } } else { @@ -88,16 +95,26 @@ namespace Tango.PPC.UI.Navigation /// <param name="viewPath">The view path.</param> public void NavigateTo<T>(params String[] viewPath) where T : IPPCModule { + NavigateTo(typeof(T), viewPath); + } + + /// <summary> + /// 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)); + /// </summary> + /// <param name="viewPath">The view path.</param> + 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<NavigationControl>(); - 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<NavigationControl>(); } - }); - } + } + }); } } } |
