diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-06-14 17:32:09 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-06-14 17:32:09 +0300 |
| commit | 61a68af94273563e1179b49062ac96b8a627a72a (patch) | |
| tree | b435c82b2046ece012b3555afa77c660f0a2b0ca | |
| parent | 580cb401e8b31501cb3fbee1b9f59a67ad636633 (diff) | |
| download | Tango-61a68af94273563e1179b49062ac96b8a627a72a.tar.gz Tango-61a68af94273563e1179b49062ac96b8a627a72a.zip | |
Working on PPC.
17 files changed, 314 insertions, 53 deletions
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/JobsModule.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/JobsModule.cs index 7414a5b7a..ad0eb6f45 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/JobsModule.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/JobsModule.cs @@ -11,7 +11,7 @@ using Tango.SharedUI.Helpers; namespace Tango.PPC.Jobs { - [PPCModule(1)] + [PPCModule(1, nameof(JobsView))] public class JobsModule : PPCModuleBase { public override string Name @@ -56,7 +56,7 @@ namespace Tango.PPC.Jobs public override void Dispose() { - + } } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Messages/JobSelectedMessage.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Messages/JobSelectedMessage.cs new file mode 100644 index 000000000..3b3843f29 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Messages/JobSelectedMessage.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; + +namespace Tango.PPC.Jobs.Messages +{ + /// <summary> + /// Notifies about a job being selected from the job list. + /// </summary> + public class JobSelectedMessage + { + /// <summary> + /// Gets or sets the job. + /// </summary> + public Job Job { get; set; } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj index 23af09c6a..b79d309a8 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj @@ -87,6 +87,7 @@ </Compile> <Compile Include="Converters\JobToPieImageConverter.cs" /> <Compile Include="JobsModule.cs" /> + <Compile Include="Messages\JobSelectedMessage.cs" /> <Compile Include="Properties\AssemblyInfo.cs"> <SubType>Code</SubType> </Compile> @@ -101,8 +102,8 @@ <DesignTimeSharedInput>True</DesignTimeSharedInput> </Compile> <Compile Include="ViewModelLocator.cs" /> - <Compile Include="ViewModels\JobViewVM.cs" /> <Compile Include="ViewModels\JobsViewVM.cs" /> + <Compile Include="ViewModels\JobViewVM.cs" /> <Compile Include="ViewModels\MainViewVM.cs" /> <Compile Include="Views\JobsView.xaml.cs"> <DependentUpon>JobsView.xaml</DependentUpon> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs index 55c5850f2..7af3dc7b9 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs @@ -3,15 +3,59 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.BL.Entities; using Tango.PPC.Common; +using Tango.PPC.Jobs.Messages; namespace Tango.PPC.Jobs.ViewModels { + /// <summary> + /// Represents the selected job view model. + /// </summary> + /// <seealso cref="Tango.PPC.Common.PPCViewModel" /> public class JobViewVM : PPCViewModel { + private Job _selectedJob; + /// <summary> + /// Gets or sets the selected job. + /// </summary> + public Job SelectedJob + { + get { return _selectedJob; } + set { _selectedJob = value; RaisePropertyChangedAuto(); } + } + + /// <summary> + /// Initializes a new instance of the <see cref="JobViewVM"/> class. + /// </summary> + public JobViewVM() + { + RegisterForMessage<JobSelectedMessage>(HandleJobSelectedMessage); + } + + /// <summary> + /// Handles the job selected message. + /// </summary> + /// <param name="message">The message.</param> + private void HandleJobSelectedMessage(JobSelectedMessage message) + { + SelectedJob = message.Job; + } + + /// <summary> + /// Called when the application has been started. + /// </summary> public override void OnApplicationStarted() { } + + /// <summary> + /// Called when the navigation system has navigated to this VM view. + /// </summary> + public override void OnNavigatedTo() + { + base.OnNavigatedTo(); + } } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs index eabf8b985..fabb57d10 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs @@ -11,16 +11,28 @@ using System.Windows.Data; using Tango.BL; using Tango.BL.Entities; using Tango.Core.Commands; +using Tango.Core.DI; using Tango.DragAndDrop; using Tango.PPC.Common; +using Tango.PPC.Jobs.Messages; +using Tango.PPC.Jobs.Views; namespace Tango.PPC.Jobs.ViewModels { + /// <summary> + /// Represents the jobs view model. + /// </summary> + /// <seealso cref="Tango.PPC.Common.PPCViewModel" /> public class JobsViewVM : PPCViewModel { - private ObservablesContext _jobsContext; + private ObservablesContext _jobsContext; //Holds the db context for the job list. + + #region Properties private ObservableCollection<Job> _jobs; + /// <summary> + /// Gets or sets the collection of jobs. + /// </summary> public ObservableCollection<Job> Jobs { get { return _jobs; } @@ -41,16 +53,52 @@ namespace Tango.PPC.Jobs.ViewModels } } + #endregion + + #region Commands + + /// <summary> + /// Gets or sets the job selected command. + /// </summary> public RelayCommand<Object> JobSelectedCommand { get; set; } - public RelayCommand<DropEventArgs> OnDragAndDropCommand { get; set; } + /// <summary> + /// Gets or sets the job drag and drop command. + /// </summary> + public RelayCommand<DropEventArgs> JobDragedDroppedCommand { get; set; } + + #endregion - public RelayCommand<Job> RemoveJobCommand { get; set; } + #region Constructors - private void OnDragAndDropJobs(Job draggedJob, Job droppedJob) + /// <summary> + /// Initializes a new instance of the <see cref="JobsViewVM"/> class. + /// </summary> + public JobsViewVM() { - Debug.WriteLine(draggedJob.Name + " Dragged on to " + droppedJob.Name); + Jobs = new ObservableCollection<Job>(); + + JobSelectedCommand = new RelayCommand<Object>((x) => JobSelected(x as Job)); + JobDragedDroppedCommand = new RelayCommand<DropEventArgs>((e) => + { + Job draggedJob = e.Draggable.DataContext as Job; + Job droppedJob = e.Droppable.DataContext as Job; + OnDragAndDropJob(draggedJob, droppedJob); + }); + } + + #endregion + + #region Drag & Drop + + /// <summary> + /// Called when a job has been dragged and dropped into another job. + /// </summary> + /// <param name="draggedJob">The dragged job.</param> + /// <param name="droppedJob">The dropped job.</param> + private void OnDragAndDropJob(Job draggedJob, Job droppedJob) + { if (draggedJob.JobIndex > droppedJob.JobIndex) { draggedJob.JobIndex = droppedJob.JobIndex - 1; @@ -70,43 +118,23 @@ namespace Tango.PPC.Jobs.ViewModels JobsCollectionView.Refresh(); } - private async void JobSelected(Job job) - { - Debug.WriteLine(job.Name); - await NotificationProvider.ShowInfo("Job details not yet implemented..."); - } - - public JobsViewVM() - { - Jobs = new ObservableCollection<Job>(); - - JobSelectedCommand = new RelayCommand<Object>((x) => JobSelected(x as Job)); - OnDragAndDropCommand = new RelayCommand<DropEventArgs>((e) => - { - Job draggedJob = e.Draggable.DataContext as Job; - Job droppedJob = e.Droppable.DataContext as Job; - - OnDragAndDropJobs(draggedJob, droppedJob); - }); - - RemoveJobCommand = new RelayCommand<Job>(RemoveJob); - } - - private void RemoveJob(Job job) - { - NotificationProvider.ShowQuestion("Are you sure you want to remove " + job.Name); - } + #endregion - public override void OnApplicationStarted() - { - LoadJobs(); - } + #region Job Selection & Loading - public override void OnNavigatedTo() + /// <summary> + /// Handles the job selected command. + /// </summary> + /// <param name="job">The job.</param> + private void JobSelected(Job job) { - base.OnNavigatedTo(); + NavigationManager.NavigateTo<JobsModule>(nameof(JobView)); + RaiseMessage(new JobSelectedMessage() { Job = job }); } + /// <summary> + /// Loads the jobs the database. + /// </summary> private void LoadJobs() { Task.Factory.StartNew(() => @@ -125,5 +153,31 @@ namespace Tango.PPC.Jobs.ViewModels JobsCollectionView.SortDescriptions.Add(new SortDescription(nameof(Job.LastUpdated), ListSortDirection.Descending)); }); } + + #endregion + + #region Override Methods + + /// <summary> + /// Called when the application has been started. + /// </summary> + public override void OnApplicationStarted() + { + LoadJobs(); + } + + /// <summary> + /// Called when the navigation system has navigated to this VM view. + /// </summary> + public override void OnNavigatedTo() + { + base.OnNavigatedTo(); + } + + public override void OnNavigatedFrom() + { + base.OnNavigatedFrom(); + } + #endregion } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml index 993b2365a..16a448d67 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml @@ -8,7 +8,17 @@ xmlns:local="clr-namespace:Tango.PPC.Jobs.Views" mc:Ignorable="d" d:DesignHeight="1280" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:JobViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.JobViewVM}"> - <Grid> - + <Grid Background="{StaticResource TangoMidBackgroundBrush}"> + <Grid.RowDefinitions> + <RowDefinition Height="Auto"/> + <RowDefinition Height="1*"/> + </Grid.RowDefinitions> + + <Border Padding="20" Background="{StaticResource TangoPrimaryBackgroundBrush}" BorderThickness="0 0 0 1" BorderBrush="{StaticResource TangoDividerBrush}"> + <Border.Effect> + <DropShadowEffect Color="Silver" ShadowDepth="0" BlurRadius="20" Opacity="1" /> + </Border.Effect> + <TextBlock VerticalAlignment="Center" FontSize="{StaticResource TangoHeaderFontSize}" FontWeight="SemiBold" Text="{Binding SelectedJob.Name}"></TextBlock> + </Border> </Grid> </UserControl> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobsView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobsView.xaml index 56c444fb7..dd76d0ed5 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobsView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobsView.xaml @@ -58,7 +58,7 @@ </touch:TouchNavigationLinks> <Grid Grid.Row="1"> - <touch:LightTouchDataGrid x:Name="dataGridJobs" OnDragAndDropCommand="{Binding OnDragAndDropCommand}" ItemsSource="{Binding JobsCollectionView}" ItemSelectedCommand="{Binding JobSelectedCommand}" Margin="10"> + <touch:LightTouchDataGrid x:Name="dataGridJobs" OnDragAndDropCommand="{Binding JobDragedDroppedCommand}" ItemsSource="{Binding JobsCollectionView}" ItemSelectedCommand="{Binding JobSelectedCommand}" Margin="10"> <touch:LightTouchDataGrid.Columns> <touch:LightTouchDataGridColumn> <touch:LightTouchDataGridColumn.Header> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/MainView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/MainView.xaml index 6b62bcc30..6eacfa8df 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/MainView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/MainView.xaml @@ -11,7 +11,7 @@ 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 TransitionType="Slide"> + <controls:NavigationControl TransitionType="Slide" TransitionDuration="00:00:0.2"> <views:JobsView /> <views:JobView /> </controls:NavigationControl> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCModuleAttribute.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCModuleAttribute.cs index 933791268..e166fef04 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCModuleAttribute.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCModuleAttribute.cs @@ -19,6 +19,11 @@ namespace Tango.PPC.Common public int Index { get; private set; } /// <summary> + /// Gets or sets the home view. + /// </summary> + public String HomeViewName { get; set; } + + /// <summary> /// Initializes a new instance of the <see cref="PPCModuleAttribute"/> class. /// </summary> /// <param name="index">The module index.</param> @@ -26,5 +31,15 @@ namespace Tango.PPC.Common { Index = index; } + + /// <summary> + /// Initializes a new instance of the <see cref="PPCModuleAttribute"/> class. + /// </summary> + /// <param name="index">The module index.</param> + /// <param name="homeViewName">Name of the home view.</param> + public PPCModuleAttribute(int index, String homeViewName) : this(index) + { + HomeViewName = homeViewName; + } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs index dc7976884..fcce155ab 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs @@ -109,6 +109,26 @@ namespace Tango.PPC.Common { Visible = false; } + + /// <summary> + /// Raises the specified message using the default <see cref="TangoMessenger"/>. + /// </summary> + /// <typeparam name="T"></typeparam> + /// <param name="message">The message.</param> + protected void RaiseMessage<T>(T message) where T : class + { + TangoMessenger.Default.Send<T>(message); + } + + /// <summary> + /// Registers a message handle for the specified message type T. + /// </summary> + /// <typeparam name="T"></typeparam> + /// <param name="handler">The handler.</param> + protected void RegisterForMessage<T>(Action<T> handler) + { + TangoMessenger.Default.Register<T>(handler); + } } /// <summary> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/App.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/App.xaml.cs index 1e3a16e3e..4b4c7acb9 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/App.xaml.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/App.xaml.cs @@ -18,6 +18,10 @@ namespace Tango.PPC.UI /// </summary> public partial class App : Application { + /// <summary> + /// Raises the <see cref="E:System.Windows.Application.Startup" /> event. + /// </summary> + /// <param name="e">A <see cref="T:System.Windows.StartupEventArgs" /> that contains the event data.</param> protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Modules/DefaultStudioModuleLoader.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Modules/DefaultStudioModuleLoader.cs index bb68f05cd..78ebd8ded 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Modules/DefaultStudioModuleLoader.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Modules/DefaultStudioModuleLoader.cs @@ -13,6 +13,7 @@ using Tango.PPC.Common.Authentication; using Tango.PPC.Common.Modules; using Tango.PPC.Common; using Tango.PPC.Jobs; +using System.Windows.Data; namespace Tango.PPC.UI.Modules { @@ -23,6 +24,7 @@ namespace Tango.PPC.UI.Modules /// <seealso cref="Tango.PPC.Common.Modules.IPPCModuleLoader" /> public class DefaultPPCModuleLoader : ExtendedObject, IPPCModuleLoader { + private static object _syncObject = new object(); private IAuthenticationProvider _authenticationProvider; private bool _loaded; @@ -40,6 +42,9 @@ namespace Tango.PPC.UI.Modules _authenticationProvider = authenticationProvider; AllModules = new ObservableCollection<IPPCModule>(); UserModules = new ObservableCollection<IPPCModule>(); + + BindingOperations.EnableCollectionSynchronization(UserModules, _syncObject); + _authenticationProvider.CurrentUserChanged += _authenticationProvider_CurrentUserChanged; } 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>(); } - }); - } + } + }); } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs index 4e200ada6..8731bc7d9 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs @@ -3,9 +3,11 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.Core.Commands; using Tango.Core.DI; using Tango.PPC.Common; using Tango.PPC.Common.Modules; +using Tango.PPC.Common.Navigation; using Tango.PPC.UI.ViewsContracts; using Tango.SharedUI; @@ -23,6 +25,54 @@ namespace Tango.PPC.UI.ViewModels [TangoInject] public IPPCModuleLoader ModuleLoader { get; set; } + private bool _isMenuOpened; + /// <summary> + /// Gets or sets a value indicating whether the side menu is opened. + /// </summary> + public bool IsMenuOpened + { + get { return _isMenuOpened; } + set { _isMenuOpened = value; RaisePropertyChangedAuto(); } + } + + /// <summary> + /// Gets or sets the module navigation command. + /// </summary> + public RelayCommand<String> ModuleNavigationCommand { get; set; } + + /// <summary> + /// Gets or sets the home command. + /// </summary> + public RelayCommand HomeCommand { get; set; } + + /// <summary> + /// Initializes a new instance of the <see cref="LayoutViewVM"/> class. + /// </summary> + public LayoutViewVM() + { + ModuleNavigationCommand = new RelayCommand<string>(HandleModuleNavigationCommand); + HomeCommand = new RelayCommand(HandleHomeCommand); + } + + /// <summary> + /// Handles the module navigation command. + /// </summary> + /// <param name="moduleName">Name of the module.</param> + private void HandleModuleNavigationCommand(string moduleName) + { + IsMenuOpened = false; + NavigationManager.NavigateTo(moduleName); + } + + /// <summary> + /// Handles the home command. + /// </summary> + private void HandleHomeCommand() + { + IsMenuOpened = false; + NavigationManager.NavigateTo(NavigationView.HomeModule); + } + /// <summary> /// Called when the application has been started. /// </summary> 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 8baeab6a4..d7c9fc39e 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml @@ -15,7 +15,7 @@ d:DesignHeight="1280" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:LayoutViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.LayoutViewVM}"> <Grid> - <touch:TouchSideMenu x:Name="menu"> + <touch:TouchSideMenu x:Name="menu" IsOpened="{Binding IsMenuOpened,Mode=TwoWay}"> <touch:TouchSideMenu.MenuContent> <Border x:Name="border" BorderThickness="0 0 1 0" BorderBrush="{StaticResource TangoDividerBrush}"> <DockPanel LastChildFill="False" Background="{StaticResource TangoPrimaryBackgroundBrush}"> @@ -52,13 +52,26 @@ </StackPanel> </Grid> <StackPanel Margin="0 16 0 0"> - <touch:TouchButton Style="{StaticResource TangoFlatButton}"> + <touch:TouchButton Style="{StaticResource TangoFlatButton}" Command="{Binding HomeCommand}"> <StackPanel Orientation="Horizontal" HorizontalAlignment="Left"> <fa:ImageAwesome VerticalAlignment="Center" Icon="Home" Width="32" Height="32"></fa:ImageAwesome> <TextBlock FontSize="16" VerticalAlignment="Center" Margin="10 0 0 0">Home</TextBlock> </StackPanel> </touch:TouchButton> </StackPanel> + + <ItemsControl ItemsSource="{Binding ModuleLoader.UserModules}" Margin="0 20 0 0"> + <ItemsControl.ItemTemplate> + <DataTemplate> + <touch:TouchButton Style="{StaticResource TangoFlatButton}" Command="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.ModuleNavigationCommand}" CommandParameter="{Binding Name}"> + <StackPanel Orientation="Horizontal" HorizontalAlignment="Left"> + <Image VerticalAlignment="Center" Source="{Binding Image}" Width="32" Height="32"></Image> + <TextBlock FontSize="16" VerticalAlignment="Center" Margin="10 0 0 0" Text="{Binding Name}"></TextBlock> + </StackPanel> + </touch:TouchButton> + </DataTemplate> + </ItemsControl.ItemTemplate> + </ItemsControl> </StackPanel> <StackPanel DockPanel.Dock="Bottom"> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewsContracts/ILayoutView.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewsContracts/ILayoutView.cs index f79c790ff..f01785d57 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewsContracts/ILayoutView.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewsContracts/ILayoutView.cs @@ -7,8 +7,16 @@ using Tango.PPC.Common; namespace Tango.PPC.UI.ViewsContracts { + /// <summary> + /// Represents the <see cref="ILayoutView"/> contract. + /// </summary> + /// <seealso cref="Tango.PPC.Common.IPPCView" /> public interface ILayoutView : IPPCView { + /// <summary> + /// Inserts the specified modules into the navigation system. + /// </summary> + /// <param name="modules">The modules.</param> void ApplyModules(IEnumerable<IPPCModule> modules); } } diff --git a/Software/Visual_Studio/Tango.SharedUI/Controls/NavigationControl.cs b/Software/Visual_Studio/Tango.SharedUI/Controls/NavigationControl.cs index b6f582594..25d9a14d4 100644 --- a/Software/Visual_Studio/Tango.SharedUI/Controls/NavigationControl.cs +++ b/Software/Visual_Studio/Tango.SharedUI/Controls/NavigationControl.cs @@ -368,11 +368,11 @@ namespace Tango.SharedUI.Controls navigationView.OnNavigated(); } + INavigationViewModel fromVM = fromElement.Element.DataContext as INavigationViewModel; INavigationViewModel toVM = toElement.Element.DataContext as INavigationViewModel; - INavigationViewModel fromVM = toElement.Element.DataContext as INavigationViewModel; - if (toVM != null) toVM.OnNavigatedTo(); if (fromVM != null && fromVM != toVM) fromVM.OnNavigatedFrom(); + if (toVM != null) toVM.OnNavigatedTo(); }; switch (TransitionType) |
