diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-06-14 11:57:22 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-06-14 11:57:22 +0300 |
| commit | 03959e785f635697fcdf0f99aad9454fafbf4e2e (patch) | |
| tree | dbaf0350a9fbf7502057f01a9b34fd2ff15df9fd /Software/Visual_Studio/PPC/Tango.PPC.UI | |
| parent | cc08947f9bc9f1f98ab8835200fb7cda0494cff2 (diff) | |
| download | Tango-03959e785f635697fcdf0f99aad9454fafbf4e2e.tar.gz Tango-03959e785f635697fcdf0f99aad9454fafbf4e2e.zip | |
Improved UdpDiscoveryClient (I Think...).
Improved PPC NavigationManager by providing a way to navigate by module/view paths..
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI')
6 files changed, 67 insertions, 17 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 12c759c1a..8c42a3a44 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs @@ -3,7 +3,10 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows; +using System.Windows.Media; using Tango.PPC.Common; +using Tango.PPC.Common.Modules; using Tango.PPC.Common.Navigation; using Tango.PPC.UI.Views; using Tango.SharedUI.Controls; @@ -12,23 +15,68 @@ namespace Tango.PPC.UI.Navigation { public class DefaultNavigationManager : INavigationManager { + private IPPCModuleLoader _moduleLoader; + + public DefaultNavigationManager(IPPCModuleLoader moduleLoader) + { + _moduleLoader = moduleLoader; + } + public void NavigateTo(NavigationView view) { - NavigationControl[] controls = new NavigationControl[] + if (view == NavigationView.HomeModule) { - MainView.Instance.NavigationControl, - LayoutView.Instance.NavigationControl - }; - - var control = controls.Where(x => x.Elements.ToList().Exists(y => NavigationControl.GetNavigationName(y) == view.ToString())).SingleOrDefault(); - control.NavigateTo(view.ToString()); + MainView.Instance.NavigationControl.NavigateTo(NavigationView.LayoutView.ToString()); + var firstModule = _moduleLoader.UserModules.FirstOrDefault(); + LayoutView.Instance.NavigationControl.NavigateTo(firstModule.Name); + } + else + { + MainView.Instance.NavigationControl.NavigateTo(view.ToString()); + } } public void NavigateTo<T>() where T : IPPCModule { + MainView.Instance.NavigationControl.NavigateTo(NavigationView.LayoutView.ToString()); var navigationControl = LayoutView.Instance.NavigationControl; + var module = _moduleLoader.UserModules.SingleOrDefault(x => x.GetType() == typeof(T)); + navigationControl.NavigateTo(module.Name); + } + public void NavigateTo<T>(string viewPath) where T : IPPCModule + { + NavigateTo<T>(viewPath.Split(',')); + } + public void NavigateTo<T>(params String[] viewPath) where T : IPPCModule + { + MainView.Instance.NavigationControl.NavigateTo(NavigationView.LayoutView.ToString()); + var navigationControl = LayoutView.Instance.NavigationControl; + var module = _moduleLoader.UserModules.SingleOrDefault(x => x.GetType() == typeof(T)); + var moduleView = navigationControl.NavigateTo(module.Name); + + var moduleNavigation = moduleView.FindChildOffline<NavigationControl>(); + + foreach (var view in viewPath) + { + moduleNavigation.RegisterForLoadedOrNow(async (x, e) => + { + await Task.Delay(100); + var v = moduleNavigation.NavigateTo(view); + + if (view != viewPath.Last()) + { + moduleNavigation = v.FindChildOffline<NavigationControl>(); + } + }); + } + } + + public void NavigateTo(string moduleName) + { + var navigationControl = LayoutView.Instance.NavigationControl; + navigationControl.NavigateTo(moduleName); } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs index 8b772b8bc..2fbc6c34e 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs @@ -15,6 +15,7 @@ using Tango.Core; using System.IO; using Tango.Core.Helpers; using Tango.PPC.Common.Modules; +using System.Windows.Threading; namespace Tango.PPC.UI.PPCApplication { diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs index 20752ac71..588cc8b64 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs @@ -6,18 +6,24 @@ using System.Text; using System.Threading.Tasks; using Tango.BL; using Tango.Core; +using Tango.Core.DI; using Tango.Core.Helpers; using Tango.PPC.Common; using Tango.PPC.Common.Application; using Tango.PPC.Common.Authentication; +using Tango.PPC.Common.Modules; using Tango.PPC.Common.Navigation; using Tango.PPC.Common.Notifications; +using Tango.PPC.Jobs; using Tango.SharedUI; namespace Tango.PPC.UI.ViewModels { public class LoadingViewVM : PPCViewModel { + [TangoInject] + public IPPCModuleLoader ModuleLoader { get; set; } + public async override void OnApplicationStarted() { await Task.Factory.StartNew(() => @@ -27,7 +33,7 @@ namespace Tango.PPC.UI.ViewModels ApplicationManager.ModulesInitialized += (_, __) => { - NavigationManager.NavigateTo(NavigationView.LayoutView); + NavigationManager.NavigateTo(NavigationView.HomeModule); }; await AuthenticationProvider.Login("roy@twine-s.com", "1234"); diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml index 46e104627..8baeab6a4 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml @@ -97,7 +97,7 @@ <Grid Background="{StaticResource TangoKeyboardBackground}"> <Grid> <keyboard:KeyboardView> - <controls:NavigationControl x:Name="NavigationControl" x:FieldModifier="public" TransitionAlwaysFades="False" TransitionType="Slide"> + <controls:NavigationControl x:Name="NavigationControl" x:FieldModifier="public" TransitionAlwaysFades="False" TransitionType="Zoom"> </controls:NavigationControl> </keyboard:KeyboardView> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml.cs index 8ab602f2c..18ffa8ab2 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml.cs @@ -46,11 +46,6 @@ namespace Tango.PPC.UI.Views module.Initialize(); } } - - if (modules.Count() > 0) - { - NavigationControl.NavigateTo(modules.First().Name); - } }); } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml index 8da05f0dd..1bfdda517 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml @@ -11,9 +11,9 @@ mc:Ignorable="d" d:DesignHeight="1280" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> <Grid> - <controls:NavigationControl TransitionAlwaysFades="True" TransitionType="Zoom" x:Name="NavigationControl" x:FieldModifier="public"> - <local:LoadingView controls:NavigationControl.NavigationName="LoadingView"></local:LoadingView> - <local:LayoutView controls:NavigationControl.NavigationName="LayoutView"></local:LayoutView> + <controls:NavigationControl TransitionAlwaysFades="True" TransitionType="Zoom" x:Name="NavigationControl" x:FieldModifier="public" KeepElementsAttached="True"> + <local:LoadingView></local:LoadingView> + <local:LayoutView></local:LayoutView> </controls:NavigationControl> <Grid Background="#9E000000"> |
