diff options
9 files changed, 175 insertions, 38 deletions
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Resources/Styles.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Resources/Styles.xaml index 05ef7a3e4..60879a7bd 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Resources/Styles.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Resources/Styles.xaml @@ -30,10 +30,10 @@ <Setter Property="Padding" Value="5"></Setter> <Setter Property="CornerRadius" Value="5"></Setter> <Setter Property="Margin" Value="5 4"></Setter> - <Setter Property="Height" Value="68"></Setter> + <Setter Property="Height" Value="78"></Setter> <Setter Property="Effect"> <Setter.Value> - <DropShadowEffect BlurRadius="5" ShadowDepth="1" Color="Silver" /> + <DropShadowEffect BlurRadius="5" ShadowDepth="1" Color="{StaticResource TangoDropShadowColor}" /> </Setter.Value> </Setter> </Style> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobSummeryViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobSummeryViewVM.cs index 67a1ebbfc..f9e4d7073 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobSummeryViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobSummeryViewVM.cs @@ -25,11 +25,14 @@ namespace Tango.PPC.Jobs.ViewModels public RelayCommand DyeCommand { get; set; } + public RelayCommand EditCommand { get; set; } + public JobSummeryViewVM() { RegisterForMessage<JobSelectedMessage>(HandleJobSelectedMessage); DyeCommand = new RelayCommand(StartJob); + EditCommand = new RelayCommand(EditJob); } private void HandleJobSelectedMessage(JobSelectedMessage message) @@ -37,14 +40,19 @@ namespace Tango.PPC.Jobs.ViewModels Job = message.Job; } + private void EditJob() + { + NavigationManager.NavigateTo<JobsModule>(false, nameof(JobView)); + } + private void StartJob() { - NavigationManager.NavigateTo<JobsModule>(nameof(JobView)); + } public override void OnApplicationStarted() { - + } } } 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 7ecc74c10..90e404307 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 @@ -12,6 +12,9 @@ using Tango.Core.Commands; using System.Windows; using Tango.Touch.Controls; using System.Windows.Media; +using Tango.DragAndDrop; +using System.ComponentModel; +using System.Windows.Data; namespace Tango.PPC.Jobs.ViewModels { @@ -35,6 +38,20 @@ namespace Tango.PPC.Jobs.ViewModels set { _job = value; RaisePropertyChangedAuto(); } } + private ICollectionView _segmentsCollectionView; + /// <summary> + /// Gets or sets the job segments collection view. + /// </summary> + public ICollectionView SegmentsCollectionView + { + get { return _segmentsCollectionView; } + set + { + _segmentsCollectionView = value; + RaisePropertyChangedAuto(); + } + } + private List<ColorSpace> _colorSpaces; /// <summary> /// Gets or sets the available color spaces. @@ -109,6 +126,11 @@ namespace Tango.PPC.Jobs.ViewModels /// </summary> public RelayCommand<Segment> AddBrushStopCommand { get; set; } + /// <summary> + /// Gets or sets the segment dropped command. + /// </summary> + public RelayCommand<DropEventArgs> SegmentDroppedCommand { get; set; } + #endregion #region Constructors @@ -129,6 +151,12 @@ namespace Tango.PPC.Jobs.ViewModels AddSolidSegmentCommand = new RelayCommand(() => AddSolidSegment()); AddBrushStopCommand = new RelayCommand<Segment>(AddBrushStop); AddGradientSegmentCommand = new RelayCommand(() => AddGradientSegment()); + SegmentDroppedCommand = new RelayCommand<DropEventArgs>((e) => + { + DragAndDropSegment( + (e.Draggable as FrameworkElement).DataContext as Segment, + (e.Droppable as FrameworkElement).DataContext as Segment); + }); } #endregion @@ -151,6 +179,32 @@ namespace Tango.PPC.Jobs.ViewModels return Job.AddGradientSegment(); } + /// <summary> + /// Called when a segment has been dragged and dropped into another segment. + /// </summary> + /// <param name="draggedJob">The dragged job.</param> + /// <param name="droppedJob">The dropped job.</param> + private void DragAndDropSegment(Segment draggedSegment, Segment droppedSegment) + { + if (draggedSegment.SegmentIndex > droppedSegment.SegmentIndex) + { + draggedSegment.SegmentIndex = droppedSegment.SegmentIndex - 1; + } + else + { + draggedSegment.SegmentIndex = droppedSegment.SegmentIndex + 1; + } + + int index = 1; + + foreach (var segment in Job.Segments.OrderBy(x => x.SegmentIndex)) + { + segment.SegmentIndex = index++; + } + + SegmentsCollectionView.Refresh(); + } + #endregion #region Brush Stops Management @@ -185,6 +239,9 @@ namespace Tango.PPC.Jobs.ViewModels ColorSpaces = _db.ColorSpaces.ToList(); SpoolTypes = _db.SpoolTypes.ToList(); Customers = _db.Customers.Where(x => x.OrganizationGuid == Job.Machine.Organization.Guid).ToList(); + + SegmentsCollectionView = CollectionViewSource.GetDefaultView(Job.Segments); + SegmentsCollectionView.SortDescriptions.Add(new SortDescription(nameof(Segment.SegmentIndex), ListSortDirection.Ascending)); } #endregion diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobSummeryView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobSummeryView.xaml index 3f6cb437d..b956d7b6c 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobSummeryView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobSummeryView.xaml @@ -4,7 +4,9 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" + xmlns:fa="http://schemas.fontawesome.io/icons/" xmlns:vm="clr-namespace:Tango.PPC.Jobs.ViewModels" + xmlns:controls="clr-namespace:Tango.PPC.Jobs.Controls" xmlns:global="clr-namespace:Tango.PPC.Jobs" xmlns:local="clr-namespace:Tango.PPC.Jobs.Views" mc:Ignorable="d" @@ -24,20 +26,39 @@ </Border> <Grid Grid.Row="1"> - <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Width="400"> - <Image Source="../Images/pantone.png" Width="256" /> - <TextBlock FontSize="{StaticResource TangoHeaderFontSize}"> - <Run Text="{Binding Job.Name,FallbackValue='Name'}"></Run> - <Run>Is Ready</Run> - </TextBlock> - <TextBlock Margin="0 10 0 0">Tap 'DYE' to start dying this job.</TextBlock> + <DockPanel> + <Grid DockPanel.Dock="Bottom" Height="350" Background="{StaticResource TangoPrimaryBackgroundBrush}"> + <StackPanel Margin="50 0 50 0"> + <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0 60 0 0"> + <touch:TouchButton FontSize="{StaticResource TangoExpanderHeaderFontSize}" Command="{Binding EditCommand}" BorderThickness="2" BorderBrush="{StaticResource TangoPrimaryAccentBrush}" RippleBrush="{StaticResource TangoRippleDarkBrush}" Background="Transparent" EnableDropShadow="False" Height="80" Padding="0" Width="270" Foreground="{StaticResource TangoPrimaryAccentBrush}" CornerRadius="40" BlurRadius="20" HorizontalAlignment="Right"> + <StackPanel Orientation="Horizontal"> + <fa:ImageAwesome Icon="Pencil" Width="24" Foreground="{StaticResource TangoPrimaryAccentBrush}" /> + <TextBlock Margin="20 0 0 0" VerticalAlignment="Center">EDIT</TextBlock> + </StackPanel> + </touch:TouchButton> + <touch:TouchButton FontSize="{StaticResource TangoExpanderHeaderFontSize}" Margin="20 0 0 0" Height="80" Padding="0" Width="270" CornerRadius="40" BlurRadius="20" HorizontalAlignment="Right" Command="{Binding DyeCommand}"> + <StackPanel Orientation="Horizontal"> + <TextBlock VerticalAlignment="Center">DYE</TextBlock> + <fa:ImageAwesome Margin="20 0 0 0" Icon="ChevronRight" Width="14" Foreground="{StaticResource TangoPrimaryBackgroundBrush}" /> + </StackPanel> + </touch:TouchButton> + </StackPanel> + </StackPanel> + </Grid> + + <Grid> + <StackPanel VerticalAlignment="Center" Margin="50 0"> + <Image Source="../Images/pantone.png" Width="256" /> + <TextBlock FontSize="{StaticResource TangoHeaderFontSize}" Margin="0 30 0 0"> + <Run>'</Run><Run Text="{Binding Job.Name,FallbackValue='Name'}"></Run><Run>'</Run> + <Run>is ready!</Run> + </TextBlock> + <TextBlock Margin="40 10 0 0" FontSize="{StaticResource TangoTitleFontSize}">Tap 'DYE' to start the dying process...</TextBlock> + </StackPanel> - <Grid Margin="0 40 0 0"> - <touch:TouchButton Height="54" Padding="0" Width="184" CornerRadius="30" BlurRadius="20" HorizontalAlignment="Right" Command="{Binding DyeCommand}"> - DYE - </touch:TouchButton> + <controls:JobSummeryViewer Height="50" Margin="-6 0 -6 0" DataContext="{Binding Job}" VerticalAlignment="Bottom" /> </Grid> - </StackPanel> + </DockPanel> </Grid> </Grid> </UserControl> 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 fc2242631..26a0db10f 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 @@ -151,7 +151,7 @@ <touch:TouchToggleIconButton x:Name="toggleEdit" DockPanel.Dock="Right" Icon="Pencil" CheckedIcon="Pencil" Padding="8" CornerRadius="20" /> </DockPanel> - <ItemsControl Style="{StaticResource Level2Container}" ItemsSource="{Binding Job.Segments}"> + <ItemsControl Style="{StaticResource Level2Container}" ItemsSource="{Binding SegmentsCollectionView}"> <ItemsControl.ItemTemplate> <DataTemplate> <Border Margin="0 0 0 15" CornerRadius="8" Background="{StaticResource TangoPrimaryBackgroundBrush}" BorderThickness="1" BorderBrush="{StaticResource TangoGrayBrush}"> @@ -163,7 +163,17 @@ <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> - <Grid Background="{StaticResource TangoPrimaryBackgroundBrush}" dragAndDrop:DragAndDropService.Draggable="True" dragAndDrop:DragAndDropService.Droppable="True" dragAndDrop:DragAndDropService.DraggingSurface="{Binding ElementName=DraggingSurface}"> + <Grid Background="Transparent" dragAndDrop:DragAndDropService.Draggable="True" dragAndDrop:DragAndDropService.Droppable="True" dragAndDrop:DragAndDropService.DraggingSurface="{Binding ElementName=DraggingSurface}"> + <Grid.Style> + <Style TargetType="Grid"> + <Setter Property="Opacity" Value="1"></Setter> + <Style.Triggers> + <Trigger Property="dragAndDrop:DragAndDropService.IsDraggableOver" Value="True"> + <Setter Property="Opacity" Value="0.5"></Setter> + </Trigger> + </Style.Triggers> + </Style> + </Grid.Style> <DockPanel> <DockPanel.Style> <Style TargetType="DockPanel"> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Navigation/INavigationManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Navigation/INavigationManager.cs index 4a29022e8..09277496d 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Navigation/INavigationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Navigation/INavigationManager.cs @@ -38,20 +38,20 @@ namespace Tango.PPC.Common.Navigation /// Navigates to the specified PPC view. /// </summary> /// <param name="view">The view.</param> - Task<bool> NavigateTo(NavigationView view); + Task<bool> NavigateTo(NavigationView view, bool pushToHistory = true); /// <summary> /// Navigates to the specified module. /// </summary> /// <typeparam name="T"></typeparam> - Task<bool> NavigateTo<T>() where T : IPPCModule; + Task<bool> NavigateTo<T>(bool pushToHistory = true) where T : IPPCModule; /// <summary> /// Navigates to the specified module using the view path (e.g MainView.JobsView). /// </summary> /// <typeparam name="T"></typeparam> /// <param name="viewPath">The view path.</param> - Task<bool> NavigateTo<T>(String viewPath) where T : IPPCModule; + Task<bool> NavigateTo<T>(String viewPath, bool pushToHistory = true) where T : IPPCModule; /// <summary> /// Navigates to the specified module using the view path (e.g MainView,JobsView). @@ -59,12 +59,12 @@ namespace Tango.PPC.Common.Navigation /// </summary> /// <typeparam name="T"></typeparam> /// <param name="viewPath">The view path.</param> - Task<bool> NavigateTo<T>(params String[] viewPath) where T : IPPCModule; + Task<bool> NavigateTo<T>(bool pushToHistory = true, params String[] viewPath) where T : IPPCModule; /// <summary> /// Navigates to the specified module and view by full path (e.g Jobs.JobsView). /// </summary> /// <param name="fullPath">The full path.</param> - Task<bool> NavigateTo(String fullPath); + Task<bool> NavigateTo(String fullPath, bool pushToHistory = true); } } 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 befad6000..9e51d7252 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs @@ -64,7 +64,7 @@ namespace Tango.PPC.UI.Navigation /// Navigates to the specified PPC view. /// </summary> /// <param name="view">The view.</param> - public Task<bool> NavigateTo(NavigationView view) + public Task<bool> NavigateTo(NavigationView view, bool pushToHistory = true) { if (view == NavigationView.HomeModule) { @@ -75,11 +75,11 @@ namespace Tango.PPC.UI.Navigation if (moduleAtt != null) { - return NavigateTo(firstModule.GetType(), moduleAtt.HomeViewName); + return NavigateTo(firstModule.GetType(), pushToHistory, moduleAtt.HomeViewName); } else { - return NavigateTo(firstModule.GetType()); + return NavigateTo(firstModule.GetType(), pushToHistory); } } else @@ -93,7 +93,7 @@ namespace Tango.PPC.UI.Navigation /// Navigates to the specified module. /// </summary> /// <typeparam name="T"></typeparam> - public Task<bool> NavigateTo<T>() where T : IPPCModule + public Task<bool> NavigateTo<T>(bool pushToHistory = true) where T : IPPCModule { return NavigateTo(typeof(T)); } @@ -103,9 +103,9 @@ namespace Tango.PPC.UI.Navigation /// </summary> /// <typeparam name="T"></typeparam> /// <param name="viewPath">The view path.</param> - public Task<bool> NavigateTo<T>(string viewPath) where T : IPPCModule + public Task<bool> NavigateTo<T>(string viewPath, bool pushToHistory = true) where T : IPPCModule { - return NavigateTo<T>(viewPath.Split('.')); + return NavigateTo<T>(pushToHistory, viewPath.Split('.')); } /// <summary> @@ -114,16 +114,16 @@ namespace Tango.PPC.UI.Navigation /// </summary> /// <typeparam name="T"></typeparam> /// <param name="viewPath">The view path.</param> - public Task<bool> NavigateTo<T>(params String[] viewPath) where T : IPPCModule + public Task<bool> NavigateTo<T>(bool pushToHistory = true, params String[] viewPath) where T : IPPCModule { - return NavigateTo(typeof(T), viewPath); + return NavigateTo(typeof(T), pushToHistory, viewPath); } /// <summary> /// Navigates to the specified module and view by full path (e.g Jobs.JobsView). /// </summary> /// <param name="fullPath">The full path.</param> - public async Task<bool> NavigateTo(String fullPath) + public async Task<bool> NavigateTo(String fullPath, bool pushToHistory = true) { String[] path = fullPath.Split('.'); var module = _moduleLoader.UserModules.SingleOrDefault(x => x.GetType().Name == path[0] || x.Name == path[0]); @@ -138,8 +138,11 @@ namespace Tango.PPC.UI.Navigation } } - _navigationHistory.Push(fullPath); - RaisePropertyChanged(nameof(CanNavigateBack)); + if (pushToHistory) + { + _navigationHistory.Push(fullPath); + RaisePropertyChanged(nameof(CanNavigateBack)); + } MainView.Instance.NavigationControl.NavigateTo(NavigationView.LayoutView.ToString()); var navigationControl = LayoutView.Instance.NavigationControl; @@ -172,15 +175,15 @@ namespace Tango.PPC.UI.Navigation return true; } - private Task<bool> NavigateTo(Type moduleType, params String[] viewPath) + private Task<bool> NavigateTo(Type moduleType, bool pushToHistory = true, params String[] viewPath) { if (viewPath != null && viewPath.Length > 0) { - return NavigateTo(moduleType.Name + "." + String.Join(".", viewPath)); + return NavigateTo(moduleType.Name + "." + String.Join(".", viewPath), pushToHistory); } else { - return NavigateTo(moduleType.Name); + return NavigateTo(moduleType.Name, pushToHistory); } } diff --git a/Software/Visual_Studio/Tango.DragAndDrop/DragAndDropService.cs b/Software/Visual_Studio/Tango.DragAndDrop/DragAndDropService.cs index 1ba7907f9..445cc3924 100644 --- a/Software/Visual_Studio/Tango.DragAndDrop/DragAndDropService.cs +++ b/Software/Visual_Studio/Tango.DragAndDrop/DragAndDropService.cs @@ -102,6 +102,37 @@ namespace Tango.DragAndDrop #endregion + #region DropCommand + + /// <summary> + /// Determines whether an element is DropCommand by the drag and drop service. + /// </summary> + public static readonly DependencyProperty DropCommandProperty = + DependencyProperty.RegisterAttached("DropCommand", + typeof(ICommand), typeof(DragAndDropService), + new FrameworkPropertyMetadata(null)); + /// <summary> + /// Sets the DropCommand attached property. + /// </summary> + /// <param name="element">The element.</param> + /// <param name="value">if set to <c>true</c> [value].</param> + public static void SetDropCommand(FrameworkElement element, ICommand value) + { + element.SetValue(DropCommandProperty, value); + } + + /// <summary> + /// Gets the DropCommand attached property. + /// </summary> + /// <param name="element">The element.</param> + /// <returns></returns> + public static ICommand GetDropCommand(FrameworkElement element) + { + return (ICommand)element.GetValue(DropCommandProperty); + } + + #endregion + #region Draggable /// <summary> @@ -672,6 +703,13 @@ namespace Tango.DragAndDrop if (_currentDropElement != null && _currentDragedElement != null) { _currentDropElement.RaiseEvent(new DropEventArgs(DropEvent, _currentDragedElement, _currentDropElement, _mouseDownLocation)); + + var command = GetDropCommand(_currentDropElement); + if (command != null) + { + command.Execute(new DropEventArgs(DropEvent, _currentDragedElement, _currentDropElement, _mouseDownLocation)); + } + _currentDragedElement = null; _currentDropElement = null; } diff --git a/Software/Visual_Studio/Tango.Touch/Resources/Fonts.xaml b/Software/Visual_Studio/Tango.Touch/Resources/Fonts.xaml index fd7f80045..3ea65a957 100644 --- a/Software/Visual_Studio/Tango.Touch/Resources/Fonts.xaml +++ b/Software/Visual_Studio/Tango.Touch/Resources/Fonts.xaml @@ -8,7 +8,7 @@ <sys:Double x:Key="TangoSmallFontSize">14</sys:Double> <sys:Double x:Key="TangoDefaultFontSize">16</sys:Double> <sys:Double x:Key="TangoDataGridHeaderFontSize">16</sys:Double> - <sys:Double x:Key="TangoNavigationLinksFontSize">18</sys:Double> + <sys:Double x:Key="TangoNavigationLinksFontSize">20</sys:Double> <sys:Double x:Key="TangoHeaderFontSize">30</sys:Double> <sys:Double x:Key="TangoTitleFontSize">20</sys:Double> <sys:Double x:Key="TangoButtonFontSize">20</sys:Double> |
