diff options
| author | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2021-11-01 14:53:16 +0200 |
|---|---|---|
| committer | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2021-11-01 14:53:16 +0200 |
| commit | 20f49c625cd32b95154db138ed7eeebbadd04bf7 (patch) | |
| tree | 951627b53972a48e77f9c3d11e9de5295e15fa45 /Software/Visual_Studio/PPC | |
| parent | b1049c0822b76939215225a617e143274abe2e8b (diff) | |
| download | Tango-20f49c625cd32b95154db138ed7eeebbadd04bf7.tar.gz Tango-20f49c625cd32b95154db138ed7eeebbadd04bf7.zip | |
Color selection and Job sequence package. Redesign list control, move Color Selection View to dialogs, implement save.
Diffstat (limited to 'Software/Visual_Studio/PPC')
23 files changed, 946 insertions, 963 deletions
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Converters/ColorTabToVisibilityConverter.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Converters/ColorTabToVisibilityConverter.cs index 9189d6172..6f9a95ccf 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Converters/ColorTabToVisibilityConverter.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Converters/ColorTabToVisibilityConverter.cs @@ -6,7 +6,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Data; -using static Tango.PPC.Jobs.ViewModels.ColorSelectionToolViewVM; +using static Tango.PPC.Jobs.Dialogs.ColorSelectionViewVM; namespace Tango.PPC.Jobs.Converters { diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/ColorSelectionToolView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionView.xaml index 9d48df2fb..a095ff7aa 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/ColorSelectionToolView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionView.xaml @@ -1,19 +1,18 @@ -<UserControl x:Class="Tango.PPC.Jobs.Views.ColorSelectionToolView" +<UserControl x:Class="Tango.PPC.Jobs.Dialogs.ColorSelectionView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" - xmlns:vm="clr-namespace:Tango.PPC.Jobs.ViewModels" + xmlns:local="clr-namespace:Tango.PPC.Jobs.Dialogs" + xmlns:vm="clr-namespace:Tango.PPC.Jobs.Dialogs" xmlns:controls="clr-namespace:Tango.PPC.Jobs.Controls" xmlns:sharedConverters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" xmlns:converters="clr-namespace:Tango.PPC.Jobs.Converters" xmlns:global="clr-namespace:Tango.PPC.Jobs" - xmlns:local="clr-namespace:Tango.PPC.Jobs.Views" - mc:Ignorable="d" - d:DesignHeight="1280" d:DesignWidth="800" Background="{StaticResource TangoPrimaryBackgroundBrush}" - d:DataContext="{d:DesignInstance Type=vm:ColorSelectionToolViewVM, IsDesignTimeCreatable=False}" - DataContext="{x:Static global:ViewModelLocator.ColorSelectionToolViewVM}"> + mc:Ignorable="d" + d:DesignHeight="1280" d:DesignWidth="800" Width="750" Height="1200" Background="{StaticResource TangoPrimaryBackgroundBrush}" + d:DataContext="{d:DesignInstance Type=vm:ColorSelectionViewVM, IsDesignTimeCreatable=False}"> <UserControl.Resources> <ResourceDictionary> @@ -27,10 +26,10 @@ <sharedConverters:BooleanInverseConverter x:Key="BooleanInverseConverter"/> <DataTemplate x:Key="brushColorPanel"> - <Grid Height=" 180" Margin="93 10 0 0" HorizontalAlignment="Stretch"> + <Grid Height="180" Margin="93 10 0 0" HorizontalAlignment="Stretch"> <Grid.ColumnDefinitions> - <ColumnDefinition Width="3*"/> - <ColumnDefinition Width="2*"/> + <ColumnDefinition Width="1*"/> + <ColumnDefinition Width="270"/> </Grid.ColumnDefinitions> <StackPanel Orientation="Vertical" Visibility="{Binding IsEditMode, Converter={StaticResource BooleanToVisibilityConverter}}"> <TextBlock FontSize="{StaticResource TangoDataGridHeaderFontSize}" > @@ -73,7 +72,7 @@ <TextBlock Margin="10 0" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="{StaticResource TangoLightForegroundBrush}" FontSize="{StaticResource TangoSmallFontSize}" FontWeight="SemiBold" Text="This color is not supported." ></TextBlock> </Border> </StackPanel> - <StackPanel Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Center" Visibility="{Binding SelectedBrushStop.IsCMYKLiquidVolumesOutOfRange,Converter={StaticResource BooleanToVisibilityConverter}}"> + <StackPanel Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Center" Visibility="{Binding SelectedBrushStop.IsLiquidVolumesOutOfRange,Converter={StaticResource BooleanToVisibilityConverter}}"> <Image Margin="30 0 24 0" Stretch="Fill" Width="37" Height="33" RenderOptions.BitmapScalingMode="Fant" Source="../Images/JobView/Exclamation_black.png" HorizontalAlignment="Center"></Image> <Border Margin=" 0 10 0 0" MinWidth="115" Height="31" Background="{StaticResource TangoDarkForegroundBrush}" CornerRadius="2"> <TextBlock Margin="10 0" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="{StaticResource TangoLightForegroundBrush}" FontSize="{StaticResource TangoSmallFontSize}" FontWeight="SemiBold" Text="Maximum ink level is reached." ></TextBlock> @@ -93,15 +92,15 @@ <Image Margin="30 0 0 0" Stretch="Fill" VerticalAlignment="Center" Width="20" Height="13" RenderOptions.BitmapScalingMode="Fant" Source="../Images/ColorSelection/arrow-round-back.png"></Image> <StackPanel Grid.Column="1" Orientation="Vertical" HorizontalAlignment="Stretch" Margin="26 0 93 0" > - <TextBlock Text="Best match" FontSize="{StaticResource TangoDataGridHeaderFontSize}" HorizontalAlignment="Left"/> - <Border HorizontalAlignment="Stretch" VerticalAlignment="Center" Height="100" Margin="0 21 0 0" CornerRadius="20" BorderThickness="1" BorderBrush="{StaticResource TangoGrayBrush}"> + <TextBlock Text="Best Match" FontSize="{StaticResource TangoDataGridHeaderFontSize}" HorizontalAlignment="Left"/> + <Border HorizontalAlignment="Stretch" VerticalAlignment="Center" Height="100" Width="100" Margin="0 21 0 0" CornerRadius="20" BorderThickness="1" BorderBrush="{StaticResource TangoGrayBrush}"> <Border.Background> <SolidColorBrush Color="{Binding SelectedBrushStop.DisplayedColor}"/> </Border.Background> <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Visibility="{Binding SelectedBrushStop.IsBusy,Converter={StaticResource BooleanToVisibilityConverter}}"> <touch:TouchBusyIndicator HorizontalAlignment="Center" Minimum="0" Maximum="100" IsIndeterminate="True" Foreground="White" Width="32" Height="32" /> - <TextBlock HorizontalAlignment="Center" Margin="0 10 0 0" Text="Color conversion"></TextBlock> + <TextBlock HorizontalAlignment="Center" Margin="0 10 0 0" Foreground="{StaticResource TangoLightForegroundBrush}" Text="Processing..."></TextBlock> </StackPanel> </Border> </StackPanel> @@ -139,38 +138,29 @@ <TextBlock FontSize="{StaticResource TangoDefaultFontSize}" VerticalAlignment="Center"> Job Palette</TextBlock> <Rectangle Margin="0 10 20 0" Stroke="{StaticResource TangoDarkForegroundBrush}" Height="1" VerticalAlignment="Bottom"/> </StackPanel> - <touch:TouchButton Grid.Row="2" CornerRadius="24" Width="180" Height="48" TextElement.Foreground="{StaticResource TangoLightForegroundBrush}" TextElement.FontSize="{StaticResource TangoExpanderHeaderFontSize}" Command="{Binding OKCommand}" IsEnabled="{Binding SelectedBrushStop.IsCMYKLiquidVolumesOutOfRange, Converter={StaticResource BooleanInverseConverter}}" Content="OK"> - <touch:TouchButton.Style> - <Style TargetType="touch:TouchButton"> - <Setter Property="Background" Value="{StaticResource TangoMidAccentBrush}"/> - <Style.Triggers> - <Trigger Property="IsEnabled" Value="False"> - <Setter Property="Background" Value="{StaticResource TangoDisabledBackgroundBrush}"></Setter> - <Setter Property="BorderBrush" Value="{StaticResource TangoDisabledBackgroundBrush}"></Setter> - <Setter Property="Foreground" Value="{StaticResource TangoDisabledForegroundBrush}"></Setter> - </Trigger> - </Style.Triggers> - </Style> - </touch:TouchButton.Style> - </touch:TouchButton> + + <Grid DockPanel.Dock="Bottom" Grid.Row="2"> + <touch:TouchButton HorizontalAlignment="Left" CornerRadius="25" Command="{Binding CloseCommand}" Style="{StaticResource TangoHollowButton}" Width="200" Height="50" VerticalAlignment="Bottom">CANCEL</touch:TouchButton> + <touch:TouchButton HorizontalAlignment="Right" CornerRadius="25" Command="{Binding OKCommand}" Style="{StaticResource TangoHollowButton}" Width="200" Height="50" VerticalAlignment="Bottom">CONFIRM</touch:TouchButton> + </Grid> </Grid> </DataTemplate> </ResourceDictionary> </UserControl.Resources> <Grid> <Border Background="#E5E5E5"> - <Grid Margin="24" Background="{StaticResource TangoPrimaryBackgroundBrush}"> + <Grid Background="{StaticResource TangoPrimaryBackgroundBrush}"> <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">Color Selection Tool</TextBlock> - </Border> + <Border.Effect> + <DropShadowEffect Color="Silver" ShadowDepth="0" BlurRadius="20" Opacity="1" /> + </Border.Effect> + <TextBlock VerticalAlignment="Center" FontSize="{StaticResource TangoHeaderFontSize}" FontWeight="SemiBold">Color Selection Tool</TextBlock> + </Border> <Grid Grid.Row="1"> <Grid.RowDefinitions> <RowDefinition Height="100"/> @@ -201,45 +191,44 @@ <Grid Grid.Row="1" x:Name="HSBGrid"> - <touch:TouchLoadingPanel x:Name="hsbPanel" Visibility="{Binding SelectedColorTab,Converter={StaticResource ColorTabToVisibilityConverter},ConverterParameter='HSB'}"> - <Grid Margin="0"> - <Grid.RowDefinitions> - <RowDefinition Height="Auto" /> - <RowDefinition Height="Auto" /> - <RowDefinition Height="Auto" /> - <RowDefinition Height="1*" /> - </Grid.RowDefinitions> + + <Grid Visibility="{Binding SelectedColorTab,Converter={StaticResource ColorTabToVisibilityConverter},ConverterParameter='HSB'}"> + <Grid.RowDefinitions> + <RowDefinition Height="Auto" /> + <RowDefinition Height="Auto" /> + <RowDefinition Height="Auto" /> + <RowDefinition Height="1*" /> + </Grid.RowDefinitions> - <ContentControl Name="myColors" Grid.Row="0" ContentTemplate="{StaticResource myColorsBtn}" Content="{Binding}"/> + <ContentControl Name="myColors" Grid.Row="0" ContentTemplate="{StaticResource myColorsBtn}" Content="{Binding}"/> - <ContentControl Name="segmentContent" Grid.Row="1" ContentTemplate="{StaticResource brushColorPanel}" Content="{Binding}"/> + <ContentControl Name="segmentContent" Grid.Row="1" ContentTemplate="{StaticResource brushColorPanel}" Content="{Binding}"/> - <Grid Grid.Row="2" Margin="80 0 93 0"> + <Grid Grid.Row="2" Margin="80 0 93 0"> - <touch:TouchColorPickerHSBControl x:Name="HSBPicker" Visibility="Visible" ThumbHeight="30" ThumbHeightInside="28" ThumbColor="{StaticResource TangoPrimaryBackgroundColor}" + <touch:TouchColorPickerHSBControl x:Name="HSBPicker" Visibility="Visible" ThumbHeight="30" ThumbHeightInside="28" ThumbColor="{StaticResource TangoPrimaryBackgroundColor}" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="0 0 0 0" MinWidth="200" BorderBrush="{StaticResource TangoKeyboardKeyDarkTextBrush}" H="{Binding SelectedBrushStop.Hue, Mode=TwoWay}" S="{Binding SelectedBrushStop.Saturation, Mode=TwoWay}" B="{Binding SelectedBrushStop.Brightness, Mode=TwoWay}" /> - </Grid> - - <ContentControl Grid.Row="3" ContentTemplate="{StaticResource bottomPanel}" Content="{Binding}"/> </Grid> - </touch:TouchLoadingPanel> - <touch:TouchLoadingPanel x:Name="labPanel" Visibility="{Binding SelectedColorTab,Converter={StaticResource ColorTabToVisibilityConverter},ConverterParameter='CIELab'}"> - <Grid Margin="10"> - <Grid.RowDefinitions> - <RowDefinition Height="Auto" /> - <RowDefinition Height="Auto" /> - <RowDefinition Height="Auto" /> - <RowDefinition Height="1*" /> - </Grid.RowDefinitions> - <ContentControl Name="myLabColors" Grid.Row="0" ContentTemplate="{StaticResource myColorsBtn}" Content="{Binding}"/> + <ContentControl Grid.Row="3" ContentTemplate="{StaticResource bottomPanel}" Content="{Binding}"/> + </Grid> + + <Grid Visibility="{Binding SelectedColorTab,Converter={StaticResource ColorTabToVisibilityConverter},ConverterParameter='CIELab'}"> + <Grid.RowDefinitions> + <RowDefinition Height="Auto" /> + <RowDefinition Height="Auto" /> + <RowDefinition Height="Auto" /> + <RowDefinition Height="1*" /> + </Grid.RowDefinitions> - <ContentControl Name="segmentContentLab" Grid.Row="1" ContentTemplate="{StaticResource brushColorPanel}" Content="{Binding}"/> + <ContentControl Name="myLabColors" Grid.Row="0" ContentTemplate="{StaticResource myColorsBtn}" Content="{Binding}"/> - <Grid Grid.Row="2" Margin="80 0 93 0"> - <touch:TouchColorPickerLABControl x:Name="LABPicker" Visibility="Visible" + <ContentControl Name="segmentContentLab" Grid.Row="1" ContentTemplate="{StaticResource brushColorPanel}" Content="{Binding}"/> + + <Grid Grid.Row="2" Margin="80 0 93 0"> + <touch:TouchColorPickerLABControl x:Name="LABPicker" Visibility="Visible" ThumbHeight="30" ThumbHeightInside="28" ThumbColor="{StaticResource TangoPrimaryBackgroundColor}" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" @@ -249,54 +238,52 @@ L="{Binding SelectedBrushStop.L, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" A="{Binding SelectedBrushStop.A, Mode=TwoWay}" B="{ Binding SelectedBrushStop.B, Mode=TwoWay}" /> - </Grid> + </Grid> - <ContentControl Grid.Row="3" ContentTemplate="{StaticResource bottomPanel}" Content="{Binding}"/> + <ContentControl Grid.Row="3" ContentTemplate="{StaticResource bottomPanel}" Content="{Binding}"/> - </Grid> - </touch:TouchLoadingPanel> - <touch:TouchLoadingPanel x:Name="rgbPanel" Visibility="{Binding SelectedColorTab,Converter={StaticResource ColorTabToVisibilityConverter},ConverterParameter='RGB'}"> - <Grid Margin="10"> - <Grid.RowDefinitions> - <RowDefinition Height="Auto" /> - <RowDefinition Height="Auto" /> - <RowDefinition Height="Auto" /> - <RowDefinition Height="1*" /> - </Grid.RowDefinitions> + </Grid> + + <Grid Visibility="{Binding SelectedColorTab,Converter={StaticResource ColorTabToVisibilityConverter},ConverterParameter='RGB'}"> + <Grid.RowDefinitions> + <RowDefinition Height="Auto" /> + <RowDefinition Height="Auto" /> + <RowDefinition Height="Auto" /> + <RowDefinition Height="1*" /> + </Grid.RowDefinitions> - <ContentControl Name="myRGBColors" Grid.Row="0" ContentTemplate="{StaticResource myColorsBtn}" Content="{Binding}"/> + <ContentControl Name="myRGBColors" Grid.Row="0" ContentTemplate="{StaticResource myColorsBtn}" Content="{Binding}"/> - <ContentControl Name="segmentRGBContent" Grid.Row="1" ContentTemplate="{StaticResource brushColorPanel}" Content="{Binding}"/> + <ContentControl Name="segmentRGBContent" Grid.Row="1" ContentTemplate="{StaticResource brushColorPanel}" Content="{Binding}"/> - <Grid Grid.Row="2" Margin="80 0 93 0" > - <touch:TouchColorPickerRGBControl x:Name="RGBPicker" Visibility="Visible" ThumbHeight="30" ThumbHeightInside="28" ThumbColor="{StaticResource TangoPrimaryBackgroundColor}" + <Grid Grid.Row="2" Margin="80 0 93 0" > + <touch:TouchColorPickerRGBControl x:Name="RGBPicker" Visibility="Visible" ThumbHeight="30" ThumbHeightInside="28" ThumbColor="{StaticResource TangoPrimaryBackgroundColor}" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="0 0 0 0" MinWidth="200" BorderBrush="{StaticResource TangoKeyboardKeyDarkTextBrush}" R="{Binding SelectedBrushStop.Red, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" G="{Binding SelectedBrushStop.Green, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" B="{ Binding SelectedBrushStop.Blue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" /> - </Grid> - - <ContentControl Grid.Row="3" ContentTemplate="{StaticResource bottomPanel}" Content="{Binding}"/> - </Grid> - </touch:TouchLoadingPanel> - <touch:TouchLoadingPanel x:Name="CMYKPanel" Visibility="{Binding SelectedColorTab,Converter={StaticResource ColorTabToVisibilityConverter},ConverterParameter='CMYK'}"> - <Grid Margin="10"> - <Grid.RowDefinitions> - <RowDefinition Height="Auto" /> - <RowDefinition Height="Auto" /> - <RowDefinition Height="Auto" /> - <RowDefinition Height="1*" /> - </Grid.RowDefinitions> - <ContentControl Name="myCMYKColors" Grid.Row="0" ContentTemplate="{StaticResource myColorsBtn}" Content="{Binding}"/> + <ContentControl Grid.Row="3" ContentTemplate="{StaticResource bottomPanel}" Content="{Binding}"/> + + </Grid> - <ContentControl Name="segmentCMYKContent" Grid.Row="1" ContentTemplate="{StaticResource brushColorPanel}" Content="{Binding}"/> + <Grid Visibility="{Binding SelectedColorTab,Converter={StaticResource ColorTabToVisibilityConverter},ConverterParameter='Volume'}"> + <Grid.RowDefinitions> + <RowDefinition Height="Auto" /> + <RowDefinition Height="Auto" /> + <RowDefinition Height="Auto" /> + <RowDefinition Height="1*" /> + </Grid.RowDefinitions> - <Grid Grid.Row="2" Margin="80 0 93 0"> - <touch:TouchColorPickerCMYKControl x:Name="CMYKPicker" Visibility="Visible" ThumbHeight="30" ThumbHeightInside="28" + <ContentControl Name="myCMYKColors" Grid.Row="0" ContentTemplate="{StaticResource myColorsBtn}" Content="{Binding}"/> + + <ContentControl Name="segmentCMYKContent" Grid.Row="1" ContentTemplate="{StaticResource brushColorPanel}" Content="{Binding}"/> + + <Grid Grid.Row="2" Margin="80 0 93 0"> + <touch:TouchColorPickerCMYKControl x:Name="CMYKPicker" Visibility="Visible" ThumbHeight="30" ThumbHeightInside="28" ThumbColor="{StaticResource TangoPrimaryBackgroundColor}" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="0 0 0 0" @@ -308,13 +295,13 @@ MaxYellowValue="{Binding MaxYellowValue, UpdateSourceTrigger=PropertyChanged}" MaxKeyValue="{Binding MaxBlackValue, UpdateSourceTrigger=PropertyChanged}" /> - </Grid> - - <ContentControl Grid.Row="3" ContentTemplate="{StaticResource bottomPanel}" Content="{Binding}"/> </Grid> - </touch:TouchLoadingPanel> - <touch:TouchLoadingPanel Visibility="{Binding SelectedColorTab,Converter={StaticResource ColorTabToVisibilityConverter},ConverterParameter='Catalogs'}"> - </touch:TouchLoadingPanel> + + <ContentControl Grid.Row="3" ContentTemplate="{StaticResource bottomPanel}" Content="{Binding}"/> + </Grid> + + <Grid Visibility="{Binding SelectedColorTab,Converter={StaticResource ColorTabToVisibilityConverter},ConverterParameter='Catalog'}"> + </Grid> </Grid> </Grid> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/ColorSelectionToolView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionView.xaml.cs index dea4c2d61..550390f44 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/ColorSelectionToolView.xaml.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionView.xaml.cs @@ -12,41 +12,36 @@ using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; -using Tango.PPC.Jobs.Converters; using Tango.PPC.Jobs.ViewModels; -using Tango.Touch.Controls; -using static Tango.SharedUI.Controls.NavigationControl; -using static Tango.PPC.Jobs.ViewModels.ColorSelectionToolViewVM; -namespace Tango.PPC.Jobs.Views +namespace Tango.PPC.Jobs.Dialogs { /// <summary> - /// Interaction logic for ColorSelectionToolView.xaml + /// Interaction logic for ColorSelectionView.xaml /// </summary> - public partial class ColorSelectionToolView : UserControl + public partial class ColorSelectionView : UserControl { - private ColorSelectionToolViewVM _vm; - public ColorSelectionToolView() + private ColorSelectionViewVM _vm; + + public ColorSelectionView() { InitializeComponent(); - + Loaded += (_, __) => { - _vm = DataContext as ColorSelectionToolViewVM; + _vm = DataContext as ColorSelectionViewVM; }; - } - private void TouchNavigationLinks_SelectionChanged(object sender, SelectionChangedEventArgs e) { - + } private void TouchNavigationLinks_OnPreviewMouseDown(object sender, MouseButtonEventArgs e) { - if (_vm != null && _vm.SelectedBrushStop != null && true == _vm.SelectedBrushStop.IsCMYKLiquidVolumesOutOfRange) + if (_vm != null && _vm.SelectedBrushStop != null && true == _vm.SelectedBrushStop.IsLiquidVolumesOutOfRange) { var item = ItemsControl.ContainerFromElement(sender as ListBox, e.OriginalSource as DependencyObject) as ListBoxItem; if (item != null) @@ -55,7 +50,5 @@ namespace Tango.PPC.Jobs.Views } } } - - } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/ColorSelectionToolViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionViewVM.cs index aeb42f98b..83128a374 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/ColorSelectionToolViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionViewVM.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -12,33 +13,51 @@ using Tango.PPC.Common.Navigation; using Tango.PPC.Jobs.Models; using Tango.PPC.Jobs.NavigationObjects; using Tango.PPC.Jobs.ViewContracts; +using Tango.SharedUI; -namespace Tango.PPC.Jobs.ViewModels +namespace Tango.PPC.Jobs.Dialogs { - public class ColorSelectionToolViewVM : PPCViewModel<IJobView>, INavigationResultProvider<BrushStopModel, ColorSelectionNavigationObject> + public class ColorSelectionViewVM : DialogViewVM { public enum ColorTab { - HSB, - CIELab, - RGB, - CMYK, - Catalogs + [Description("HSB")] + HSB = 5, + [Description("CIELab")] + CIELab = 3, + [Description("RGB")] + RGB = 1, + [Description("CMYK")] + Volume = 0, + [Description("Catalog")] + Catalog = 2 } + public class DialogObject + { + public SegmentModel SelectedSegment { get; set; } + public BrushStopModel BrushStopForEdit { get; set; } + /// <summary> + /// True when first brush is open for editing + /// </summary> + public bool IsEditingMode { get; set; } + } + + private ActionTimer _volumeConversionTimer; private IColorConverter _converter; #region Properties - private bool _confirmed; private bool _isEditMode; public bool IsEditMode { get { return _isEditMode; } - set { _isEditMode = value; + set + { + _isEditMode = value; RaisePropertyChangedAuto(); } } @@ -52,24 +71,88 @@ namespace Tango.PPC.Jobs.ViewModels get { return _selectedColorTabIndex; } set { - _selectedColorTabIndex = value; - RaisePropertyChangedAuto(); - RaisePropertyChanged(nameof(SelectedColorTab)); - OnSelectedtabChanged(); + if(_selectedColorTabIndex != value) + { + _selectedColorTabIndex = value; + RaisePropertyChangedAuto(); + switch (_selectedColorTabIndex) + { + case 0: + { + SelectedColorTab = ColorTab.HSB; + break; + } + case 1: + { + SelectedColorTab = ColorTab.CIELab; + break; + } + case 2: + { + SelectedColorTab = ColorTab.RGB; + break; + } + case 3: + { + SelectedColorTab = ColorTab.Volume; + break; + } + case 4: + { + SelectedColorTab = ColorTab.Catalog; + break; + } + } + } } } + private ColorTab _selectedColorTab; /// <summary> /// Gets or sets the selected category. /// </summary> + /// public ColorTab SelectedColorTab { - get { return (ColorTab)SelectedColorTabIndex; } + get { + return _selectedColorTab; + } set { - if (SelectedColorTabIndex != value.ToInt32()) + if (_selectedColorTab != value) { - SelectedColorTabIndex = value.ToInt32(); + _selectedColorTab = value; + switch (SelectedColorTab) + { + case ColorTab.HSB: + { + SelectedColorTabIndex = 0; + break; + } + case ColorTab.CIELab: + { + SelectedColorTabIndex = 1; + break; + } + case ColorTab.RGB: + { + SelectedColorTabIndex = 2; + break; + } + case ColorTab.Volume: + { + SelectedColorTabIndex = 3; + break; + } + case ColorTab.Catalog: + { + SelectedColorTabIndex = 4; + break; + } + } + + OnSelectedtabChanged(); + RaisePropertyChangedAuto(); } } } @@ -79,7 +162,9 @@ namespace Tango.PPC.Jobs.ViewModels public int SegmentIndex { get { return _segmentIndex; } - set { _segmentIndex = value; + set + { + _segmentIndex = value; RaisePropertyChangedAuto(); } } @@ -92,9 +177,11 @@ namespace Tango.PPC.Jobs.ViewModels public BrushStopModel InitialBrushStop { get { return _initialBrushStop; } - set { + set + { _initialBrushStop = value; - RaisePropertyChangedAuto(); } + RaisePropertyChangedAuto(); + } } private BrushStopModel _selectedBrushStop; @@ -110,12 +197,12 @@ namespace Tango.PPC.Jobs.ViewModels RaisePropertyChangedAuto(); } } - + public double MaxCyanValue { get { - return GetMaxCMYKValueOrDefault( LiquidTypes.Cyan); + return GetMaxCMYKValueOrDefault(LiquidTypes.Cyan); } } @@ -143,73 +230,37 @@ namespace Tango.PPC.Jobs.ViewModels } } - #endregion + public DialogObject DialogEditObject { get; set; } - #region Command - /// <summary> - /// Gets or sets the OK command. - /// </summary> - public RelayCommand OKCommand { get; set; } #endregion - public ColorSelectionToolViewVM() + public ColorSelectionViewVM() { - OKCommand = new RelayCommand(Confirm); + SelectedColorTab = ColorTab.RGB; _volumeConversionTimer = new ActionTimer(TimeSpan.FromMilliseconds(50)); _converter = new DefaultColorConverter(); } - #region Navigation - /// Confirms this instance. - /// </summary> - private void Confirm() + public override void OnShow() { - _confirmed = true; - - NavigationManager.NavigateBack(); - } + base.OnShow(); - public BrushStopModel GetNavigationResult() - { - if (_confirmed) - { - return SelectedBrushStop; - } - else + SegmentIndex = DialogEditObject.SelectedSegment.SegmentIndex; + IsEditMode = DialogEditObject.IsEditingMode; + if (DialogEditObject.IsEditingMode) { - return null; - } - } - - public void OnNavigationObjectReceived(ColorSelectionNavigationObject obj) - { - SegmentIndex = obj.SelectedSegment.SegmentIndex; - IsEditMode = obj.IsEditingMode; - if (obj.IsEditingMode) - { - InitialBrushStop = obj.BrushStopForEdit; - // InitialBrushStop.ConvertColorToRGB(); - // InitialBrushStop.InitColor(); + InitialBrushStop = DialogEditObject.BrushStopForEdit; SelectedBrushStop = InitialBrushStop.Clone(); SelectedBrushStop.ColorSpace = InitialBrushStop.ColorSpace; - if(SelectedBrushStop.ColorSpace == BL.Enumerations.ColorSpaces.RGB) - SelectedColorTab = ColorTab.RGB; - else if (SelectedBrushStop.ColorSpace == BL.Enumerations.ColorSpaces.LAB) - SelectedColorTab = ColorTab.CIELab; - else if (SelectedBrushStop.ColorSpace == BL.Enumerations.ColorSpaces.CMYK) - SelectedColorTab = ColorTab.CMYK; - else if (SelectedBrushStop.ColorSpace == BL.Enumerations.ColorSpaces.Catalog) - SelectedColorTab = ColorTab.Catalogs; - else SelectedColorTab = ColorTab.HSB; + SelectedColorTab = (ColorTab)SelectedBrushStop.ColorSpace; } else { - SelectedBrushStop = obj.BrushStopForEdit; + SelectedBrushStop = DialogEditObject.BrushStopForEdit; SelectedColorTab = ColorTab.RGB; } - UpdateCMYKMaxValues(); - _confirmed = false; + UpdateVolumesMaxValues(); } private void OnSelectedtabChanged() @@ -241,20 +292,17 @@ namespace Tango.PPC.Jobs.ViewModels } return; } - case ColorTab.CMYK: + case ColorTab.Volume: { - if (SelectedBrushStop != null) { - SelectedBrushStop.ConvertColorToCMYK(); + SelectedBrushStop.ConvertColorToVolume(); } return; } } } - #endregion - #region Methods private double GetMaxCMYKValueOrDefault(LiquidTypes type) @@ -265,21 +313,28 @@ namespace Tango.PPC.Jobs.ViewModels if (liquidTypesRml != null) { //var test = liquidTypesRml.GetMaxCalibrationValue(); - + return liquidTypesRml.GetMaxCalibrationValue(); } - + } return 100; } - private void UpdateCMYKMaxValues() + private void UpdateVolumesMaxValues() { RaisePropertyChanged(nameof(MaxCyanValue)); RaisePropertyChanged(nameof(MaxMagentaValue)); RaisePropertyChanged(nameof(MaxYellowValue)); RaisePropertyChanged(nameof(MaxBlackValue)); } + + protected override void Accept() + { + base.Accept(); + } + #endregion + } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/JobCreationView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/JobCreationView.xaml index 250e3959d..69bbbdb05 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/JobCreationView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/JobCreationView.xaml @@ -9,7 +9,7 @@ xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" mc:Ignorable="d" - Background="{StaticResource TangoPrimaryBackgroundBrush}" d:DesignHeight="861" d:DesignWidth="662" Width="662" Height="861" d:DataContext="{d:DesignInstance Type=local:JobCreationViewVM, IsDesignTimeCreatable=False}"> + Background="{StaticResource TangoPrimaryBackgroundBrush}" d:DesignHeight="861" d:DesignWidth="662" Width="750" Height="1200" d:DataContext="{d:DesignInstance Type=local:JobCreationViewVM, IsDesignTimeCreatable=False}"> <UserControl.Resources> <converters:JobTypeToImageConverter x:Key="JobTypeToImageConverter" /> @@ -20,96 +20,85 @@ <Border CornerRadius="20" BorderThickness="0"> <Grid Margin="45 51 89 110"> <DockPanel> - <Grid DockPanel.Dock="Bottom"> - <touch:TouchButton HorizontalAlignment="Left" CornerRadius="25" Command="{Binding CloseCommand}" Style="{StaticResource TangoHollowButton}" Width="150" Height="50" VerticalAlignment="Bottom">CANCEL</touch:TouchButton> - <touch:TouchButton HorizontalAlignment="Right" CornerRadius="25" Command="{Binding OKCommand}" Width="180" Height="48" VerticalAlignment="Bottom" Background="{StaticResource TangoMidAccentBrush}" TextElement.Foreground="{StaticResource TangoLightForegroundBrush}" FontSize="{StaticResource TangoButtonFontSize}">OK</touch:TouchButton> - </Grid> + <Grid DockPanel.Dock="Bottom"> + <touch:TouchButton HorizontalAlignment="Left" CornerRadius="25" Command="{Binding CloseCommand}" Style="{StaticResource TangoHollowButton}" Width="200" Height="50" VerticalAlignment="Bottom">CANCEL</touch:TouchButton> + <touch:TouchButton HorizontalAlignment="Right" CornerRadius="25" Command="{Binding OKCommand}" Style="{StaticResource TangoHollowButton}" Width="200" Height="50" VerticalAlignment="Bottom">OK</touch:TouchButton> + <!--<touch:TouchButton HorizontalAlignment="Right" CornerRadius="25" Command="{Binding OKCommand}" Width="180" Height="48" VerticalAlignment="Bottom" Background="{StaticResource TangoMidAccentBrush}" TextElement.Foreground="{StaticResource TangoLightForegroundBrush}" FontSize="{StaticResource TangoButtonFontSize}">OK</touch:TouchButton>--> + </Grid> - <StackPanel DockPanel.Dock="Top" Orientation="Horizontal"> - <Image Source="../Images/JobView/job-details.png" Width="34" /> - <TextBlock HorizontalAlignment="Left" Margin="14 0 0 0" FontSize="{StaticResource TangoHeaderFontSize}">Job Details</TextBlock> - </StackPanel> - - <UniformGrid Rows="3" VerticalAlignment="Top" TextElement.FontWeight="Normal" Margin="0 80 0 0"> - <!--<touch:TouchStaticListBox Margin="20" VerticalAlignment="Center" Width="480" ItemsSource="{Binding SupportedJobTypes}" SelectedItem="{Binding SelectedJobType,Mode=TwoWay}"> - <touch:TouchStaticListBox.ItemsPanel> - <ItemsPanelTemplate> - <UniformGrid Rows="1" /> - </ItemsPanelTemplate> - </touch:TouchStaticListBox.ItemsPanel> - <touch:TouchStaticListBox.ItemContainerStyle> - <Style TargetType="touch:TouchStaticListBoxItem"> - <Setter Property="BorderBrush" Value="{StaticResource TangoPrimaryAccentBrush}"></Setter> - <Setter Property="BorderThickness" Value="0"></Setter> - <Setter Property="CornerRadius" Value="5"></Setter> - <Setter Property="Padding" Value="0 10"></Setter> - <Setter Property="Margin" Value="25"></Setter> - <Setter Property="Background" Value="Transparent"></Setter> - <Setter Property="Width" Value="110"></Setter> - <Style.Triggers> - <Trigger Property="IsSelected" Value="True"> - <Setter Property="BorderThickness" Value="2"></Setter> - </Trigger> - </Style.Triggers> - </Style> - </touch:TouchStaticListBox.ItemContainerStyle> - <touch:TouchStaticListBox.ItemTemplate> - <DataTemplate> - <StackPanel Orientation="Vertical" HorizontalAlignment="Center"> - <Image Stretch="Fill" Width="60" RenderOptions.BitmapScalingMode="Fant" Height="60" Source="{Binding Converter={StaticResource JobTypeToImageConverter}}"></Image> - <TextBlock HorizontalAlignment="Center" Margin="0 10 0 0" Text="{Binding Converter={StaticResource EnumToDescriptionConverter}}" ></TextBlock> - </StackPanel> - </DataTemplate> - </touch:TouchStaticListBox.ItemTemplate> - </touch:TouchStaticListBox>--> - <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0 50 0 0"> - <TextBlock HorizontalAlignment="Left" Margin="0 10 0 0" Text="Job Name" FontSize="{StaticResource TangoExpanderHeaderFontSize}" Width="125"/> - <Border Margin="49 0 0 0" BorderThickness="1" Width="353" Height="44" CornerRadius="22" BorderBrush="{StaticResource TangoMidAccentBrush}"> - <touch:TouchTextBox Margin="20 10 0 10" FontSize="{StaticResource TangoComboBoxItemFontSize}" Text="{Binding JobName}" IsEnabled="True" HorizontalAlignment="Left" MinWidth="250" VerticalAlignment="Center" ></touch:TouchTextBox> - </Border> - </StackPanel > - <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0 50 0 0"> - <TextBlock HorizontalAlignment="Left" Margin="0 10 0 0" Text="Thread Type" FontSize="{StaticResource TangoExpanderHeaderFontSize}" Width="125"/> - <Border Margin="49 0 0 0" BorderThickness="1" Width="353" Height="44" CornerRadius="22" BorderBrush="{StaticResource TangoMidAccentBrush}"> - <touch:TouchComboBox Margin="20 0 10 10" ItemsSource="{Binding Rmls}" SelectedItem="{Binding SelectedRML,Mode=TwoWay}"> - <touch:TouchComboBox.ItemTemplate> - <DataTemplate> - <TextBlock Margin="20 10 10 10" TextTrimming="CharacterEllipsis" FontSize="{StaticResource TangoExpanderItemFontSize}" Text="{Binding Name}"> - - </TextBlock> - </DataTemplate> - </touch:TouchComboBox.ItemTemplate> - <touch:TouchComboBox.SelectedItemTemplate> - <DataTemplate> - <TextBlock Margin="0 0 0 5" FontSize="{StaticResource TangoExpanderItemFontSize}" Text="{Binding Name}" VerticalAlignment="Center"></TextBlock> - </DataTemplate> - </touch:TouchComboBox.SelectedItemTemplate> - </touch:TouchComboBox> - </Border> + <Grid DockPanel.Dock="Top"> + <Grid.RowDefinitions> + <RowDefinition Height="Auto"/> + <RowDefinition Height="Auto"/> + <RowDefinition Height="Auto"/> + </Grid.RowDefinitions> + <StackPanel Orientation="Horizontal"> + <Image Source="../Images/JobView/job-details.png" Width="34" /> + <TextBlock HorizontalAlignment="Left" Margin="14 0 0 0" FontSize="{StaticResource TangoHeaderFontSize}">Job Details</TextBlock> </StackPanel> - <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0 50 0 0"> - <TextBlock HorizontalAlignment="Left" Margin="0 10 0 0" Text="Spool Type" FontSize="{StaticResource TangoExpanderHeaderFontSize}" Width="125"/> - <Border Margin="49 0 0 0" BorderThickness="1" Width="353" Height="44" CornerRadius="22" BorderBrush="{StaticResource TangoMidAccentBrush}"> - <touch:TouchComboBox Margin="20 0 10 10" ItemsSource="{Binding SpoolTypes}" SelectedItem="{Binding SelectedSpoolType,Mode=TwoWay}" FontSize="{StaticResource TangoExpanderItemFontSize}"> - - <touch:TouchComboBox.ItemTemplate> - <DataTemplate> - <TextBlock Margin="20 10 10 10" TextTrimming="CharacterEllipsis" FontSize="{StaticResource TangoExpanderItemFontSize}"> + + <UniformGrid Grid.Row="1" Rows="4" VerticalAlignment="Top" TextElement.FontWeight="Normal" Margin="0 80 57 0" HorizontalAlignment="Stretch"> + <DockPanel Margin="0 50 0 0" HorizontalAlignment="Stretch"> + <TextBlock HorizontalAlignment="Left" Margin="0 10 0 0" Text="Job Name" FontSize="{StaticResource TangoDialogFontSize}" Width="125"/> + <Border Margin="49 0 0 0" BorderThickness="1" Height="44" CornerRadius="22" BorderBrush="{StaticResource TangoMidAccentBrush}"> + <touch:TouchTextBox Margin="20 10 0 10" FontSize="{StaticResource TangoComboBoxItemFontSize}" Text="{Binding JobName}" IsEnabled="True" HorizontalAlignment="Left" MinWidth="250" VerticalAlignment="Center" ></touch:TouchTextBox> + </Border> + </DockPanel > + <DockPanel HorizontalAlignment="Stretch" Margin="0 50 0 0"> + <TextBlock HorizontalAlignment="Left" Margin="0 10 0 0" Text="Thread Type" FontSize="{StaticResource TangoDialogFontSize}" Width="125"/> + <Border Margin="49 0 0 0" BorderThickness="1" Height="44" CornerRadius="22" BorderBrush="{StaticResource TangoMidAccentBrush}"> + <touch:TouchComboBox Margin="20 0 10 10" ItemsSource="{Binding Rmls}" SelectedItem="{Binding SelectedRML,Mode=TwoWay}"> + <touch:TouchComboBox.ItemTemplate> + <DataTemplate> + <TextBlock Margin="20 10 10 10" TextTrimming="CharacterEllipsis" FontSize="{StaticResource TangoDialogFontSize}" Text="{Binding Name}"> + + </TextBlock> + </DataTemplate> + </touch:TouchComboBox.ItemTemplate> + <touch:TouchComboBox.SelectedItemTemplate> + <DataTemplate> + <TextBlock Margin="0 0 0 5" FontSize="{StaticResource TangoDialogFontSize}" Text="{Binding Name}" VerticalAlignment="Center"></TextBlock> + </DataTemplate> + </touch:TouchComboBox.SelectedItemTemplate> + </touch:TouchComboBox> + </Border> + </DockPanel> + <DockPanel HorizontalAlignment="Stretch" Margin="0 50 0 0"> + <TextBlock HorizontalAlignment="Left" Margin="0 10 0 0" Text="Spool Type" FontSize="{StaticResource TangoDialogFontSize}" Width="125"/> + <Border Margin="49 0 0 0" BorderThickness="1" HorizontalAlignment="Stretch" Height="44" CornerRadius="22" BorderBrush="{StaticResource TangoMidAccentBrush}"> + <touch:TouchComboBox Margin="20 0 10 10" ItemsSource="{Binding SpoolTypes}" SelectedItem="{Binding SelectedSpoolType,Mode=TwoWay}" FontSize="{StaticResource TangoDialogFontSize}"> + + <touch:TouchComboBox.ItemTemplate> + <DataTemplate> + <TextBlock Margin="20 10 10 10" TextTrimming="CharacterEllipsis" FontSize="{StaticResource TangoDialogFontSize}"> <Run Text="{Binding Name}"></Run> <Run Foreground="{StaticResource TangoDarkForegroundBrush}" Text="{Binding Length,Mode=OneWay}"></Run> <Run Foreground="{StaticResource TangoDarkForegroundBrush}" Text="m"></Run> - </TextBlock> - </DataTemplate> - </touch:TouchComboBox.ItemTemplate> - <touch:TouchComboBox.SelectedItemTemplate> - <DataTemplate> - <TextBlock Margin="0 0 0 5" FontSize="{StaticResource TangoExpanderItemFontSize}" Text="{Binding Name}"></TextBlock> - </DataTemplate> - </touch:TouchComboBox.SelectedItemTemplate> - </touch:TouchComboBox> - </Border> - </StackPanel> - </UniformGrid> + </TextBlock> + </DataTemplate> + </touch:TouchComboBox.ItemTemplate> + <touch:TouchComboBox.SelectedItemTemplate> + <DataTemplate> + <TextBlock Margin="0 0 0 5" FontSize="{StaticResource TangoDialogFontSize}" Text="{Binding Name}"></TextBlock> + </DataTemplate> + </touch:TouchComboBox.SelectedItemTemplate> + </touch:TouchComboBox> + </Border> + </DockPanel> + <DockPanel Margin="0 50 0 0" HorizontalAlignment="Stretch"> + <TextBlock HorizontalAlignment="Left" Margin="0 10 0 0" Text="White Gap" FontSize="{StaticResource TangoDialogFontSize}" Width="125"/> + <Border Margin="49 0 0 0" BorderThickness="1" Height="44" CornerRadius="22" BorderBrush="{StaticResource TangoMidAccentBrush}"> + <touch:TouchNumericTextBox Margin="20 0 0 10" FontSize="{StaticResource TangoComboBoxItemFontSize}" Value="{Binding WhiteGap, Mode=TwoWay}" IsEnabled="True" HorizontalAlignment="Left" MinWidth="250" VerticalAlignment="Center" ></touch:TouchNumericTextBox> + </Border> + </DockPanel > + </UniformGrid> + + <Grid Grid.Row="2" Margin="0 70 57 0" HorizontalAlignment="Stretch" > + <TextBlock HorizontalAlignment="Left" Margin="0 10 0 0" Text="Duplicate Job As New" FontWeight="Normal" FontSize="{StaticResource TangoDialogFontSize}" Width="Auto"/> + <touch:TouchButton CornerRadius="25" Command="{Binding DuplicateCommand}" Width="180" Height="48" VerticalAlignment="Center" HorizontalAlignment="Right" Background="{StaticResource TangoPrimaryAccentBrush}" TextElement.Foreground="{StaticResource TangoLightForegroundBrush}" FontSize="{StaticResource TangoButtonFontSize}">Duplicate</touch:TouchButton> + + </Grid> + </Grid> </DockPanel> </Grid> </Border> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/JobCreationViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/JobCreationViewVM.cs index f571cd519..66be7bd04 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/JobCreationViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/JobCreationViewVM.cs @@ -5,6 +5,7 @@ using System.Text; using System.Threading.Tasks; using Tango.BL.Entities; using Tango.BL.Enumerations; +using Tango.Core.Commands; using Tango.SharedUI; namespace Tango.PPC.Jobs.Dialogs @@ -67,17 +68,51 @@ namespace Tango.PPC.Jobs.Dialogs set { _selectedSpoolType = value; RaisePropertyChangedAuto(); } } - + + private double _whiteGap; + + public double WhiteGap + { + get { return _whiteGap; } + set { _whiteGap = value; + RaisePropertyChangedAuto(); + } + } + + + private bool _showDuplicate; + + public bool ShowDuplicate + { + get { return _showDuplicate; } + set { _showDuplicate = value; + RaisePropertyChangedAuto(); + + } + } + + public bool IsDuplicate { get; set; } + public RelayCommand DuplicateCommand { get; set; } /// <summary> /// Initializes a new instance of the <see cref="JobCreationViewVM"/> class. /// </summary> /// <param name="supportedJobTypes">The supported job types.</param> /// <param name="supportedColorSpaces">The supported color spaces</param> - public JobCreationViewVM(List<SpoolType> spoolTypes, List<Rml> rmls) : base() + public JobCreationViewVM(List<SpoolType> spoolTypes, List<Rml> rmls, double whitegap, bool showDuplicate) : base() { JobName = "Unnamed"; SpoolTypes = spoolTypes; - Rmls = rmls.OrderBy(x => x.Name).ToList(); + Rmls = rmls.OrderBy(x => x.Name).ToList(); + DuplicateCommand = new RelayCommand(Duplicate); + IsDuplicate = false; + ShowDuplicate = showDuplicate; + WhiteGap = whitegap; + } + + private void Duplicate(object obj) + { + IsDuplicate = true; + Accept(); } protected override bool CanOK() diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/RepeatJobView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/RepeatJobView.xaml new file mode 100644 index 000000000..90c5b8b9f --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/RepeatJobView.xaml @@ -0,0 +1,32 @@ +<UserControl x:Class="Tango.PPC.Jobs.Dialogs.RepeatJobView" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + 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:local="clr-namespace:Tango.PPC.Jobs.Dialogs" + mc:Ignorable="d" + Background="Transparent" d:DesignHeight="630" d:DesignWidth="560" MinWidth="380" Height="280" + d:DataContext="{d:DesignInstance Type=local:RepeatJobViewVM, IsDesignTimeCreatable=False}"> + <Border BorderBrush="{StaticResource TangoMidAccentBrush}" Margin="-24" CornerRadius="40" BorderThickness="2" Background="{StaticResource TangoPrimaryBackgroundBrush}"> + + <Grid> + + <DockPanel Height="33" VerticalAlignment="Top" Margin="44 39 40 0" Grid.Row="0"> + <TextBlock DockPanel.Dock="Left" FontSize="{StaticResource TangoMessageBoxButtonFontSize}" FontWeight="SemiBold" > Copy Job Summary</TextBlock> + <touch:TouchIconButton DockPanel.Dock="Right" VerticalAlignment="Center" Height="22" Command="{Binding CloseCommand}" Icon="Close" RippleBrush="{StaticResource TangoRippleDarkBrush}" Foreground="{StaticResource TangoDarkForegroundBrush}" HorizontalAlignment="Right" /> + </DockPanel> + + <Grid Margin="44 0 0 0" Grid.Row="1" Width="302" VerticalAlignment="Center" HorizontalAlignment="Left"> + <StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch" VerticalAlignment="Top"> + <TextBlock HorizontalAlignment="Left" DockPanel.Dock="Left" FontSize="{StaticResource TangoButtonFontSize}" >Repeat:</TextBlock> + <touch:TouchNumericUpDownConrol Margin="30 0 30 0" Width="Auto" Value="{Binding Repeats, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Center" BorderThickness="0" MaxValue="{Binding MaxRepeations, Mode=OneWay}" MinValue="1" Style="{StaticResource TouchNumericMiddleUpDownControl}"/> + <TextBlock HorizontalAlignment="Right" FontSize="{StaticResource TangoButtonFontSize}">Units</TextBlock> + </StackPanel> + <Rectangle Margin="0 30 0 0" Width="382" Stroke="{StaticResource TangoDividerBrush}" Height="3" VerticalAlignment="Bottom"/> + + </Grid> + <touch:TouchButton Margin="0 0 0 60 " Command="{Binding OKCommand}" FontSize="{StaticResource TangoButtonFontSize}" Style="{StaticResource TangoFlatButton}" Width="100" Height="50" VerticalAlignment="Bottom">OK</touch:TouchButton> + </Grid> + </Border> +</UserControl> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/RepeatJobView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/RepeatJobView.xaml.cs new file mode 100644 index 000000000..dff1ced26 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/RepeatJobView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.PPC.Jobs.Dialogs +{ + /// <summary> + /// Interaction logic for RepeatJob.xaml + /// </summary> + public partial class RepeatJobView : UserControl + { + public RepeatJobView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/RepeatJobViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/RepeatJobViewVM.cs new file mode 100644 index 000000000..4cf5d8c95 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/RepeatJobViewVM.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.SharedUI; + +namespace Tango.PPC.Jobs.Dialogs +{ + public class RepeatJobViewVM : DialogViewVM + { + private int _repeats; + + public int Repeats + { + get { return _repeats; } + set { _repeats = value; + RaisePropertyChangedAuto(); + } + } + + private int _maxrepeations; + + public int MaxRepeations + { + get { + return _maxrepeations; } + set { _maxrepeations = value; + RaisePropertyChangedAuto(); + } + } + + + public RepeatJobViewVM() + { + Repeats = 1; + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/job_details.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/job_details.png Binary files differindex 1ccee4475..fa5a1f81f 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/job_details.png +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/job_details.png diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/BrushStopModel.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/BrushStopModel.cs index 78ce8f1a7..3447cec8e 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/BrushStopModel.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/BrushStopModel.cs @@ -13,11 +13,21 @@ using Tango.ColorConversion; using System.Reflection; using Tango.BL.Dispensing; using Tango.BL; +using Tango.Core.ExtensionMethods; namespace Tango.PPC.Jobs.Models { public class BrushStopModel : ViewModel { + public enum PositionStatus + { + First = 1, + FirstColor = 2, + Middle = 3, + SecondColor = 4, + Last = 5 + } + private ActionTimer _volumeConversionTimer; private IColorConverter _converter; public const double MAX_INK_UPTAKE = 400; @@ -45,7 +55,7 @@ namespace Tango.PPC.Jobs.Models { _cyan = value; RaisePropertyChangedAuto(); - OnCMYKChanged(); + OnVolumeChanged(); } } } @@ -69,7 +79,7 @@ namespace Tango.PPC.Jobs.Models { _magenta = value; RaisePropertyChangedAuto(); - OnCMYKChanged(); + OnVolumeChanged(); } } } @@ -93,7 +103,7 @@ namespace Tango.PPC.Jobs.Models { _yellow = value; RaisePropertyChangedAuto(); - OnCMYKChanged(); + OnVolumeChanged(); } } } @@ -116,7 +126,7 @@ namespace Tango.PPC.Jobs.Models { _black = value; RaisePropertyChangedAuto(); - OnCMYKChanged(); + OnVolumeChanged(); } } } @@ -306,29 +316,6 @@ namespace Tango.PPC.Jobs.Models } } - - protected Boolean _istransparent; - - /// <summary> - /// Gets or sets the BrushStopModel is transparent. - /// </summary> - public Boolean IsTransparent - { - get - { - return _istransparent; - } - set - { - if (_istransparent != value) - { - _istransparent = value; - RaisePropertyChangedAuto(); - - } - } - } - protected Double _offsetpercent; /// <summary> @@ -399,37 +386,14 @@ namespace Tango.PPC.Jobs.Models } } - private bool _isFirst; - - public bool IsFirst - { - get { return _isFirst; } - set { _isFirst = value; } - } - private bool _isLast; - - public bool IsLast - { - get { return _isLast; } - set { _isLast = value; } - } - - private bool _isFirstColorBrush; - - public bool IsFirstColorBrush - { - get { return _isFirstColorBrush; } - set { _isFirstColorBrush = value; } - } - - private bool _isSecondColorBrush; + private PositionStatus _position; - public bool IsSecondColorBrush + public PositionStatus Position { - get { return _isSecondColorBrush; } - set { _isSecondColorBrush = value; } + get { return _position; } + set { _position = value; } } - + protected ColorSpaces _colorspace; public virtual ColorSpaces ColorSpace @@ -514,24 +478,7 @@ namespace Tango.PPC.Jobs.Models get { return _segmentmodel; } set { _segmentmodel = value; } } - - private BrushStop _dummyBrushStop; - - public BrushStop DummyBrushStop - { - get { return _dummyBrushStop; } - set { _dummyBrushStop = value; } - } - - private bool _isMiddle; - - public bool IsMiddle - { - get { return _isMiddle; } - set { _isMiddle = value; - RaisePropertyChangedAuto(); - } - } + private bool _outOfGamutChecked; /// <summary> @@ -556,11 +503,6 @@ namespace Tango.PPC.Jobs.Models { _isOutOfGamut = value; RaisePropertyChangedAuto(); - - //if (SegmentModel != null) - //{ - // Segment.RaiseHasOutOfGamutBrushStop(); - //} } } } @@ -576,7 +518,8 @@ namespace Tango.PPC.Jobs.Models _b = 0; _red = _green = _blue = 255; _cyan = _magenta = _yellow = _black = 0; - IsMiddle = IsFirstColorBrush = IsSecondColorBrush = false; + StopIndex = 1; + Position = PositionStatus.FirstColor; SegmentModel = segmentModel; IsOutOfGamut = false; _volumeConversionTimer = new ActionTimer(TimeSpan.FromMilliseconds(50)); @@ -686,17 +629,33 @@ namespace Tango.PPC.Jobs.Models public BrushStopModel Clone() { - var cloned = (BrushStopModel)Activator.CreateInstance(typeof(BrushStopModel), SegmentModel); + var cloned = new BrushStopModel(SegmentModel); + cloned.StopIndex = StopIndex; cloned.PreventPropertyUpdate = true; + cloned.Red = Red; + cloned.Green = Green; + cloned.Blue = Blue; + cloned.L = L; + cloned.A = A; + cloned.B = B; + cloned.Cyan = Cyan; + cloned.Magenta = Magenta; + cloned.Yellow = Yellow; + cloned.Black = Black; + cloned.Hue = Hue; + cloned.Saturation = Saturation; + cloned.Brightness = Brightness; + cloned.Color = Color; - foreach (var prop in typeof(BrushStopModel).GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(x => x.SetMethod != null)) - { - if (!prop.PropertyType.IsGenericTypeAndNotNullable()) - { - prop.SetValue(cloned, prop.GetValue(this)); - } - } - cloned.SegmentModel = SegmentModel; + cloned.ColorCatalogsItem = ColorCatalogsItem; + cloned.ColorSpace = ColorSpace; + cloned.DisplayedColor = DisplayedColor; + cloned.OffsetMeters = OffsetMeters; + cloned.OffsetPercent = OffsetPercent; + cloned.Position = Position; + cloned.IsOutOfGamut = IsOutOfGamut; + cloned.OutOfGamutChecked = OutOfGamutChecked; + //this.MapPropertiesTo(cloned, MappingFlags.NoReferenceTypes); cloned.PreventPropertyUpdate = false; return cloned; } @@ -719,12 +678,12 @@ namespace Tango.PPC.Jobs.Models #region changes - private void OnCMYKChanged() + private void OnVolumeChanged() { if (PreventPropertyUpdate) return; - ColorSpace = ColorSpaces.CMYK; - RaisePropertyChanged(nameof(IsCMYKLiquidVolumesOutOfRange)); + ColorSpace = ColorSpaces.Volume; + RaisePropertyChanged(nameof(IsLiquidVolumesOutOfRange)); OnBrushStopFieldValueChanged(); } @@ -796,7 +755,7 @@ namespace Tango.PPC.Jobs.Models { Hsb hsb = null; - if (ColorSpace == ColorSpaces.CMYK) + if (ColorSpace == ColorSpaces.Volume) { BrushStop stop = CreateBrushStop(ColorSpaces.Volume); try @@ -806,7 +765,7 @@ namespace Tango.PPC.Jobs.Models _red = output.SingleCoordinates.Red; _green = output.SingleCoordinates.Green; _blue = output.SingleCoordinates.Blue; - IsOutOfGamut = _converter.IsOutOfGamut(stop, SegmentModel.Job.Machine.Configuration, SegmentModel.Job.Rml); + IsOutOfGamut = output.OutOfGamut; } catch (Exception ex) { @@ -845,7 +804,7 @@ namespace Tango.PPC.Jobs.Models { if (ColorSpace != ColorSpaces.RGB) { - if (ColorSpace == ColorSpaces.CMYK) + if (ColorSpace == ColorSpaces.Volume) { BrushStop stop = CreateBrushStop(ColorSpaces.Volume); try @@ -855,7 +814,7 @@ namespace Tango.PPC.Jobs.Models _red = output.SingleCoordinates.Red; _green = output.SingleCoordinates.Green; _blue = output.SingleCoordinates.Blue; - IsOutOfGamut = _converter.IsOutOfGamut(stop, SegmentModel.Job.Machine.Configuration, SegmentModel.Job.Rml); + IsOutOfGamut = output.OutOfGamut; } catch (Exception ex) { @@ -885,7 +844,7 @@ namespace Tango.PPC.Jobs.Models if (ColorSpace != ColorSpaces.LAB) { Lab lab = null; - if (ColorSpace == ColorSpaces.CMYK) + if (ColorSpace == ColorSpaces.Volume) { BrushStop stop = CreateBrushStop(ColorSpaces.Volume); try @@ -895,11 +854,11 @@ namespace Tango.PPC.Jobs.Models _l = output.SingleCoordinates.L; _a = output.SingleCoordinates.A; _b = output.SingleCoordinates.B; - IsOutOfGamut = _converter.IsOutOfGamut(stop, SegmentModel.Job.Machine.Configuration, SegmentModel.Job.Rml); + IsOutOfGamut = output.OutOfGamut; } catch (Exception ex) { - LogManager.Log(ex, "An error occurred while trying to get volume => RGB from conversion engine."); + LogManager.Log(ex, "An error occurred while trying to convert volume to LAB."); } finally { @@ -929,9 +888,9 @@ namespace Tango.PPC.Jobs.Models } } - public void ConvertColorToCMYK() + public void ConvertColorToVolume() { - if (ColorSpace != ColorSpaces.CMYK) + if (ColorSpace != ColorSpaces.Volume) { ColorSpaces colorSpace = ColorSpace; if (ColorSpace == ColorSpaces.HSB) @@ -944,16 +903,16 @@ namespace Tango.PPC.Jobs.Models IsBusy = true; var output = _converter.Convert(stop, SegmentModel.Job.Machine.Configuration, SegmentModel.Job.Rml, false, false, false); - _cyan = output.SingleCoordinates.OutputLiquids.SingleOrDefault(x => x.LiquidType == PMR.ColorLab.LiquidType.Cyan).Volume; - _yellow = output.SingleCoordinates.OutputLiquids.SingleOrDefault(x => x.LiquidType == PMR.ColorLab.LiquidType.Yellow).Volume; - _magenta = output.SingleCoordinates.OutputLiquids.SingleOrDefault(x => x.LiquidType == PMR.ColorLab.LiquidType.Magenta).Volume; - _black = output.SingleCoordinates.OutputLiquids.SingleOrDefault(x => x.LiquidType == PMR.ColorLab.LiquidType.Magenta).Volume; + _cyan = (output.SingleCoordinates.OutputLiquids.SingleOrDefault(x => x.LiquidType == PMR.ColorLab.LiquidType.Cyan).Volume) ; + _yellow = (output.SingleCoordinates.OutputLiquids.SingleOrDefault(x => x.LiquidType == PMR.ColorLab.LiquidType.Yellow).Volume); + _magenta = (output.SingleCoordinates.OutputLiquids.SingleOrDefault(x => x.LiquidType == PMR.ColorLab.LiquidType.Magenta).Volume); + _black = (output.SingleCoordinates.OutputLiquids.SingleOrDefault(x => x.LiquidType == PMR.ColorLab.LiquidType.Black).Volume); IsOutOfGamut = false; RaisePropertyChanged(nameof(Cyan)); RaisePropertyChanged(nameof(Yellow)); RaisePropertyChanged(nameof(Magenta)); RaisePropertyChanged(nameof(Black)); - RaisePropertyChanged(nameof(IsCMYKLiquidVolumesOutOfRange)); + RaisePropertyChanged(nameof(IsLiquidVolumesOutOfRange)); } catch (Exception ex) { @@ -1010,11 +969,11 @@ namespace Tango.PPC.Jobs.Models } return 0.0; } - public bool IsCMYKLiquidVolumesOutOfRange + public bool IsLiquidVolumesOutOfRange { get { - if (ColorSpace == BL.Enumerations.ColorSpaces.CMYK) + if (ColorSpace == BL.Enumerations.ColorSpaces.Volume) { var sum = GetColorNLPerCm(Cyan, LiquidTypes.Cyan) + GetColorNLPerCm(Magenta, LiquidTypes.Magenta) + GetColorNLPerCm(Yellow, LiquidTypes.Yellow) + GetColorNLPerCm(Black, LiquidTypes.Black); var maxLiq = GetTotalMaximumLiquidNlPerCMLimit(); @@ -1036,23 +995,16 @@ namespace Tango.PPC.Jobs.Models try { ColorSpaces colorSpace = ColorSpace; - if(ColorSpace == ColorSpaces.HSB) - { - colorSpace = ColorSpaces.RGB; - } - if (ColorSpace == ColorSpaces.CMYK) - { - colorSpace = ColorSpaces.Volume; - } + BrushStop stop = CreateBrushStop(colorSpace); Configuration configuration = SegmentModel.Job.Machine.Configuration; Rml rml = SegmentModel.Job.Rml; - RaisePropertyChanged(nameof(IsCMYKLiquidVolumesOutOfRange)); - if ( ColorSpace == BL.Enumerations.ColorSpaces.CMYK) + RaisePropertyChanged(nameof(IsLiquidVolumesOutOfRange)); + if ( ColorSpace == BL.Enumerations.ColorSpaces.Volume) { - if(IsCMYKLiquidVolumesOutOfRange) + if(IsLiquidVolumesOutOfRange) { IsBusy = false; return; @@ -1079,14 +1031,27 @@ namespace Tango.PPC.Jobs.Models Rgb rgb = new Rgb(lab.ToRgb()); DisplayedColor = Color.FromRgb((byte)rgb.R, (byte)rgb.G, (byte)rgb.B); //TODO ASK ROY - // DisplayedColor = Color.FromRgb((byte)output.SingleCoordinates.Red, (byte)output.SingleCoordinates.Green, (byte)output.SingleCoordinates.Blue); + //foreach (var outputLiquid in output.SingleCoordinates.OutputLiquids) + //{ + // var liquidVolume = stop.LiquidVolumes.SingleOrDefault(x => x.IdsPack.LiquidType.Code == outputLiquid.LiquidType.ToInt32()); + + // if (liquidVolume == null) + // { + // throw new NullReferenceException("Liquid volume not found for color conversion output liquid '" + outputLiquid.LiquidType + "'."); + // } + // liquidVolume.Volume = outputLiquid.Volume; + //} } else if (stop.BrushColorSpace == BL.Enumerations.ColorSpaces.RGB) { IsOutOfGamut = _converter.IsOutOfGamut(stop, configuration, rml); DisplayedColor = Color.FromRgb((byte)output.SingleCoordinates.Red, (byte)output.SingleCoordinates.Green, (byte)output.SingleCoordinates.Blue); - + } + else if (stop.BrushColorSpace == BL.Enumerations.ColorSpaces.HSB) + { + IsOutOfGamut = _converter.IsOutOfGamut(stop, configuration, rml); + DisplayedColor = Color.FromRgb((byte)output.SingleCoordinates.Red, (byte)output.SingleCoordinates.Green, (byte)output.SingleCoordinates.Blue); } } catch (Exception ex) diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/JobModel.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/JobModel.cs index 349b9049b..3bb6188d9 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/JobModel.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/JobModel.cs @@ -118,6 +118,7 @@ namespace Tango.PPC.Jobs.Models { _numberofunits = value; RaisePropertyChangedAuto(); + RaisePropertyChanged(nameof(LengthIncludingNumberOfUnits)); } } @@ -489,6 +490,11 @@ namespace Tango.PPC.Jobs.Models { RaisePropertyChanged(nameof(EffectiveSegments)); } + else if(e.PropertyName == nameof(SegmentModel.EnableInterSegment)) + { + OnLengthChanged(); + RaisePropertyChanged(nameof(EffectiveSegments)); + } else if(e.PropertyName == nameof(SegmentModel.IsSelected)) { if (_preventChange) return; @@ -532,6 +538,7 @@ namespace Tango.PPC.Jobs.Models public void CopySegments() { + SegmentsToCopy.Clear(); if (false == Segments.ToList().Any(x => x.IsSelected)) return; LogManager.Log("Copy selected segments."); @@ -552,14 +559,20 @@ namespace Tango.PPC.Jobs.Models } SegmentsToCopy.ForEach(x => x.RaiseSegmentBrushChanged()); - var selected = Segments.ToList().FindIndex(x => x.IsSelected); - if(selected != -1) + var selectedIndex = Segments.ToList().FindIndex(x => x.IsSelected); + if(selectedIndex == -1 || selectedIndex == (Segments.Count) - 1) { - Segments.ToList().InsertRange(selected, SegmentsToCopy); + foreach ( var newSegmentModel in SegmentsToCopy) + { + Segments.Add(newSegmentModel); + } } else { - Segments.ToList().AddRange(SegmentsToCopy); + foreach (var newSegmentModel in SegmentsToCopy) + { + Segments.Insert(selectedIndex++, newSegmentModel); + } } SegmentsToCopy.Clear(); } @@ -573,6 +586,17 @@ namespace Tango.PPC.Jobs.Models Segments.Where(i => i.IsSelected).ToList().ForEach(y => y.EnableInterSegment = true); } + public void SwapSegments(int index1, int index2) + { + if (index1 < 0 || index1 >= Segments.Count) + return; + if (index2 < 0 || index2 >= Segments.Count) + return; + var tmpIndex = Segments[index2].SegmentIndex; + Segments[index2].SegmentIndex = Segments[index1].SegmentIndex; + Segments[index1].SegmentIndex = tmpIndex; + } + #endregion } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/SegmentModel.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/SegmentModel.cs index c7edecd41..a03c56a46 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/SegmentModel.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/SegmentModel.cs @@ -24,9 +24,10 @@ namespace Tango.PPC.Jobs.Models private ActionTimer _brushStopCollectionChangedActionTimer; #region Properties - - protected String _name; + public string GUID { get; set; } + + protected String _name; /// <summary> /// Gets or sets the SegmentModel name. /// </summary> @@ -108,7 +109,6 @@ namespace Tango.PPC.Jobs.Models _enableintersegment = value; RaisePropertyChangedAuto(); RaisePropertyChanged(nameof(LengthWithInterSegment)); - Job.OnLengthChanged(); } } } @@ -178,54 +178,51 @@ namespace Tango.PPC.Jobs.Models } public bool IsOffsetChanged { get; set; } - - private double _leftOffset; - + public double LeftOffset { - get { return _leftOffset; } - set { _leftOffset = value; - RaisePropertyChangedAuto(); - if (FirstBrushStop != null) + get { return FirstBrushStop != null? FirstBrushStop.OffsetPercent : 0; } + set { + + if (FirstBrushStop != null && FirstBrushStop.OffsetPercent != value) { - FirstBrushStop.OffsetPercent = _leftOffset/2; + FirstBrushStop.OffsetPercent = value; + RaisePropertyChangedAuto(); IsOffsetChanged = true; - RaiseSegmentBrushChanged(); + RaisePropertyChanged(nameof(SegmentBrush)); IsOffsetChanged = false; } } } - private double _middleOffset; - + public double MiddleOffset { - get { return _middleOffset; } - set { _middleOffset = value; - RaisePropertyChangedAuto(); - if (MiddleBrushStop != null) + get { return (MiddleBrushStop != null) ? MiddleBrushStop.OffsetPercent : 0; } + set { + + if (MiddleBrushStop != null && MiddleBrushStop.OffsetPercent != value) { - MiddleBrushStop.OffsetPercent = _middleOffset; - + MiddleBrushStop.OffsetPercent = value; + RaisePropertyChangedAuto(); IsOffsetChanged = true; - RaiseSegmentBrushChanged(); + RaisePropertyChanged(nameof(SegmentBrush)); IsOffsetChanged = false; } } } - - private double _rightOffset; - + public double RightOffset { - get { return _rightOffset; } - set { _rightOffset = value; - RaisePropertyChangedAuto(); - if (SecondBrushStop != null) + get { return SecondBrushStop != null ? SecondBrushStop.OffsetPercent: 0; } + set { + + if (SecondBrushStop != null && SecondBrushStop.OffsetPercent != value) { - SecondBrushStop.OffsetPercent = _rightOffset; + SecondBrushStop.OffsetPercent = value; + RaisePropertyChangedAuto(); IsOffsetChanged = true; - RaiseSegmentBrushChanged(); + RaisePropertyChanged(nameof(SegmentBrush)); IsOffsetChanged = false; } } @@ -255,7 +252,7 @@ namespace Tango.PPC.Jobs.Models get { if (BrushStops.Count > 1) - return BrushStops.Where(x => x.IsSecondColorBrush).FirstOrDefault(); + return BrushStops.Where(x => x.Position == BrushStopModel.PositionStatus.SecondColor).FirstOrDefault(); return null; } @@ -268,11 +265,12 @@ namespace Tango.PPC.Jobs.Models { get { - if (BrushStops.Count == 1) - return BrushStops[0]; - if (BrushStops.Count > 1) - return BrushStops.Where(x => x.IsFirstColorBrush).FirstOrDefault(); - + if(BrushStops.Count > 0) + { + var brushStop = BrushStops.Where(x => x.Position == BrushStopModel.PositionStatus.FirstColor).FirstOrDefault(); + return brushStop; + } + return null; } @@ -286,7 +284,7 @@ namespace Tango.PPC.Jobs.Models get { if (BrushStops.Count > 1) - return BrushStops.Where(x => x.IsMiddle).FirstOrDefault(); + return BrushStops.Where(x => x.Position == BrushStopModel.PositionStatus.Middle).FirstOrDefault(); return null; } @@ -321,14 +319,16 @@ namespace Tango.PPC.Jobs.Models public RelayCommand DeleteGapCommand { get; set; } #endregion - public SegmentModel(JobModel jobModel) + public SegmentModel(JobModel jobModel, string guid) { InitnewSegment(); Job = jobModel; + GUID = guid; } public SegmentModel() { + GUID = ""; InitnewSegment(); } @@ -356,14 +356,12 @@ namespace Tango.PPC.Jobs.Models if (_brush == null || _brush.GradientStops.Count != BrushStops.Count || IsOffsetChanged) { GradientStopCollection stops = new GradientStopCollection(); - - foreach (var stop in BrushStops.ToList().OrderBy(x => x.StopIndex).ToList()) { //TODO test if displayed is valid stop.IsValid Color color = stop.DisplayedColor; - stops.Add(new GradientStop(stop.IsTransparent ? Colors.Transparent : color, stop.OffsetPercent / 100d)); + stops.Add(new GradientStop( color, stop.OffsetPercent / 100d)); } LinearGradientBrush brush = new LinearGradientBrush(); @@ -381,7 +379,7 @@ namespace Tango.PPC.Jobs.Models { //TODO test if displayed is valid stop.IsValid Color color = BrushStops[i].DisplayedColor; - _brush.GradientStops[i].Color = BrushStops[i].IsTransparent ? Colors.Transparent : color; + _brush.GradientStops[i].Color = color; _brush.GradientStops[i].Offset = BrushStops[i].OffsetPercent / 100d; } @@ -391,17 +389,19 @@ namespace Tango.PPC.Jobs.Models public SegmentModel Clone() { - var cloned = (SegmentModel)Activator.CreateInstance(typeof(SegmentModel), this.Job); + var cloned = new SegmentModel(Job, GUID);//(SegmentModel)Activator.CreateInstance(typeof(SegmentModel), this.Job); - foreach (var prop in typeof(SegmentModel).GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(x => x.SetMethod != null)) - { - if (!prop.PropertyType.IsGenericTypeAndNotNullable()) - { - prop.SetValue(cloned, prop.GetValue(this)); - } - } + cloned.Name = Name; + cloned.LeftOffset = LeftOffset; + cloned.MiddleOffset = MiddleOffset; + cloned.RightOffset = RightOffset; + cloned.IsOffsetChanged = IsOffsetChanged; + cloned.Length = Length; + cloned.IsSelected = false; + cloned.IsInterSegment = IsInterSegment; + cloned.EnableInterSegment = EnableInterSegment; cloned.BrushStops = BrushStops.Select(x => x.Clone()).ToSynchronizedObservableCollection(); - cloned.Job = Job; + cloned.SegmentIndex = SegmentIndex + 1; return cloned; @@ -427,30 +427,18 @@ namespace Tango.PPC.Jobs.Models BrushStopModel brushStop = firstBrush.Clone(); brushStop.StopIndex = 1; brushStop.OffsetPercent = 0; - brushStop.IsFirst = true; - brushStop.IsFirstColorBrush = false; - brushStop.IsMiddle = false; - brushStop.IsSecondColorBrush = false; - brushStop.IsLast = false; + brushStop.Position = BrushStopModel.PositionStatus.First; BrushStops.Add(brushStop); BrushStopModel colorbrushStop = firstBrush.Clone(); - colorbrushStop.IsFirstColorBrush = true; - colorbrushStop.IsFirst = false; - colorbrushStop.IsMiddle = false; - colorbrushStop.IsSecondColorBrush = false; - colorbrushStop.IsLast = false; + colorbrushStop.Position = BrushStopModel.PositionStatus.FirstColor; colorbrushStop.StopIndex = 2; colorbrushStop.OffsetPercent = 0; BrushStops.Add(colorbrushStop); BrushStopModel middleBrushStop = firstBrush.Clone(); middleBrushStop.StopIndex = 3; - middleBrushStop.IsMiddle = true; - middleBrushStop.IsFirst = false; - middleBrushStop.IsFirstColorBrush = false; - middleBrushStop.IsSecondColorBrush = false; - middleBrushStop.IsLast = false; + middleBrushStop.Position = BrushStopModel.PositionStatus.Middle; middleBrushStop.OffsetPercent = 50; middleBrushStop.Color = BrushStopModel.GetRelativeRGB(firstBrush.Color, secondBrush.Color, 0, 1, 0.5); middleBrushStop.DisplayedColor = BrushStopModel.GetRelativeRGB(firstBrush.DisplayedColor, secondBrush.DisplayedColor, 0, 1, 0.5); @@ -465,22 +453,14 @@ namespace Tango.PPC.Jobs.Models BrushStopModel secondbrushStop = secondBrush.Clone(); secondbrushStop.StopIndex = 4; - secondbrushStop.IsSecondColorBrush = true; - secondbrushStop.IsFirst = false; - secondbrushStop.IsFirstColorBrush = false; - secondbrushStop.IsMiddle = false; - secondbrushStop.IsLast = false; + secondbrushStop.Position = BrushStopModel.PositionStatus.SecondColor; secondbrushStop.OffsetPercent = 100; BrushStops.Add(secondbrushStop); BrushStopModel lastSecondBrushStop = secondBrush.Clone(); lastSecondBrushStop.StopIndex = 5; lastSecondBrushStop.OffsetPercent = 100; - lastSecondBrushStop.IsLast = true; - lastSecondBrushStop.IsFirst = false; - lastSecondBrushStop.IsFirstColorBrush = false; - lastSecondBrushStop.IsMiddle = false; - lastSecondBrushStop.IsSecondColorBrush = false; + lastSecondBrushStop.Position = BrushStopModel.PositionStatus.Last; ; BrushStops.Add(lastSecondBrushStop); } @@ -488,18 +468,18 @@ namespace Tango.PPC.Jobs.Models { target.SetNewColor(source); target.IsOutOfGamut = source.IsOutOfGamut; - if (target.IsFirstColorBrush) + if (target.Position == BrushStopModel.PositionStatus.FirstColor) { - BrushStopModel first = BrushStops.Where(x => x.IsFirst).FirstOrDefault(); + BrushStopModel first = BrushStops.Where(x => x.Position == BrushStopModel.PositionStatus.First).FirstOrDefault(); if(first != null) { first.SetNewColor(source); first.IsOutOfGamut = source.IsOutOfGamut; } } - else if(target.IsSecondColorBrush) + else if(target.Position == BrushStopModel.PositionStatus.SecondColor) { - BrushStopModel last = BrushStops.Where(x => x.IsLast).FirstOrDefault(); + BrushStopModel last = BrushStops.Where(x => x.Position == BrushStopModel.PositionStatus.Last).FirstOrDefault(); if(last != null) { last.SetNewColor(source); diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/NavigationObjects/ColorSelectionNavigationObject.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/NavigationObjects/ColorSelectionNavigationObject.cs deleted file mode 100644 index f8c1e81a0..000000000 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/NavigationObjects/ColorSelectionNavigationObject.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.PPC.Jobs.Models; - -namespace Tango.PPC.Jobs.NavigationObjects -{ - public class ColorSelectionNavigationObject - { - public SegmentModel SelectedSegment { get; set; } - public BrushStopModel BrushStopForEdit { get; set; } - /// <summary> - /// True when first brush is open for editing - /// </summary> - public bool IsEditingMode { get; set; } - } - -} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Tango.PPC.JobsV2.csproj b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Tango.PPC.JobsV2.csproj index d816fa42e..deb0e5cc9 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Tango.PPC.JobsV2.csproj +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Tango.PPC.JobsV2.csproj @@ -92,6 +92,10 @@ <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> + <Page Include="Dialogs\ColorSelectionView.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> <Page Include="Dialogs\ImportCsvJobView.xaml"> <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> @@ -124,6 +128,10 @@ <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> + <Page Include="Dialogs\RepeatJobView.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> <Page Include="Dialogs\SpoolChangeView.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> @@ -136,10 +144,6 @@ <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> - <Page Include="Views\ColorSelectionToolView.xaml"> - <SubType>Designer</SubType> - <Generator>MSBuild:Compile</Generator> - </Page> <Page Include="Views\JobProgressView.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> @@ -202,6 +206,9 @@ <DependentUpon>BasicColorCorrectionView.xaml</DependentUpon> </Compile> <Compile Include="Dialogs\BasicColorCorrectionViewVM.cs" /> + <Compile Include="Dialogs\ColorSelectionView.xaml.cs"> + <DependentUpon>ColorSelectionView.xaml</DependentUpon> + </Compile> <Compile Include="Dialogs\ImportCsvJobView.xaml.cs"> <DependentUpon>ImportCsvJobView.xaml</DependentUpon> </Compile> @@ -234,6 +241,10 @@ </Compile> <Compile Include="Dialogs\CatalogSelectionViewVM.cs" /> <Compile Include="Dialogs\JobCreationViewVM.cs" /> + <Compile Include="Dialogs\RepeatJobView.xaml.cs"> + <DependentUpon>RepeatJobView.xaml</DependentUpon> + </Compile> + <Compile Include="Dialogs\RepeatJobViewVM.cs" /> <Compile Include="Dialogs\SpoolChangeView.xaml.cs"> <DependentUpon>SpoolChangeView.xaml</DependentUpon> </Compile> @@ -245,7 +256,6 @@ <Compile Include="Models\BrushStopModel.cs" /> <Compile Include="Models\JobModel.cs" /> <Compile Include="Models\SegmentModel.cs" /> - <Compile Include="NavigationObjects\ColorSelectionNavigationObject.cs" /> <Compile Include="NavigationObjects\JobNavigationObject.cs" /> <Compile Include="NavigationObjects\JobSummeryNavigationObject.cs" /> <Compile Include="NavigationObjects\TwineCatalogNavigationObject.cs" /> @@ -269,16 +279,13 @@ <Compile Include="ViewContracts\IJobsView.cs" /> <Compile Include="ViewContracts\IJobView.cs" /> <Compile Include="ViewModelLocator.cs" /> - <Compile Include="ViewModels\ColorSelectionToolViewVM.cs" /> + <Compile Include="Dialogs\ColorSelectionViewVM.cs" /> <Compile Include="ViewModels\JobProgressViewVM.cs" /> <Compile Include="ViewModels\JobSummeryViewVM.cs" /> <Compile Include="ViewModels\JobsViewVM.cs" /> <Compile Include="ViewModels\JobViewVM.cs" /> <Compile Include="ViewModels\MainViewVM.cs" /> <Compile Include="ViewModels\TwineCatalogViewVM.cs" /> - <Compile Include="Views\ColorSelectionToolView.xaml.cs"> - <DependentUpon>ColorSelectionToolView.xaml</DependentUpon> - </Compile> <Compile Include="Views\JobProgressView.xaml.cs"> <DependentUpon>JobProgressView.xaml</DependentUpon> </Compile> @@ -593,7 +600,7 @@ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" /> + <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" /> </VisualStudio> </ProjectExtensions> </Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModelLocator.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModelLocator.cs index 4f357be2c..5298cf096 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModelLocator.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModelLocator.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Tango.Core.DI; +using Tango.PPC.Jobs.Dialogs; using Tango.PPC.Jobs.ViewModels; namespace Tango.PPC.Jobs @@ -21,7 +22,7 @@ namespace Tango.PPC.Jobs TangoIOC.Default.Register<JobViewVM>(); TangoIOC.Default.Register<TwineCatalogViewVM>(); TangoIOC.Default.Register<JobProgressViewVM>(); - TangoIOC.Default.Register<ColorSelectionToolViewVM>(); + TangoIOC.Default.Register<ColorSelectionViewVM>(); } /// <summary> @@ -94,11 +95,11 @@ namespace Tango.PPC.Jobs /// <summary> /// Gets the twine catalog view VM. /// </summary> - public static ColorSelectionToolViewVM ColorSelectionToolViewVM + public static ColorSelectionViewVM ColorSelectionToolViewVM { get { - return TangoIOC.Default.GetInstance<ColorSelectionToolViewVM>(); + return TangoIOC.Default.GetInstance<ColorSelectionViewVM>(); } } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobViewVM.cs index 52c961876..990f210f4 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobViewVM.cs @@ -48,11 +48,11 @@ namespace Tango.PPC.Jobs.ViewModels /// Represents the selected job view model. /// </summary> /// <seealso cref="Tango.PPC.Common.PPCViewModel" /> - public class JobViewVM : PPCViewModel<IJobView>, INavigationObjectReceiver<JobNavigationObject> + public class JobViewVM : PPCViewModel<IJobView>, INavigationObjectReceiver<JobNavigationObject>, INavigationBlocker { private ObservablesContext _db; private bool _can_navigate_back; - private Thread _check_gamut_thread; + //private Thread _check_gamut_thread; private Job _job_to_load; private JobNavigationIntent _job_to_load_intent; private static Dictionary<String, List<FineTuneItem>> _jobs_fine_tune_items; @@ -435,7 +435,7 @@ namespace Tango.PPC.Jobs.ViewModels // (e.Draggable as FrameworkElement).DataContext as Segment, // (e.Droppable as FrameworkElement).DataContext as Segment); //}); - + AddColorCommand = new RelayCommand<SegmentModel>(AddColor); EditColorCommand = new RelayCommand<BrushStopModel>(EditColor); @@ -453,8 +453,8 @@ namespace Tango.PPC.Jobs.ViewModels } }); - _check_gamut_thread = new Thread(CheckGamutThreadMethod); - _check_gamut_thread.IsBackground = true; + //_check_gamut_thread = new Thread(CheckGamutThreadMethod); + //_check_gamut_thread.IsBackground = true; StartSampleDyeCommand = new RelayCommand(StartSampleDye, CanStartJob); DyeCommand = new RelayCommand(StartJob, CanStartJob); @@ -479,8 +479,8 @@ namespace Tango.PPC.Jobs.ViewModels RepeateSegmentCommand = new RelayCommand(RepeateSegment); PasteCommand = new RelayCommand(Paste); CopyCommand = new RelayCommand(Copy); - UndoCommand = new RelayCommand(Undo); - RedoCommand = new RelayCommand(Redo); + UndoCommand = new RelayCommand(Undo,(x)=> { return false; }); + RedoCommand = new RelayCommand(Redo, (x) => { return false; }); IsFullMode = true; } @@ -498,10 +498,9 @@ namespace Tango.PPC.Jobs.ViewModels { if (!(_job_to_load == null || (_job_to_load != null && Job != null && _job_to_load.Guid == Job.Guid))) { - View.ScrollToTop(); + //View.ScrollToTop(); LogManager.Log($"Loading selected job '{_job_to_load.Name}'..."); - //NotificationProvider.SetGlobalBusyMessage("Loading job details..."); IsFree = false; @@ -541,9 +540,7 @@ namespace Tango.PPC.Jobs.ViewModels .WithSegments() .WithBrushStops() .BuildAsync(); - - //Job.RmlChanged += OnRmlChanged; Job.NameChanged -= Job_NameChanged; Job.NameChanged += Job_NameChanged; @@ -568,15 +565,7 @@ namespace Tango.PPC.Jobs.ViewModels await LoadRML(_selectedRML); - if (!_check_gamut_thread.IsAlive) - { - _check_gamut_thread.Start(); - } - - // SegmentsCollectionView = CollectionViewSource.GetDefaultView(Job.Segments); - // SegmentsCollectionView.SortDescriptions.Add(new SortDescription(nameof(Segment.SegmentIndex), ListSortDirection.Ascending)); - - //ResetFineTuning(); + ///NEW CODE Save to MODEL var jobModel = new JobModel(ColorSpaces) { @@ -594,7 +583,7 @@ namespace Tango.PPC.Jobs.ViewModels foreach( var segm in Job.Segments) { - SegmentModel segmentModel = new SegmentModel(jobModel) + SegmentModel segmentModel = new SegmentModel(jobModel, segm.Guid) { Name = segm.Name, Length = segm.Length, @@ -607,6 +596,7 @@ namespace Tango.PPC.Jobs.ViewModels { BrushStopModel brushStopModel = new BrushStopModel(segmentModel) { + SegmentModel = segmentModel, Cyan = brushStop.Cyan, Magenta = brushStop.Magenta, Yellow = brushStop.Yellow, @@ -618,14 +608,16 @@ namespace Tango.PPC.Jobs.ViewModels A = brushStop.A, B = brushStop.B, OffsetPercent = brushStop.OffsetPercent, - IsTransparent = brushStop.IsTransparent, Color = brushStop.Color, DisplayedColor = brushStop.Color, ColorSpace = brushStop.ColorSpace.Space, - ColorCatalogsItem = brushStop.ColorCatalogsItem + ColorCatalogsItem = brushStop.ColorCatalogsItem, + StopIndex = brushStop.StopIndex }; - AddBrushStop(segmentModel, brushStopModel); + segmentModel.BrushStops.Add(brushStopModel); + // AddBrushStop(segmentModel, brushStopModel); } + ArrangeBrushStopsPosition(segmentModel); jobModel.Segments.Add(segmentModel); } JobModel = jobModel; @@ -691,7 +683,7 @@ namespace Tango.PPC.Jobs.ViewModels base.OnBeforeNavigatedFrom(); //Save... } - + /// <summary> /// Saves the job. /// </summary> @@ -801,43 +793,37 @@ namespace Tango.PPC.Jobs.ViewModels try { LogManager.Log("Editing the job details."); - JobCreationViewVM vm = new JobCreationViewVM( - _spoolTypes.ToList(), - _rmls.ToList() - ); + JobCreationViewVM vm = new JobCreationViewVM( _spoolTypes.ToList(),_rmls.ToList(), JobModel.InterSegmentLength, true ); vm.JobName = JobModel.Name; vm.SelectedRML = JobModel.Rml; vm.SelectedSpoolType = JobModel.SpoolType; vm = await NotificationProvider.ShowDialog<JobCreationViewVM>(vm); if (!vm.DialogResult) return; - Job.Name = vm.JobName; - JobModel.Name = vm.JobName; - bool updateVolumes = JobModel.Rml != vm.SelectedRML; - JobModel. Rml = vm.SelectedRML; - SelectedRML = vm.SelectedRML; - JobModel.Rml = vm.SelectedRML; - Job.SpoolType = vm.SelectedSpoolType; - JobModel.SpoolType = vm.SelectedSpoolType; + if(vm.IsDuplicate) + { + //Duplicate new job + /* + * int index = Jobs.Max(x => x.JobIndex); - if(updateVolumes) + List<Job> clonedJobs = new List<Job>(); + + foreach (var job in SelectedJobs) { - NotificationProvider.SetGlobalBusyMessage("Updating job liquid volumes..."); - foreach (var stop in JobModel.Segments.SelectMany(x => x.BrushStops).Where(x => x.ColorSpace == BL.Enumerations.ColorSpaces.RGB || x.ColorSpace == BL.Enumerations.ColorSpaces.LAB).ToList()) - { - try - { - stop.OnBrushStopFieldValueChanged(); - //TODO ASK ROY!!!!!! - //output.ApplyOnBrushStopVolumesOnly(stop); - } - catch (Exception ex) - { - LogManager.Log(ex, $"Error updating stop volumes after changing thread on segment {stop.SegmentModel.SegmentIndex}, stop {stop.StopIndex}."); - } - } - NotificationProvider.ReleaseGlobalBusyMessage(); + var cloned = job.Clone(); + cloned.JobIndex = ++index; + _db.Jobs.Add(cloned); + clonedJobs.Add(cloned); } + + await _db.SaveChangesAsync(); + * */ + } + Job.Name = vm.JobName; + JobModel.Name = vm.JobName; + Job.SpoolType = vm.SelectedSpoolType; + JobModel.SpoolType = vm.SelectedSpoolType;//update length!!!! + SelectedRML = vm.SelectedRML; } catch (Exception ex) { @@ -845,9 +831,22 @@ namespace Tango.PPC.Jobs.ViewModels } } - private void RepeatUnits() + private async void RepeatUnits() { - //open dialog + var maxLength = Job.SpoolType.Length; + var maxRep = (maxLength == 0 ? 999 : (maxLength / JobModel.Length)); + + + var vm = await NotificationProvider.ShowDialog<RepeatJobViewVM>(new RepeatJobViewVM() + { + MaxRepeations = (int)maxRep, + Repeats = JobModel.NumberOfUnits + }); + + if (vm.DialogResult) + { + JobModel.NumberOfUnits = vm.Repeats; + } } #endregion @@ -865,7 +864,7 @@ namespace Tango.PPC.Jobs.ViewModels { if (Job.Rml != rml || rml.Cct == null) { - bool updateVolumes = Job.Rml != rml; + bool updateRML = Job.Rml != rml; Job.Rml = await new RmlBuilder(_db) .Set(rml.Guid) @@ -875,32 +874,50 @@ namespace Tango.PPC.Jobs.ViewModels .WithLiquidFactors() .WithSpools() .BuildAsync(); - - //foreach (var segment in Job.Segments) - //{ - // SetSegmentLiquidVolumes(segment); - //} - + if(JobModel != null) + JobModel.Rml = Job.Rml; + GetLubricationLevel(); await SetSpoolTension(rml); - if (updateVolumes) + if (updateRML && JobModel != null) { - NotificationProvider.SetGlobalBusyMessage("Updating job liquid volumes..."); - foreach (var stop in Job.Segments.SelectMany(x => x.BrushStops).Where(x => x.BrushColorSpace == BL.Enumerations.ColorSpaces.RGB || x.BrushColorSpace == BL.Enumerations.ColorSpaces.LAB).ToList()) + NotificationProvider.SetGlobalBusyMessage("Updating IsOutOfGammut due to the change RML..."); + foreach (var stop in JobModel.Segments.SelectMany(x => x.BrushStops).Where(x => x.ColorSpace == BL.Enumerations.ColorSpaces.RGB || x.ColorSpace == BL.Enumerations.ColorSpaces.LAB).ToList()) { try { - var output = await _converter.ConvertAsync(stop, false, false); - output.ApplyOnBrushStopVolumesOnly(stop); + stop.OnBrushStopFieldValueChanged(); + //TODO ASK ROY!!!!!! + //output.ApplyOnBrushStopVolumesOnly(stop); } catch (Exception ex) { - LogManager.Log(ex, $"Error updating stop volumes after changing thread on segment {stop.Segment.SegmentIndex}, stop {stop.StopIndex}."); + LogManager.Log(ex, $"Error updating stop volumes after changing thread on segment {stop.SegmentModel.SegmentIndex}, stop {stop.StopIndex}."); } } + DyeCommand.RaiseCanExecuteChanged(); + StartSampleDyeCommand.RaiseCanExecuteChanged(); + StartFineTuningCommand.RaiseCanExecuteChanged(); NotificationProvider.ReleaseGlobalBusyMessage(); } + //if (updateVolumes) + //{ + // NotificationProvider.SetGlobalBusyMessage("Updating job liquid volumes..."); + // foreach (var stop in Job.Segments.SelectMany(x => x.BrushStops).Where(x => x.BrushColorSpace == BL.Enumerations.ColorSpaces.RGB || x.BrushColorSpace == BL.Enumerations.ColorSpaces.LAB).ToList()) + // { + // try + // { + // var output = await _converter.ConvertAsync(stop, false, false); + // output.ApplyOnBrushStopVolumesOnly(stop); + // } + // catch (Exception ex) + // { + // LogManager.Log(ex, $"Error updating stop volumes after changing thread on segment {stop.Segment.SegmentIndex}, stop {stop.StopIndex}."); + // } + // } + // NotificationProvider.ReleaseGlobalBusyMessage(); + //} } } } @@ -1022,204 +1039,6 @@ namespace Tango.PPC.Jobs.ViewModels #region Brush Stops Management - //private void Stop_ColorCatalogChanged(object sender, ColorCatalog catalog) - //{ - // BrushStop stop = sender as BrushStop; - - // if (stop.ColorSpace != null && stop.BrushColorSpace == BL.Enumerations.ColorSpaces.Catalog) - // { - // if (stop.ColorCatalogsItem != null) - // { - // try - // { - // if (catalog != null && catalog.AllItemsOrdered.Count > 0) - // { - // stop.ColorCatalogsItem = catalog.GetClosestItem(stop.ColorCatalogsItem.Color); - // } - // else - // { - // stop.ColorCatalogsItem = null; - // } - // } - // catch (Exception ex) - // { - // LogManager.Log(ex, "Error getting closest catalog color."); - // stop.ColorCatalogsItem = null; - // } - // } - // } - //} - - - /// <summary> - /// Invokes the color adjustment for the specified brush stop. - /// </summary> - /// <param name="brushStop">The brush stop.</param> - private async void InvokeColorAdjustmentForBrushStop(BrushStop brushStop) - { - try - { - LogManager.Log($"Invoking triplet color adjustment dialog for brush stop {brushStop.StopIndex} at segment {brushStop.Segment.SegmentIndex}."); - - LogManager.Log("Retrieving color conversion suggestions for brush stop..."); - PMR.ColorLab.ConversionOutput conversionOutput = null; - - if (brushStop.IsOutOfGamut) - { - conversionOutput = _converter.Convert(brushStop, false); - } - - BasicColorCorrectionViewVM vm = null; - List<ColorConversionSuggestion> suggestions = null; - - if (brushStop.IsOutOfGamut) - { - vm = await NotificationProvider.ShowDialog<BasicColorCorrectionViewVM>(new BasicColorCorrectionViewVM() - { - InvalidBrushStop = brushStop, - Suggestions = new List<ColorConversionSuggestion>() { new ColorConversionSuggestion(conversionOutput.SingleCoordinates, 0, 0) }, - }); - } - - if (vm == null || vm.Result == BasicColorCorrectionViewVM.ColorCorrectionDialogResult.MoreOptions) - { - NotificationProvider.SetGlobalBusyMessage("Generating color hive..."); - - await Task.Factory.StartNew(() => - { - conversionOutput = _converter.Convert(brushStop, true); - - suggestions = conversionOutput.CreateHiveSuggestions(); - - if (vm == null) - { - var center = suggestions.GetCenterSuggestion(); - center.Coordinates.Red = brushStop.Red; - center.Coordinates.Green = brushStop.Green; - center.Coordinates.Blue = brushStop.Blue; - - center.Coordinates.L = brushStop.L; - center.Coordinates.A = brushStop.A; - center.Coordinates.B = brushStop.B; - } - }); - - NotificationProvider.ReleaseGlobalBusyMessage(); - LogManager.Log("Invoking hive color conversion dialog..."); - vm = await NotificationProvider.ShowDialog<AdvancedColorCorrectionViewVM>(new AdvancedColorCorrectionViewVM() - { - InvalidBrushStop = brushStop, - Suggestions = suggestions, - IsOutOfGamut = brushStop.IsOutOfGamut, - }); - } - - if (vm.Result == BasicColorCorrectionViewVM.ColorCorrectionDialogResult.Confirmed) - { - LogManager.Log($"Color suggestion selected: {vm.SelectedSuggestion.Color.ToString()}."); - - if (brushStop.BrushColorSpace == BL.Enumerations.ColorSpaces.RGB) - { - brushStop.Red = vm.SelectedSuggestion.Coordinates.Red; - brushStop.Green = vm.SelectedSuggestion.Coordinates.Green; - brushStop.Blue = vm.SelectedSuggestion.Coordinates.Blue; - } - else if (brushStop.BrushColorSpace == BL.Enumerations.ColorSpaces.LAB) - { - brushStop.L = vm.SelectedSuggestion.Coordinates.L; - brushStop.A = vm.SelectedSuggestion.Coordinates.A; - brushStop.B = vm.SelectedSuggestion.Coordinates.B; - } - else if (brushStop.BrushColorSpace == BL.Enumerations.ColorSpaces.Volume) - { - vm.SelectedSuggestion.ApplyOnBrushStop(brushStop); - } - - brushStop.Corrected = true; - brushStop.IsOutOfGamut = false; - brushStop.OutOfGamutChecked = true; - } - } - catch (Exception ex) - { - LogManager.Log(ex, "Error while invoking color adjustment dialog."); - await NotificationProvider.ShowError("An error occurred while trying to convert the selected color."); - } - finally - { - NotificationProvider.ReleaseGlobalBusyMessage(); - DyeCommand.RaiseCanExecuteChanged(); - } - } - - /// <summary> - /// Called when the brush stop field value has been changed (This called from the view!). - /// </summary> - /// <param name="stop">The brush stop.</param> - [HandleProcessCorruptedStateExceptions] - public void OnBrushStopFieldValueChanged(BrushStop stop) - { - if (stop != null && stop.ColorSpace != null) - { - if (stop.BrushColorSpace == BL.Enumerations.ColorSpaces.Catalog) - { - DyeCommand.RaiseCanExecuteChanged(); - return; - } - - _volumeConversionTimer.ResetReplace(() => - { - - try - { - var output = _converter.Convert(stop, false); - - if (stop.BrushColorSpace == BL.Enumerations.ColorSpaces.Volume) - { - stop.Red = output.SingleCoordinates.Red; - stop.Green = output.SingleCoordinates.Green; - stop.Blue = output.SingleCoordinates.Blue; - stop.L = output.SingleCoordinates.L; - stop.A = output.SingleCoordinates.A; - stop.B = output.SingleCoordinates.B; - stop.Corrected = false; - stop.OutOfGamutChecked = false; - } - else if (stop.BrushColorSpace == BL.Enumerations.ColorSpaces.LAB) - { - output.ApplyOnBrushStopVolumesOnly(stop); - stop.Corrected = false; - stop.OutOfGamutChecked = false; - } - else if (stop.BrushColorSpace == BL.Enumerations.ColorSpaces.RGB) - { - output.ApplyOnBrushStopVolumesOnly(stop); - stop.Corrected = false; - stop.OutOfGamutChecked = false; - } - - try - { - var closestItem = AvailableCatalogs.SelectMany(x => x.AllItemsOrdered).GetClosestItem(stop.Color); - stop.ColorCatalog = closestItem.ColorCatalogsGroup.ColorCatalog; - stop.ColorCatalogsItem = closestItem; - } - catch { } - } - catch (Exception ex) - { - LogManager.Log(ex, "An error occurred while trying to get volume => RGB from conversion engine."); - } - finally - { - InvokeUI(() => DyeCommand.RaiseCanExecuteChanged()); - } - - }); - - } - } - /// <summary> /// Opens the twine catalog for the specified brush stop. /// </summary> @@ -1244,12 +1063,23 @@ namespace Tango.PPC.Jobs.ViewModels // } //} - private void ArrangeBrushStopsIndices(Segment segment) + private void ArrangeBrushStopsIndexes(SegmentModel segment) { for (int i = 0; i < segment.BrushStops.Count; i++) { segment.BrushStops[i].StopIndex = i + 1; } + ArrangeBrushStopsPosition(segment); + } + + private void ArrangeBrushStopsPosition(SegmentModel segment) + { + if(segment.BrushStops.Count == 1) + { + segment.BrushStops.FirstOrDefault().Position = BrushStopModel.PositionStatus.FirstColor; + } + else if (segment.BrushStops.Count > 1) + segment.BrushStops.ToList().ForEach(x => x.Position = (BrushStopModel.PositionStatus)x.StopIndex); } private bool ValidateBrushStops() @@ -1269,15 +1099,21 @@ namespace Tango.PPC.Jobs.ViewModels await NotificationProvider.ShowInfo("Color transitions are best visible with segment length of 5 meters and above."); } - var newBrushStop = await NavigationManager.NavigateForResult<JobsV2Module, ColorSelectionToolView, BrushStopModel, ColorSelectionNavigationObject>( - new ColorSelectionNavigationObject() + var vm = await NotificationProvider.ShowDialog<ColorSelectionViewVM>(new ColorSelectionViewVM() + { + DialogEditObject = new ColorSelectionViewVM.DialogObject() { SelectedSegment = segment, BrushStopForEdit = new BrushStopModel(segment), - IsEditingMode = false - }, true); - - AddBrushStop(segment, newBrushStop); + IsEditingMode = false, + } + }); + + if (vm.DialogResult) + { + AddBrushStop(segment, vm.SelectedBrushStop); + DyeCommand.RaiseCanExecuteChanged(); + } // SetSegmentLiquidVolumes(segment); //RegisterJobBrushStopsEvents(); } @@ -1289,18 +1125,22 @@ namespace Tango.PPC.Jobs.ViewModels { SegmentModel segment = brushStop.SegmentModel; LogManager.Log($"Edit brush stop."); - - var newBrushStop = await NavigationManager.NavigateForResult<JobsV2Module, ColorSelectionToolView, BrushStopModel, ColorSelectionNavigationObject>( - new ColorSelectionNavigationObject() + + var vm = await NotificationProvider.ShowDialog<ColorSelectionViewVM>(new ColorSelectionViewVM() + { + DialogEditObject = new ColorSelectionViewVM.DialogObject() { SelectedSegment = segment, BrushStopForEdit = brushStop, - IsEditingMode = true - }, true); + IsEditingMode = true, + } + }); - if(newBrushStop != null) + + if (vm.DialogResult) { - segment.SetNewColor(brushStop,newBrushStop); + segment.SetNewColor(brushStop, vm.SelectedBrushStop); + DyeCommand.RaiseCanExecuteChanged(); } } @@ -1310,29 +1150,23 @@ namespace Tango.PPC.Jobs.ViewModels public async void AddBrushStop(SegmentModel segment, BrushStopModel newBrushStop) { if (newBrushStop == null || segment == null) - return; - - JobModel job = segment.Job; - + return; + Segment s = new Segment(); //SolidColor - if(segment.BrushStops.Count == 0) + if (segment.BrushStops.Count == 0) { - newBrushStop.IsFirstColorBrush = true; + newBrushStop.Position = BrushStopModel.PositionStatus.FirstColor; segment.BrushStops.Add(newBrushStop); } - //Add SecondColor + //Add Second BrushStop else if(segment.BrushStops.Count == 1)// add gradient { BrushStopModel currentBrushStop = segment.BrushStops[0]; segment.CreateGradientBrushes(segment.BrushStops[0], newBrushStop); segment.RaiseSegmentBrushChanged(); } - else + else //Create new Segment and Add BrushStop { - if (segment.BrushStops.Count < 5) - { - return; - } await NotificationProvider.ShowInfo("Please note that gradient segment is now split into two gradients."); SegmentModel newSegmentModel = segment.Clone(); @@ -1347,12 +1181,14 @@ namespace Tango.PPC.Jobs.ViewModels segment.AddOrReplaceSecondBrush(newBrushStop); segment.UpdateMiddleColorBrush(); segment.RaiseSegmentBrushChanged(); + ArrangeBrushStopsIndexes(segment); + ArrangeBrushStopsIndexes(newSegmentModel); - if(job.Segments.Count == segment.SegmentIndex) - job.Segments.Add(newSegmentModel); + if (JobModel.Segments.Count == segment.SegmentIndex) + JobModel.Segments.Add(newSegmentModel); else { - job.Segments.Insert(segment.SegmentIndex, newSegmentModel); + JobModel.Segments.Insert(segment.SegmentIndex, newSegmentModel); } ArrangeSegmentsIndixes(); } @@ -1596,51 +1432,7 @@ namespace Tango.PPC.Jobs.ViewModels #region Out Of Gamut Check Thread - /// <summary> - /// Iterates over all brush stops and checks for out of gamut. - /// </summary> - [HandleProcessCorruptedStateExceptions] - private void CheckGamutThreadMethod() - { - while (true) - { - Thread.Sleep(500); - - if (Job != null && Job.Rml.Cct != null && IsVisible) - { - var brushStops = Job.Segments.SelectMany(x => x.BrushStops).Where(x => x.ColorSpace != null).Where(x => (x.BrushColorSpace == BL.Enumerations.ColorSpaces.LAB || x.BrushColorSpace == BL.Enumerations.ColorSpaces.RGB) && !x.Corrected && !x.OutOfGamutChecked).ToList(); - - foreach (var stop in brushStops) - { - try - { - stop.IsOutOfGamut = _converter.IsOutOfGamut(stop); - stop.OutOfGamutChecked = true; - } - catch (AccessViolationException) - { - LogManager.Log($"Out of gamut check failed for brush stop {stop.StopIndex} at segment {stop.Segment.SegmentIndex}.", LogCategory.Warning); - continue; - } - catch - { - LogManager.Log($"Out of gamut check failed for brush stop {stop.StopIndex} at segment {stop.Segment.SegmentIndex}.", LogCategory.Warning); - } - } - - if (brushStops.Count > 0) - { - InvokeUI(() => - { - DyeCommand.RaiseCanExecuteChanged(); - StartSampleDyeCommand.RaiseCanExecuteChanged(); - StartFineTuningCommand.RaiseCanExecuteChanged(); - }); - } - } - } - } - + #endregion #region Lubrication Level @@ -1755,6 +1547,11 @@ namespace Tango.PPC.Jobs.ViewModels _job_to_load_intent = JobNavigationIntent.Default; } + public override void OnNavigatedTo(PPCViewModel fromVM) + { + base.OnNavigatedTo(fromVM); + } + /// <summary> /// Called before the navigation system navigates back from this object. /// Return false to abort the navigation. @@ -1762,40 +1559,17 @@ namespace Tango.PPC.Jobs.ViewModels /// <returns></returns> public async override Task<bool> OnNavigateBackRequest() { - bool result = true; - - if (!IsFree) return false; - - if (!_can_navigate_back) + try { - bool jobChainged = false; - - if (Job != null) - { - string job_string = Job.ToJobFileWhenLoaded().ToString(); - jobChainged = job_string != _current_job_string; - } - - if (jobChainged) - { - if (await NotificationProvider.ShowQuestion("Are you sure you want to exit this job without saving changes?")) - { - Job = null; - SegmentsCollectionView = null; - } - else - { - result = false; - } - } - else - { - Job = null; - SegmentsCollectionView = null; - } + await Save(); + return true; + } + catch (Exception ex) + { + LogManager.Log(ex, "Error saving job to database."); + await NotificationProvider.ShowError("Error saving the current job."); + return false; } - - return result; } public override void OnApplicationReady() @@ -1832,16 +1606,21 @@ namespace Tango.PPC.Jobs.ViewModels { if (false == JobModel.Segments.ToList().Any(x => x.IsSelected)) return; - var firstIndex = JobModel.Segments.ToList().FindIndex(i => i.IsSelected == true); - var lastIndex = JobModel.Segments.ToList().FindLastIndex(i => i.IsSelected == true); - if(firstIndex < lastIndex) + + for (int firstIndex = 0, lastIndex = JobModel.Segments.Count - 1; firstIndex < lastIndex; firstIndex++) { - //TODO function! - //var copy = JobModel.Segments.ToList(); - //copy.Reverse(firstIndex, (lastIndex - firstIndex + 1)); - //JobModel.Segments = new SynchronizedObservableCollection<SegmentModel>(copy); - //ArrangeSegmentsIndixes(); + if (JobModel.Segments[firstIndex].IsSelected) + { + for (; lastIndex >= 0; lastIndex--) + { + if (JobModel.Segments[lastIndex].IsSelected) + { + JobModel.SwapSegments(firstIndex, lastIndex); + } + } + } } + ArrangeSegmentsIndixes(); } private async void DeleteSegment() @@ -1902,5 +1681,80 @@ namespace Tango.PPC.Jobs.ViewModels } #endregion + + private async Task Save() + { + if (JobModel == null) + return; + var colorSpaces = await _db.ColorSpaces.ToListAsync(); + + Job.ColorSpace = colorSpaces.FirstOrDefault(); + + var oldSegments = Job.Segments.ToList(); + + foreach (var segment in Job.Segments.ToList()) + { + foreach (var stop in segment.BrushStops.ToList()) + { + _db.BrushStops.Remove(stop); + } + + _db.Segments.Remove(segment); + } + + Job.Segments.Clear(); + + foreach (var segment in JobModel.Segments.OrderBy(x => x.SegmentIndex).ToList()) + { + var dbSegment = new Segment(); + dbSegment.Name = "Standard Segment"; + + dbSegment.Job = Job; + dbSegment.SegmentIndex = segment.SegmentIndex; + dbSegment.Length = segment.Length; + + _db.Segments.Add(dbSegment); + + foreach (var stop in segment.BrushStops.OrderBy(x => x.StopIndex).ToList()) + { + var dbStop = new BrushStop(); + dbStop.Segment = dbSegment; + _db.BrushStops.Add(dbStop); + + dbStop.ColorSpace = colorSpaces.FirstOrDefault(x => x.Code == (int)stop.ColorSpace); + dbStop.Red = stop.Red; + dbStop.Green = stop.Green; + dbStop.Blue = stop.Blue; + dbStop.L = stop.L; + dbStop.A = stop.A; + dbStop.B = stop.B; + dbStop.Cyan = stop.Cyan; + dbStop.Magenta = stop.Magenta; + dbStop.Yellow = stop.Yellow; + dbStop.Black = stop.Black; + dbStop.BestMatchR = stop.DisplayedColor.R; + dbStop.BestMatchG = stop.DisplayedColor.G; + dbStop.BestMatchB = stop.DisplayedColor.B; + + dbStop.OffsetPercent = stop.OffsetPercent; + dbStop.StopIndex = stop.StopIndex; + dbStop.IsOutOfGamut = stop.IsOutOfGamut; + + + dbStop.SetVolume(LiquidTypes.Cyan, stop.Cyan); + dbStop.SetVolume(LiquidTypes.Magenta, stop.Magenta); + dbStop.SetVolume(LiquidTypes.Yellow, stop.Yellow); + dbStop.SetVolume(LiquidTypes.Black, stop.Black); + } + } + Job.LastUpdated = DateTime.UtcNow; + Job.IsSynchronized = false; + Job.JobStatus = BL.Enumerations.JobStatuses.Draft; + //_current_job_string = Job.ToJobFileWhenLoaded().ToString(); + RaiseMessage(new JobSavedMessage() { Job = Job }); + + await _db.SaveChangesAsync(); + + } } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobsViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobsViewVM.cs index 0a1ce7df7..1f7042b57 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobsViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobsViewVM.cs @@ -422,10 +422,7 @@ namespace Tango.PPC.Jobs.ViewModels { await Task.Delay(200); } - JobCreationViewVM vm = new JobCreationViewVM( - _spoolTypes.ToList(), - _rmls.ToList() - ); + JobCreationViewVM vm = new JobCreationViewVM( _spoolTypes.ToList(), _rmls.ToList(), 3, false ); string selectedRmlGuid = (Settings.DefaultRmlGuid != null && _rmls.Select(x => x.Guid).Contains(Settings.DefaultRmlGuid)) ? Settings.DefaultRmlGuid : _rmls.FirstOrDefault().Guid; string selectedSpoolTypeGuid = Settings.DefaultSpoolTypeGuid != null ? Settings.DefaultSpoolTypeGuid : Adapter.SpoolTypes.FirstOrDefault().Guid; ; diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobView.xaml index 982c534b9..65a880f4e 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobView.xaml @@ -145,7 +145,7 @@ </DataTemplate> <DataTemplate x:Key="Segment_Template" DataType="{x:Type entities:Segment}"> - <Grid Height="420" Margin="57 15 57 0"> + <Grid Height="430" Margin="57 15 57 0"> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> @@ -241,7 +241,7 @@ <DataTrigger Binding="{Binding FirstBrushStop.ColorSpace, Converter={StaticResource EnumToDescriptionConverter}}" Value="RGB"> <Setter Property="ContentTemplate" Value="{StaticResource RGB_Template}" /> </DataTrigger> - <DataTrigger Binding="{Binding FirstBrushStop.ColorSpace, Converter={StaticResource EnumToDescriptionConverter}}" Value="CMYK"> + <DataTrigger Binding="{Binding FirstBrushStop.ColorSpace, Converter={StaticResource EnumToDescriptionConverter}}" Value="Volume"> <Setter Property="ContentTemplate" Value="{StaticResource CMYK_Template}" /> </DataTrigger> <DataTrigger Binding="{Binding FirstBrushStop.ColorSpace, Converter={StaticResource EnumToDescriptionConverter}}" Value="LAB"> @@ -269,7 +269,7 @@ <DataTrigger Binding="{Binding SecondBrushStop.ColorSpace, Converter={StaticResource EnumToDescriptionConverter}}" Value="RGB"> <Setter Property="ContentTemplate" Value="{StaticResource RGB_Template}" /> </DataTrigger> - <DataTrigger Binding="{Binding SecondBrushStop.ColorSpace, Converter={StaticResource EnumToDescriptionConverter}}" Value="CMYK"> + <DataTrigger Binding="{Binding SecondBrushStop.ColorSpace, Converter={StaticResource EnumToDescriptionConverter}}" Value="Volume"> <Setter Property="ContentTemplate" Value="{StaticResource CMYK_Template}" /> </DataTrigger> <DataTrigger Binding="{Binding SecondBrushStop.ColorSpace, Converter={StaticResource EnumToDescriptionConverter}}" Value="LAB"> @@ -406,10 +406,8 @@ <RowDefinition Height="Auto"/> <RowDefinition Height="1*"/> </Grid.RowDefinitions> - <Border Grid.Row="0" x:Name="jobDetailsBorder" Background="{StaticResource TangoMidAccentBrush}" BorderThickness="0 0 0 1" BorderBrush="{StaticResource TangoMidAccentBrush}" Margin="10 20 10 15"> - <Border.Effect> - <DropShadowEffect Color="Silver" ShadowDepth="0" BlurRadius="20" Opacity="1" /> - </Border.Effect> + <Border Grid.Row="0" x:Name="jobDetailsBorder" Background="{StaticResource TangoPrimaryBackgroundBrush}" BorderThickness="0 0 0 1" BorderBrush="{StaticResource TangoLightBorderBrush}" Margin="0 0 0 0"> + <Grid x:Name="job_details" HorizontalAlignment="Stretch" > <DockPanel Height="74" HorizontalAlignment="Stretch"> @@ -419,24 +417,29 @@ </Border> </touch:TouchButton> - <Grid DockPanel.Dock="Left" VerticalAlignment="Center" HorizontalAlignment="Stretch" Margin="0 0 50 0" > + <Grid DockPanel.Dock="Left" VerticalAlignment="Center" HorizontalAlignment="Stretch" Margin="0 0 30 0" > <Grid.ColumnDefinitions> - <ColumnDefinition Width="Auto"/> + <ColumnDefinition Width="1*"/> <ColumnDefinition Width="1*"/> <ColumnDefinition Width="1*"/> </Grid.ColumnDefinitions> - <TextBlock Margin="10 0 0 0" TextTrimming="CharacterEllipsis" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="{StaticResource TangoComboBoxItemFontSize}" FontWeight="SemiBold" Foreground="{StaticResource TangoLightSelectedBrush}" Text="{Binding JobModel.Name,FallbackValue='Job Name'}"/> + <TextBlock Margin="10 0 0 0" TextTrimming="CharacterEllipsis" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="{StaticResource TangoMenuItemFontSize}" Text="{Binding JobModel.Name,FallbackValue='Job Name'}" ToolTip="{Binding JobModel.Name}"/> - <StackPanel Margin="20 0 0 0" Grid.Column="1" VerticalAlignment="Center" Orientation="Horizontal" HorizontalAlignment="Center"> - <TextBlock Text="Thread Type:" VerticalAlignment="Center" FontSize="{StaticResource TangoDefaultFontSize}" Foreground="{StaticResource TangoLightSelectedBrush}"></TextBlock> - <TextBlock Margin="10 0 0 0" Foreground="{StaticResource TangoLightSelectedBrush}" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" FontWeight="Medium"> - <Run Text="{Binding JobModel.Rml.Name}"></Run> + <StackPanel Margin="10 0 0 0" Grid.Column="1" VerticalAlignment="Center" Orientation="Horizontal" HorizontalAlignment="Left"> + <StackPanel.ToolTip> + <ToolTip> + <TextBlock Text="{Binding JobModel.Rml.Name}" /> + </ToolTip> + </StackPanel.ToolTip> + <TextBlock Text="Thread Type:" VerticalAlignment="Center" FontSize="{StaticResource TangoDefaultFontSize}" ></TextBlock> + <TextBlock Margin="10 0 0 0" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" FontWeight="Medium" Text="{Binding JobModel.Rml.Name}"> + </TextBlock> </StackPanel> - <StackPanel Margin="20 0 0 0" Grid.Column="2" VerticalAlignment="Center" Orientation="Horizontal" HorizontalAlignment="Center"> - <TextBlock Text="Spool Type:" VerticalAlignment="Center" FontSize="{StaticResource TangoDefaultFontSize}" Foreground="{StaticResource TangoLightSelectedBrush}"></TextBlock> - <TextBlock Text="{Binding JobModel.SpoolType.Name}" Margin="10 0 0 0" Foreground="{StaticResource TangoLightSelectedBrush}" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" FontWeight="Medium"/> + <StackPanel Margin="10 0 0 0" Grid.Column="2" VerticalAlignment="Center" Orientation="Horizontal" HorizontalAlignment="Center"> + <TextBlock Text="Spool Type:" VerticalAlignment="Center" FontSize="{StaticResource TangoDefaultFontSize}" ></TextBlock> + <TextBlock Text="{Binding JobModel.SpoolType.Name}" Margin="10 0 0 0" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" FontWeight="Medium"/> </StackPanel> </Grid> </DockPanel> @@ -559,11 +562,14 @@ <!--Border x:Name="borderDockFloat" Height="10" Margin="0 0 0 0" BorderBrush="Transparent" > <DockPanel x:Name="dockEdit" LastChildFill="False" Height="10" Width="50" HorizontalAlignment="Right" RenderTransformOrigin="0.58,2.08"/> </Border> --> - <ListBox x:Name="listSegments" Margin="10 0 10 0" ItemsSource="{Binding SegmentsCollectionView}" ItemTemplate="{StaticResource Segment_Template}" Style="{StaticResource SegmentsListBox}" ScrollViewer.VerticalScrollBarVisibility="Visible" Visibility="{Binding IsFullMode, Converter={StaticResource BooleanToVisibilityConverter}}" Padding="0" - BorderThickness="0" BorderBrush="Transparent"/> + <ListBox x:Name="listSegments" Margin="10 0 10 0" ItemsSource="{Binding SegmentsCollectionView}" ItemTemplate="{StaticResource Segment_Template}" Style="{StaticResource SegmentsListBox}" + ScrollViewer.VerticalScrollBarVisibility="Visible" + Visibility="{Binding IsFullMode, Converter={StaticResource BooleanToVisibilityConverter}}" /> - <ListBox x:Name="collapsedListSegments" ItemsSource="{Binding SegmentsCollectionView}" ItemTemplate="{StaticResource CollapsedSegment_Template}" Style="{StaticResource SegmentsListBox}" ScrollViewer.VerticalScrollBarVisibility="Visible" Visibility="{Binding IsFullMode, Converter={StaticResource BooleanToVisibilityInverseConverter}}"/> + <ListBox x:Name="collapsedListSegments" ItemsSource="{Binding SegmentsCollectionView}" ItemTemplate="{StaticResource CollapsedSegment_Template}" Style="{StaticResource SegmentsListBox}" + ScrollViewer.VerticalScrollBarVisibility="Visible" + Visibility="{Binding IsFullMode, Converter={StaticResource BooleanToVisibilityInverseConverter}}"/> <!--<StackPanel x:Name="stackOutput" Orientation="Horizontal" VerticalAlignment="Center" Style="{StaticResource Level1Container}"/>--> @@ -575,7 +581,7 @@ </Grid> <Grid Grid.Row="2"> - <Grid IsHitTestVisible="False"> + <!--<Grid IsHitTestVisible="False"> <Grid.Background> <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"> <GradientStop Offset="0" Color="#AEFFFFFF" /> @@ -583,16 +589,16 @@ </LinearGradientBrush> </Grid.Background> <Rectangle Stroke="{StaticResource TangoDividerBrush}" StrokeThickness="1" VerticalAlignment="Top" /> - </Grid> + </Grid>--> </Grid> - <touch:TouchDropShadowBorder Grid.Row="3" Margin="10 0 10 15" CornerRadius="40" BorderThickness="1" Padding="2" > - - <touch:TouchExpander IsExpanded="True" FontSize="{StaticResource TangoExpanderHeaderFontSize}" Margin="10" BorderThickness="0"> + <!--<touch:TouchDropShadowBorder Grid.Row="3" Margin="10 0 10 15" CornerRadius="0" BorderThickness="0" Padding="0" >--> + <Border Grid.Row="3" Margin="10 0 10 15" BorderThickness="0"> + <touch:TouchExpander Grid.Row="3" Margin="15 0 15 0 " IsExpanded="True" FontSize="{StaticResource TangoTitleFontSize}" BorderThickness="0" Style="{StaticResource TouchRoundedExpander}"> <touch:TouchExpander.Header> <DockPanel > <touch:TouchButton DockPanel.Dock="Right" Margin="0 0 20 0" HorizontalAlignment="Right" VerticalAlignment="Center" EnableDropShadow="False" Background="Transparent" BorderThickness="0" Command="{Binding RepeatUnitsCommand}" > - <Border CornerRadius="20" Width="130" Height="40" BorderThickness="1" BorderBrush="{StaticResource TangoDividerBrush}"> + <Border CornerRadius="20" Width="130" Height="40" BorderThickness="1" BorderBrush="{StaticResource TangoDarkForegroundBrush}"> <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="{StaticResource TangoDefaultFontSize}" Foreground="{StaticResource TangoDarkForegroundBrush}">Repeat Job</TextBlock> </Border> </touch:TouchButton> @@ -603,21 +609,28 @@ </DockPanel> </touch:TouchExpander.Header> - <StackPanel Style="{StaticResource Level2ContainerExtraMargin}"> - <Grid> + <StackPanel Margin="40 0 40 0"> + <TextBlock VerticalAlignment="Top" DockPanel.Dock="Top" Foreground="{StaticResource TangoDarkForegroundBrush}"> + <Run Text="Unit: "></Run> + <Run Text="{Binding JobModel.Length,Mode=OneWay}"/> + <Run Text="m"></Run> + </TextBlock> + + <Grid Margin=" 0 10 0 0"> <!--<touch:TouchVirtualizedContentReplaceControl MinHeight="40"> <DataTemplate>--> - <localControls:JobSummeryViewer JobModel="{Binding JobModel}" Height="40" DisplayMarkers="False" /> + <localControls:JobSummeryViewer JobModel="{Binding JobModel}" Height="20" DisplayMarkers="False" /> <!--</DataTemplate> </touch:TouchVirtualizedContentReplaceControl>--> </Grid> - <DockPanel Margin="0 30 0 0" LastChildFill="False"> - + <DockPanel Margin="0 20 0 0" LastChildFill="False"> + <StackPanel Orientation="Horizontal" DockPanel.Dock="Left" VerticalAlignment="Center"> <TextBlock> - <Run Text="Job length (m):"></Run> - <Run Text="{Binding JobModel.Length,Mode=OneWay}"></Run> + <Run Text="Total:"></Run> + <Run Text="{Binding JobModel.LengthIncludingNumberOfUnits,Mode=OneWay}"></Run> + <Run Text="m"></Run> </TextBlock> <TextBlock Foreground="{StaticResource TangoGrayTextBrush}"> <TextBlock.Style> @@ -642,14 +655,12 @@ <touch:TouchNumericTextBox Foreground="{StaticResource TangoGrayTextBrush}" Margin="5 0 0 0" Width="50" HorizontalContentAlignment="Center" Maximum="100" Minimum="0" Value="{Binding JobModel.LengthPercentageFactor}" KeyboardContainer="{Binding ElementName=Container}" StringFormat="0" FocusSelectionMode="SelectAll" /> <TextBlock VerticalAlignment="Bottom" Foreground="{StaticResource TangoGrayTextBrush}">%</TextBlock> - - <Image Margin="10 0 0 0" Source="../Images/JobView/settings.png" VerticalAlignment="Bottom" /> </StackPanel> </DockPanel> </StackPanel> - </touch:TouchExpander> - - </touch:TouchDropShadowBorder> + </touch:TouchExpander> + </Border> + <!--</touch:TouchDropShadowBorder>--> <!--<dragAndDrop:DraggingSurface x:Name="DraggingSurface" />--> </Grid> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobView.xaml.cs index 77c30bb30..66c497e29 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobView.xaml.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobView.xaml.cs @@ -28,7 +28,7 @@ namespace Tango.PPC.Jobs.Views public partial class JobView : UserControl, INavigationView, IJobView { private JobViewVM _vm; - private bool _is_edit_docked; + public JobView() { @@ -47,10 +47,10 @@ namespace Tango.PPC.Jobs.Views } - private void OnBrushStopFieldValueChanged(object sender, Touch.Controls.DoubleValueChangedEventArgs e) - { - _vm.OnBrushStopFieldValueChanged((sender as FrameworkElement).DataContext as BrushStop); - } + //private void OnBrushStopFieldValueChanged(object sender, Touch.Controls.DoubleValueChangedEventArgs e) + //{ + // _vm.OnBrushStopFieldValueChanged((sender as FrameworkElement).DataContext as BrushStop); + //} public void DisplaySampleDye() { @@ -116,18 +116,23 @@ namespace Tango.PPC.Jobs.Views // borderEditDock.Visibility = Visibility.Collapsed; //} - private void OnLiquidVolumeFieldValueChanged(object sender, Touch.Controls.DoubleValueChangedEventArgs e) - { - var liquidVolume = (sender as FrameworkElement).DataContext as LiquidVolume; + //private void OnLiquidVolumeFieldValueChanged(object sender, Touch.Controls.DoubleValueChangedEventArgs e) + //{ + // var liquidVolume = (sender as FrameworkElement).DataContext as LiquidVolume; - if (liquidVolume != null) - { - _vm.OnBrushStopFieldValueChanged(liquidVolume.BrushStop); - } - } + // if (liquidVolume != null) + // { + // _vm.OnBrushStopFieldValueChanged(liquidVolume.BrushStop); + // } + //} public void ScrollToTop() { + if(listSegments.IsVisible && listSegments.Items.Count > 0) + { + listSegments.ScrollIntoView(listSegments.Items[0]); + + } //FloatEditing(); //scrollViewer.ScrollToTop(); } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/MainView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/MainView.xaml index 77d2d200d..505ccc312 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/MainView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/MainView.xaml @@ -17,7 +17,6 @@ <views:JobView /> <views:TwineCatalogView /> <views:JobProgressView /> - <views:ColorSelectionToolView/> </controls:NavigationControl> </Grid> </UserControl> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml b/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml index c33e90e76..bb0a694cf 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml @@ -17,6 +17,10 @@ <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Styles/TouchIconButton.xaml" /> <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Styles/TouchListBox.xaml" /> <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Styles/TouchCheckBox.xaml" /> + <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Styles/TouchExpander.xaml" /> + <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Styles/TouchNumericUpDownControl.xaml" /> + <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Controls/TouchExpander.xaml" /> + <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Controls/TouchNativeListBox.xaml" /> <!--PPC--> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Styles.xaml b/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Styles.xaml index 593adc3f5..e7a6cd6c3 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Styles.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Styles.xaml @@ -49,16 +49,14 @@ <Setter Property="ItemsPanel"> <Setter.Value> <ItemsPanelTemplate> - <VirtualizingStackPanel VirtualizingPanel.IsVirtualizing="True" VirtualizingPanel.VirtualizationMode="Recycling" /> + <VirtualizingStackPanel IsVirtualizing="True" VirtualizationMode="Recycling" /> </ItemsPanelTemplate> </Setter.Value> </Setter> <Setter Property="Template"> <Setter.Value> - <ControlTemplate TargetType="ItemsControl"> - <Border BorderThickness="{TemplateBinding BorderThickness}" - BorderBrush="{TemplateBinding BorderBrush}" - Background="{TemplateBinding Background}"> + <ControlTemplate TargetType="{x:Type ListBox}"> + <Border BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}"> <touch:TouchScrollViewer CanContentScroll="True" Padding="{TemplateBinding Padding}" Focusable="False" |
