diff options
| author | Roy <Roy.mail.net@gmail.com> | 2022-12-08 17:05:57 +0200 |
|---|---|---|
| committer | Roy <Roy.mail.net@gmail.com> | 2022-12-08 17:05:57 +0200 |
| commit | d0a3f91acd04b65775afc615d426882d54dc4680 (patch) | |
| tree | 059021fc411e56a79ec6d036f29a4697b0f3de7e /Software/Visual_Studio | |
| parent | f9ac8ae24290aefd0be19d68de19669817422a88 (diff) | |
| parent | 0bcfaa9720fd7fdd55d94d0170489a0aab830410 (diff) | |
| download | Tango-d0a3f91acd04b65775afc615d426882d54dc4680.tar.gz Tango-d0a3f91acd04b65775afc615d426882d54dc4680.zip | |
Merged Manual Fine Tuning.
Diffstat (limited to 'Software/Visual_Studio')
20 files changed, 1872 insertions, 188 deletions
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Converters/ColorContrastConverter.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Converters/ColorContrastConverter.cs new file mode 100644 index 000000000..c6fe4512c --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Converters/ColorContrastConverter.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Data; +using System.Windows.Media; + +namespace Tango.PPC.Jobs.Converters +{ + public class ColorContrastConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value is SolidColorBrush) + { + var color = (value as SolidColorBrush).Color; + const double threshold = (3 * 255) / 2; + int sum = color.R + color.G + color.B; + return new SolidColorBrush(sum > threshold ? Colors.Black : Colors.White); + } + return DependencyProperty.UnsetValue; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Converters/DeltaLCHToTextConverter.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Converters/DeltaLCHToTextConverter.cs new file mode 100644 index 000000000..7d22245ed --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Converters/DeltaLCHToTextConverter.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; + +namespace Tango.PPC.Jobs.Converters +{ + class DeltaLCHToTextConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (parameter == null || value == null) + return ""; + + string type = parameter as string; + double number; + if (double.TryParse(value.ToString(), out number)) + { + if (type == "L") + { + if(number > 0 ) + return "Lighter"; + if( number < 0) + return "Darker"; + } + if (type == "C") + { + if (number > 0) + return "Brighter"; + if (number < 0) + return "Duller"; + } + if (type == "H") + { + if((number >0 && number <45) || (number >= 315 && number <360)) + return "Redder"; + if ((number >= 45 && number < 135) ) + return "Yellower"; + if ((number >= 135 && number < 225) ) + return "Greener"; + if ((number >= 225 && number < 315) ) + return "Bluer"; + + } + } + + return ""; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Converters/DoubleNullConverter.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Converters/DoubleNullConverter.cs new file mode 100644 index 000000000..a71eda720 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Converters/DoubleNullConverter.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.PPC.Jobs.Converters +{ + public class DoubleNullConverter : System.Windows.Data.IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return value is null ? 0 : double.TryParse(value.ToString(), out var valueResult) ? valueResult : 0; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionViewVM.cs index 2943e6054..85d0e0b86 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionViewVM.cs @@ -1041,7 +1041,7 @@ namespace Tango.PPC.Jobs.Dialogs { SelectedBrushStop.SaveLABBeforeChanges(); - VectorFineTuningDialogVM.Init( SelectedBrushStop, SelectedBrushStop.BestMatchL, SelectedBrushStop.BestMatchA, SelectedBrushStop.BestMatchB, SelectedBrushStop.Color); + VectorFineTuningDialogVM.Init( SelectedBrushStop, SelectedBrushStop.L, SelectedBrushStop.A, SelectedBrushStop.B, SelectedBrushStop.Color); IsOpenVectorFineTuningDialog = true; @@ -1081,7 +1081,7 @@ namespace Tango.PPC.Jobs.Dialogs public async Task<bool> NotifyAboutTrialsData() { var testColor = TrialsLogEngine.Default.GetByBrushStopGuid(SelectedBrushStop.Guid); - if (testColor != null && testColor.TrialslogList.Count > 1) + if (testColor != null && testColor.TrialslogList.Count > 0) { if (true == await NotificationProvider.ShowQuestion("The color correction is in progress, the trials data will be reset. Are you sure?")) { diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/VectorFineTuningDialog.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/VectorFineTuningDialog.xaml index 56e3ff211..93d42b610 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/VectorFineTuningDialog.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/VectorFineTuningDialog.xaml @@ -4,6 +4,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:Tango.PPC.Jobs.Dialogs" + xmlns:converters="clr-namespace:Tango.PPC.Jobs.Converters" xmlns:vm="clr-namespace:Tango.PPC.Jobs.Dialogs" xmlns:controls="clr-namespace:Tango.PPC.Jobs.Controls" xmlns:commonControls="clr-namespace:Tango.PPC.Common.Controls;assembly=Tango.PPC.Common" @@ -23,6 +24,9 @@ </ResourceDictionary.MergedDictionaries> <sharedConverters:DateTimeUTCToShortDateTimeConverter x:Key="DateTimeUTCToShortDateTimeConverter" /> <sharedConverters:GreaterThanToBooleanConverter x:Key="GreaterThanToBooleanConverter"/> + <converters:DoubleNullConverter x:Key="DoubleNullConverter" /> + <converters:DeltaLCHToTextConverter x:Key="DeltaLCHToTextConverter"/> + <converters:ColorContrastConverter x:Key="ColorContrastConverter" /> <BitmapImage x:Key="Close_mycolorsdlg" UriSource="../Images/ColorSelection/close_mycolorsdlg.png" /> <Style x:Key="GreyTextStyle" TargetType="TextBlock"> @@ -53,8 +57,39 @@ </Canvas>--> - <Grid Visibility="{Binding IsJobRunning,Converter={StaticResource BooleanToVisibilityInverseConverter}}" Margin="180 0 0 0"> - <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="{StaticResource TangoComboBoxTitleFontSize}" FontWeight="SemiBold">Color Correction Tool</TextBlock> + <Grid Visibility="{Binding IsJobRunning,Converter={StaticResource BooleanToVisibilityInverseConverter}}" > + <TextBlock Margin="180 0 0 0" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="{StaticResource TangoComboBoxTitleFontSize}" FontWeight="SemiBold">Color Correction Tool</TextBlock> + <touch:TouchButton Margin="30 0 0 0" Command="{Binding ByPassTestCommand}" CornerRadius="25" Width="180" Height="50" Content="BYPASS TEST" HorizontalAlignment="Left" BorderThickness="1" RippleBrush="{StaticResource TangoRippleDarkBrush}" EnableDropShadow="False" FontSize="{StaticResource TangoButtonFontSize}"> + <touch:TouchButton.Style > + <Style TargetType="touch:TouchButton" > + <Setter Property="Foreground" Value="{StaticResource TangoPrimaryAccentBrush}"></Setter> + <Setter Property="BorderBrush" Value="{StaticResource TangoPrimaryAccentBrush}"></Setter> + <Setter Property="TextElement.Foreground" Value="{StaticResource TangoPrimaryAccentBrush}"></Setter> + <Setter Property="Background" Value="Transparent"/> + <Setter Property="Visibility" Value="Collapsed"/> + <Style.Triggers> + <Trigger Property="IsEnabled" Value="False"> + <Setter Property="Foreground" Value="{StaticResource TangoDisabledForegroundBrush}"></Setter> + <Setter Property="TextElement.Foreground" Value="{StaticResource TangoDisabledForegroundBrush}"></Setter> + <Setter Property="BorderBrush" Value="{StaticResource TangoDisabledForegroundBrush}"></Setter> + </Trigger> + <DataTrigger Binding="{Binding IsJobRunning}" Value="True"> + <Setter Property="IsEnabled" Value="False"/> + <Setter Property="Foreground" Value="{StaticResource TangoDisabledForegroundBrush}"></Setter> + <Setter Property="TextElement.Foreground" Value="{StaticResource TangoDisabledForegroundBrush}"></Setter> + <Setter Property="BorderBrush" Value="{StaticResource TangoDisabledForegroundBrush}"></Setter> + </DataTrigger> + <MultiDataTrigger> + <MultiDataTrigger.Conditions> + <Condition Binding="{Binding ApplicationManager.IsInTechnicianMode}" Value="true"/> + <Condition Binding="{Binding IsJobRunning}" Value="False"/> + </MultiDataTrigger.Conditions> + <Setter Property="Visibility" Value="Visible"/> + </MultiDataTrigger> + </Style.Triggers> + </Style> + </touch:TouchButton.Style> + </touch:TouchButton> </Grid> <Grid Visibility="{Binding IsJobRunning,Converter={StaticResource BooleanToVisibilityConverter}, Delay=100}" Margin="40 0 0 0"> @@ -126,16 +161,29 @@ <Grid Background="{StaticResource TangoPrimaryBackgroundBrush}"> <Grid.RowDefinitions> - <RowDefinition Height="200"></RowDefinition> - <RowDefinition Height="1*"></RowDefinition> + <RowDefinition Height="Auto"></RowDefinition> + <RowDefinition Height="Auto"></RowDefinition> + <RowDefinition Height="Auto"></RowDefinition> </Grid.RowDefinitions> - <StackPanel Orientation="Vertical"> + <Grid> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="1*"/> + <ColumnDefinition Width="1*"/> + </Grid.ColumnDefinitions> + <Grid.RowDefinitions> + <RowDefinition Height="Auto"></RowDefinition> + <RowDefinition Height="30"></RowDefinition> + </Grid.RowDefinitions> <StackPanel Orientation="Horizontal" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="24 40 24 0"> <Image Stretch="Fill" Width="36" Height="36" RenderOptions.BitmapScalingMode="Fant" Source="../Images/JobView/color-length.png" HorizontalAlignment="Left"></Image> <TextBlock Margin="11 0 0 0" HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="{StaticResource TangoMessageBoxButtonFontSize}" Text="Target Color" /> </StackPanel> - <StackPanel Orientation="Horizontal" Margin="71 32 24 0"> - <Border Height="60" Width="60" HorizontalAlignment="Left" Background="{Binding ColorBrush}" CornerRadius="12"></Border> + <StackPanel Orientation="Horizontal" Margin="0 30 24 0" Grid.Column="1"> + <Border Height="60" Width="56" HorizontalAlignment="Left" Background="{Binding ColorBrush}" CornerRadius="12"> + <StackPanel Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Center" Visibility="{Binding IsOutOfGamut,Converter={StaticResource BooleanToVisibilityConverter}}"> + <Image Margin="0" Stretch="Fill" Width="24" RenderOptions.BitmapScalingMode="Fant" Source="../Images/ColorSelection/Exclamation.png" HorizontalAlignment="Center"></Image> + </StackPanel> + </Border> <UniformGrid Rows="1" Columns="3" Height="30" MinWidth="150" Margin="14 0 0 0"> <StackPanel Orientation="Horizontal"> <TextBlock Text="L" FontSize="{StaticResource TangoComboBoxItemFontSize}" VerticalAlignment="Center"/> @@ -157,8 +205,19 @@ </StackPanel> </UniformGrid> </StackPanel> - </StackPanel> - <Grid Grid.Row="1"> + <Rectangle Height="1" Fill="{StaticResource TangoDividerBrush}" Grid.ColumnSpan="2" Grid.Row="1" VerticalAlignment="Center" Margin="0 0 0 0"></Rectangle> + + </Grid> + <Grid Grid.Row="1" x:Name="corrections" Margin="0 0 0 0"> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="1*"/> + </Grid.ColumnDefinitions> + <Grid.RowDefinitions> + <RowDefinition Height="Auto"/> + <RowDefinition Height="60.6"/> + <RowDefinition Height="29.4"/> + <RowDefinition Height="1*"/> + </Grid.RowDefinitions> <StackPanel Orientation="Horizontal" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="24 10 24 0"> <Image Stretch="Fill" Width="36" Height="36" RenderOptions.BitmapScalingMode="Fant" Source="../Images/ColorSelection/CorrectionTrial.png" HorizontalAlignment="Left"></Image> <TextBlock Margin="11 0 0 0" HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="{StaticResource TangoMessageBoxButtonFontSize}" > @@ -167,65 +226,297 @@ <Run Text="{Binding TrialNumber, Mode=OneWay}" Foreground="{StaticResource TangoGrayTextBrush}"></Run> </TextBlock> </StackPanel> - <Grid Margin="78 70 0 0"> - <Grid.ColumnDefinitions> - <ColumnDefinition Width="1*"></ColumnDefinition> - <ColumnDefinition Width="311"></ColumnDefinition> - </Grid.ColumnDefinitions> - <UniformGrid Rows="3" Columns="1" Height="176" VerticalAlignment="Top"> - <UniformGrid.Style> - <Style TargetType="UniformGrid"> - <Setter Property="IsEnabled" Value="True"/> - <Style.Triggers> - <DataTrigger Binding="{Binding IsDisableInputLAB}" Value="True"> - <Setter Property="IsEnabled" Value="False"/> - </DataTrigger> - </Style.Triggers> - </Style> - </UniformGrid.Style> - <StackPanel Orientation="Horizontal"> - <TextBlock Text="L" FontSize="{StaticResource TangoComboBoxItemFontSize}" FontWeight="SemiBold" VerticalAlignment="Center" /> - <touch:TouchNumericUpDownConrol Margin="30 0 0 0" NumericPartWidth="94.0" Width="200" Height="40" HorizontalAlignment="Stretch" BorderThickness="0.8" MaxValue="100" MinValue="0" Value="{Binding MeasuredL, Delay=1000}" FontSize="{StaticResource TangoButtonFontSize}" FontWeight="Bold"/> - </StackPanel> - <StackPanel Orientation="Horizontal"> - <TextBlock Text="a" FontSize="{StaticResource TangoComboBoxItemFontSize}" FontWeight="SemiBold" VerticalAlignment="Center"/> - <touch:TouchNumericUpDownConrol Margin="30 0 0 0" NumericPartWidth="94.0" Width="200" Height="40" HorizontalAlignment="Stretch" BorderThickness="0.8" MaxValue="127" MinValue="-128" Value="{Binding MeasuredA, Delay=1000}" FontSize="{StaticResource TangoButtonFontSize}" FontWeight="Bold"/> - </StackPanel> - <StackPanel Orientation="Horizontal"> - <TextBlock Text="b" FontSize="{StaticResource TangoComboBoxItemFontSize}" FontWeight="SemiBold" VerticalAlignment="Center"/> - <touch:TouchNumericUpDownConrol Margin="30 0 0 0" NumericPartWidth="94.0" Width="200" Height="40" HorizontalAlignment="Stretch" BorderThickness="0.8" MaxValue="127" MinValue="-128" Value="{Binding MeasuredB, Delay=1000}" FontSize="{StaticResource TangoButtonFontSize}" FontWeight="Bold"/> - </StackPanel> - </UniformGrid> - <!--<UniformGrid Grid.Column="1" x:Name="cmyk_grid" Margin="0 16 0 0" Rows="4" Columns="1" HorizontalAlignment="Left" Height=" 100" VerticalAlignment="Top"> - <StackPanel Orientation="Horizontal"> - <TextBlock FontSize="{StaticResource TangoSmallFontSize}" Width="12" HorizontalAlignment="Center" VerticalAlignment="Center">C</TextBlock> - <Rectangle Margin="10 0 0 0" Width="{Binding Cyan, Mode=OneWay}" Height="12" Fill="#00C3FF"/> - <TextBlock FontSize="{StaticResource TangoSmallFontSizeBar}" Margin="10 0 0 0" Text="{Binding Cyan, StringFormat={}{0:0.##}}" VerticalAlignment="Center"></TextBlock> - </StackPanel> - <StackPanel Orientation="Horizontal" Margin="0 10 0 0"> - <TextBlock FontSize="{StaticResource TangoSmallFontSize}" Width="12" HorizontalAlignment="Center">M</TextBlock> - <Rectangle Margin="10 0 0 0" Width="{Binding Magenta, Mode=OneWay}" Height="12" Fill="#FF00B3"/> - <TextBlock Margin="10 0 0 0" Text="{Binding Magenta, StringFormat={}{0:0.##}}" FontSize="{StaticResource TangoSmallFontSizeBar}" ></TextBlock> - </StackPanel> - <StackPanel Orientation="Horizontal" Margin="0 10 0 0"> - <TextBlock FontSize="{StaticResource TangoSmallFontSize}" Width="12" HorizontalAlignment="Center">Y</TextBlock> - <Rectangle Margin="10 0 0 0" Width="{Binding Yellow, Mode=OneWay}" Height="12" Fill="#FFE500"/> - <TextBlock Margin="10 0 0 0" Text="{Binding Yellow, StringFormat={}{0:0.##}}" FontSize="{StaticResource TangoSmallFontSizeBar}" ></TextBlock> + <touch:TouchNavigationLinks Grid.Row="1" BorderBrush="{StaticResource TangoDividerBrush}" BorderThickness="0 0 0 3" x:Name="navigationCSTLinks" SelectionChanged="TouchNavigationLinks_SelectionChanged" HorizontalContentAlignment="Center" + SelectedIndex="{Binding SelectedTabIndex,Mode=TwoWay}" VerticalAlignment="Bottom" Margin="0,0,0,30" Padding="40 0 40 0" + FontSize="{StaticResource TangoNavigationLinksFontSize}" Grid.RowSpan="2" > + + <TextBlock HorizontalAlignment="Center" >Automatic</TextBlock> + <TextBlock HorizontalAlignment="Center" >Manual</TextBlock> + <touch:TouchNavigationLinks.Style> + <Style TargetType="{x:Type touch:TouchNavigationLinks}"> + <Setter Property="ItemsPanel"> + <Setter.Value> + <ItemsPanelTemplate> + <StackPanel Orientation="Horizontal"/> + </ItemsPanelTemplate> + </Setter.Value> + </Setter> + </Style> + </touch:TouchNavigationLinks.Style> + + </touch:TouchNavigationLinks> + + <Grid Grid.Row="3" Margin="40 0 20 0"> + <Grid Visibility="{Binding IsManualFineTuning, Converter={StaticResource BooleanToVisibilityInverseConverter}}" Margin="0 0 24 0" x:Name="Automatic"> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="1*"/> + <ColumnDefinition Width="1*"/> + </Grid.ColumnDefinitions> + + <StackPanel Orientation="Vertical"> + <TextBlock FontSize="{StaticResource TangoComboBoxItemFontSize}">Enter Measurement Result:</TextBlock> + <UniformGrid Rows="3" Columns="1" Height="200" VerticalAlignment="Top" Width="Auto" HorizontalAlignment="Center" Margin="0 10 40 0"> + <StackPanel Orientation="Horizontal"> + <TextBlock Text="L" FontSize="{StaticResource TangoComboBoxItemFontSize}" FontWeight="SemiBold" VerticalAlignment="Center" /> + <touch:TouchNumericTextBox Margin="20 0 20 0" Width="80" Height="40" HorizontalAlignment="Stretch" BorderThickness="0.8" Maximum="100" Minimum="0" Value="{Binding MeasuredL, Delay=1000}" FontSize="{StaticResource TangoButtonFontSize}" FontWeight="Bold" BorderBrush="{StaticResource TangoDividerBrush}" HideUnderline="True" HasDecimalPoint="True" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/> + </StackPanel> + <StackPanel Orientation="Horizontal" VerticalAlignment="Center"> + <TextBlock Text="a" FontSize="{StaticResource TangoComboBoxItemFontSize}" FontWeight="SemiBold" VerticalAlignment="Center"/> + <touch:TouchNumericTextBox Margin="20 0 20 0" Width="80" Height="40" HorizontalAlignment="Stretch" BorderThickness="0.8" Maximum="127" Minimum="-128" Value="{Binding MeasuredA, Delay=1000}" FontSize="{StaticResource TangoButtonFontSize}" FontWeight="Bold" VerticalAlignment="Top" BorderBrush="{StaticResource TangoDividerBrush}" HideUnderline="True" HasDecimalPoint="True" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/> + </StackPanel> + <StackPanel Orientation="Horizontal"> + <TextBlock Text="b" FontSize="{StaticResource TangoComboBoxItemFontSize}" FontWeight="SemiBold" VerticalAlignment="Center"/> + <touch:TouchNumericTextBox Margin="20 0 20 0" Width="80" Height="40" HorizontalAlignment="Stretch" BorderThickness="0.8" Maximum="127" Minimum="-128" Value="{Binding MeasuredB, Delay=1000}" FontSize="{StaticResource TangoButtonFontSize}" FontWeight="Bold" BorderBrush="{StaticResource TangoDividerBrush}" HideUnderline="True" HasDecimalPoint="True" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/> + </StackPanel> + </UniformGrid> + <touch:TouchCheckBox Margin="0 30 0 0" IsChecked="{Binding CorrectHue, Mode=TwoWay}" FontSize="{StaticResource TangoButtonFontSize}" FontWeight="Normal" BorderBrush="{StaticResource TangoPrimaryAccentBrush}">Correct Only Hue</touch:TouchCheckBox> </StackPanel> - <StackPanel Orientation="Horizontal" Margin="0 10 0 0"> - <TextBlock FontSize="{StaticResource TangoSmallFontSize}" Width="12" HorizontalAlignment="Center">K</TextBlock> - <Rectangle Margin="10 0 0 0" Width="{Binding Black, Mode=OneWay}" Height="12" Fill="black"/> - <TextBlock Margin="10 0 0 0" Text="{Binding Black, StringFormat={}{0:0.##}}" FontSize="{StaticResource TangoSmallFontSizeBar}" Foreground="{StaticResource TangoKeyboardKeyDarkTextBrush}"></TextBlock> + + <StackPanel Orientation="Vertical" Grid.Column="1"> + <TextBlock FontSize="{StaticResource TangoComboBoxItemFontSize}">Target Vs Results:</TextBlock> + <UniformGrid Grid.Column="1" Columns="4" Rows="1" Height="Auto" VerticalAlignment="Top" Width="Auto" Margin="0 20 0 0"> + <StackPanel Orientation="Vertical"> + <StackPanel Orientation="Horizontal"> + <Polygon Points="7.5,0 15,15, 0,15" Stroke="Black" Fill="Transparent" Margin=" 0 4 0 0"/> + <TextBlock Text="E" FontSize="{StaticResource TangoComboBoxItemFontSize}" FontWeight="SemiBold" VerticalAlignment="Center" Margin="7 0 0 0"/> + </StackPanel> + <TextBlock IsHitTestVisible="False" Text="{Binding DeltaE, StringFormat=0.00, Converter={StaticResource DoubleNullConverter}}" FontSize="{StaticResource TangoDefaultFontSize}" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="0 20 0 0"> + <TextBlock.Style> + <Style TargetType="TextBlock"> + <Setter Property="Foreground" Value="{StaticResource TangoDarkForegroundBrush}"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding DeltaE, Converter={StaticResource SmallerThanToBooleanConverter}, ConverterParameter=2}" Value="True"> + + <Setter Property="Foreground" Value="{StaticResource TangoGreenBrush}"></Setter> + + </DataTrigger> + </Style.Triggers> + </Style> + </TextBlock.Style> + </TextBlock> + </StackPanel> + + <StackPanel Orientation="Vertical" Margin="0 0 0 0"> + <StackPanel Orientation="Horizontal"> + <Polygon Points="7.5,0 15,15, 0,15" Stroke="Black" Fill="Transparent" Margin=" 0 4 0 0"/> + <TextBlock Text="L" FontSize="{StaticResource TangoComboBoxItemFontSize}" FontWeight="SemiBold" VerticalAlignment="Center" Margin="7 0 0 0"/> + </StackPanel> + <TextBlock IsHitTestVisible="False" Text="{Binding DL, StringFormat=0.00, Converter={StaticResource DoubleNullConverter}}" FontSize="{StaticResource TangoDefaultFontSize}" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="0 20 0 0"/> + <TextBlock Text="{Binding DL, Converter={StaticResource DeltaLCHToTextConverter}, ConverterParameter=L}" FontSize="{StaticResource TangoSmallFontSize}" VerticalAlignment="Center" Margin="0 20 0 0"/> + </StackPanel> + + <StackPanel Orientation="Vertical"> + <StackPanel Orientation="Horizontal"> + <Polygon Points="7.5,0 15,15, 0,15" Stroke="Black" Fill="Transparent" Margin=" 0 4 0 0"/> + <TextBlock Text="C" FontSize="{StaticResource TangoComboBoxItemFontSize}" FontWeight="SemiBold" VerticalAlignment="Center" Margin="7 0 0 0"/> + </StackPanel> + <TextBlock IsHitTestVisible="False" Text="{Binding DC, StringFormat=0.00, Converter={StaticResource DoubleNullConverter}}" FontSize="{StaticResource TangoDefaultFontSize}" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="0 20 0 0"/> + <TextBlock Text="{Binding DC, Converter={StaticResource DeltaLCHToTextConverter}, ConverterParameter=C}" FontSize="{StaticResource TangoSmallFontSize}" VerticalAlignment="Center" Margin="0 20 0 0"/> + </StackPanel> + + <StackPanel Orientation="Vertical"> + <StackPanel Orientation="Horizontal"> + <Polygon Points="7.5,0 15,15, 0,15" Stroke="Black" Fill="Transparent" Margin=" 0 4 0 0"/> + <TextBlock Text="H" FontSize="{StaticResource TangoComboBoxItemFontSize}" FontWeight="SemiBold" VerticalAlignment="Center" Margin="7 0 0 0"/> + </StackPanel> + <TextBlock IsHitTestVisible="False" Text="{Binding DH, StringFormat=0.00, Converter={StaticResource DoubleNullConverter}}" FontSize="{StaticResource TangoDefaultFontSize}" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="0 20 0 0"/> + <TextBlock Text="{Binding DH, Converter={StaticResource DeltaLCHToTextConverter}, ConverterParameter=H}" FontSize="{StaticResource TangoSmallFontSize}" VerticalAlignment="Center" Margin="0 20 0 0"/> + + </StackPanel> + </UniformGrid> </StackPanel> - </UniformGrid>--> - </Grid> + </Grid> + <Grid x:Name="visualCorrection" Visibility="{Binding IsManualFineTuning, Converter={StaticResource BooleanToVisibilityConverter}}" > + <Grid Margin="0 -20 5 40"> + <Grid.RowDefinitions> + <RowDefinition Height="Auto"/> + <RowDefinition Height="30"/> + <RowDefinition Height="1*"/> + </Grid.RowDefinitions> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="1.4*"/> + <ColumnDefinition Width="1*"/> + </Grid.ColumnDefinitions> + <StackPanel Orientation="Vertical" Grid.Column="0"> + <TextBlock FontSize="{StaticResource TangoComboBoxItemFontSize}" FontWeight="SemiBold" >Enter Measurement Result ( Optional):</TextBlock> + <UniformGrid Rows="1" Columns="3" Height="Auto" VerticalAlignment="Top" Width="Auto" HorizontalAlignment="Left" Margin="0 20 0 0"> + <StackPanel Orientation="Vertical" VerticalAlignment="Center"> + <TextBlock Text="L" FontSize="{StaticResource TangoComboBoxItemFontSize}" FontWeight="Bold" VerticalAlignment="Center" Margin="10 0 0 0"/> + <touch:TouchNumericTextBox Margin="0 10 5 0" Width="80" Height="40" HorizontalAlignment="Stretch" BorderThickness="0.8" BorderBrush="{StaticResource TangoDividerBrush}" Maximum="100" Minimum="0" Value="{Binding MeasuredL, Delay=1000}" FontSize="{StaticResource TangoButtonFontSize}" FontWeight="Bold" HideUnderline="True" HasDecimalPoint="True" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/> + </StackPanel> + <StackPanel Orientation="Vertical" VerticalAlignment="Center"> + <TextBlock Text="a" FontSize="{StaticResource TangoComboBoxItemFontSize}" FontWeight="Bold" VerticalAlignment="Center" Margin="10 0 0 0"/> + <touch:TouchNumericTextBox Margin="0 10 5 0" Width="80" Height="40" HorizontalAlignment="Stretch" BorderThickness="0.8" BorderBrush="{StaticResource TangoDividerBrush}" Maximum="127" Minimum="-128" Value="{Binding MeasuredA, Delay=1000}" FontSize="{StaticResource TangoButtonFontSize}" FontWeight="Bold" HideUnderline="True" HasDecimalPoint="True" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/> + </StackPanel> + <StackPanel Orientation="Vertical"> + <TextBlock Text="b" FontSize="{StaticResource TangoComboBoxItemFontSize}" FontWeight="Bold" VerticalAlignment="Center" Margin="10 0 0 0"/> + <touch:TouchNumericTextBox Margin="0 10 5 0" Width="80" Height="40" HorizontalAlignment="Stretch" BorderThickness="0.8" BorderBrush="{StaticResource TangoDividerBrush}" Maximum="127" Minimum="-128" Value="{Binding MeasuredB, Delay=1000}" FontSize="{StaticResource TangoButtonFontSize}" FontWeight="Bold" HideUnderline="True" HasDecimalPoint="True" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/> + </StackPanel> + </UniformGrid> + </StackPanel> + <StackPanel Orientation="Vertical" Grid.Column="1"> + <TextBlock FontSize="{StaticResource TangoComboBoxItemFontSize}" >Target Vs Results:</TextBlock> + <UniformGrid Grid.Column="1" Columns="4" Rows="1" Height="Auto" VerticalAlignment="Top" Width="Auto" Margin="0 20 0 0"> + <StackPanel Orientation="Vertical"> + <StackPanel Orientation="Horizontal"> + <Polygon Points="7.5,0 15,15, 0,15" Stroke="Black" Fill="Transparent" Margin=" 0 4 0 0"/> + <TextBlock Text="E" FontSize="{StaticResource TangoComboBoxItemFontSize}" FontWeight="SemiBold" VerticalAlignment="Center" Margin="7 0 0 0"/> + </StackPanel> + <TextBlock IsHitTestVisible="False" Text="{Binding DeltaE, StringFormat=0.00, Converter={StaticResource DoubleNullConverter}}" FontSize="{StaticResource TangoDefaultFontSize}" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="0 20 0 0"> + <TextBlock.Style> + <Style TargetType="TextBlock"> + <Setter Property="Foreground" Value="{StaticResource TangoDarkForegroundBrush}"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding DeltaE, Converter={StaticResource SmallerThanToBooleanConverter}, ConverterParameter=2}" Value="True"> + + <Setter Property="Foreground" Value="{StaticResource TangoGreenBrush}"></Setter> + + </DataTrigger> + </Style.Triggers> + </Style> + </TextBlock.Style> + </TextBlock> + </StackPanel> + + <StackPanel Orientation="Vertical" Margin="0 0 0 0"> + <StackPanel Orientation="Horizontal"> + <Polygon Points="7.5,0 15,15, 0,15" Stroke="Black" Fill="Transparent" Margin=" 0 4 0 0"/> + <TextBlock Text="L" FontSize="{StaticResource TangoComboBoxItemFontSize}" FontWeight="SemiBold" VerticalAlignment="Center" Margin="7 0 0 0"/> + </StackPanel> + <TextBlock IsHitTestVisible="False" Text="{Binding DL, StringFormat=0.00, Converter={StaticResource DoubleNullConverter}}" FontSize="{StaticResource TangoDefaultFontSize}" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="0 20 0 0"/> + <TextBlock Text="{Binding DL, Converter={StaticResource DeltaLCHToTextConverter}, ConverterParameter=L}" FontSize="{StaticResource TangoSmallFontSize}" VerticalAlignment="Center" Margin="0 20 0 0"/> + </StackPanel> + + <StackPanel Orientation="Vertical"> + <StackPanel Orientation="Horizontal"> + <Polygon Points="7.5,0 15,15, 0,15" Stroke="Black" Fill="Transparent" Margin=" 0 4 0 0"/> + <TextBlock Text="C" FontSize="{StaticResource TangoComboBoxItemFontSize}" FontWeight="SemiBold" VerticalAlignment="Center" Margin="7 0 0 0"/> + </StackPanel> + <TextBlock IsHitTestVisible="False" Text="{Binding DC, StringFormat=0.00, Converter={StaticResource DoubleNullConverter}}" FontSize="{StaticResource TangoDefaultFontSize}" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="0 20 0 0"/> + <TextBlock Text="{Binding DC, Converter={StaticResource DeltaLCHToTextConverter}, ConverterParameter=C}" FontSize="{StaticResource TangoSmallFontSize}" VerticalAlignment="Center" Margin="0 20 0 0"/> + </StackPanel> + + <StackPanel Orientation="Vertical"> + <StackPanel Orientation="Horizontal"> + <Polygon Points="7.5,0 15,15, 0,15" Stroke="Black" Fill="Transparent" Margin=" 0 4 0 0"/> + <TextBlock Text="H" FontSize="{StaticResource TangoComboBoxItemFontSize}" FontWeight="SemiBold" VerticalAlignment="Center" Margin="7 0 0 0"/> + </StackPanel> + <TextBlock IsHitTestVisible="False" Text="{Binding DH, StringFormat=0.00, Converter={StaticResource DoubleNullConverter}}" FontSize="{StaticResource TangoDefaultFontSize}" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="0 20 0 0"/> + <TextBlock Text="{Binding DH, Converter={StaticResource DeltaLCHToTextConverter}, ConverterParameter=H}" FontSize="{StaticResource TangoSmallFontSize}" VerticalAlignment="Center" Margin="0 20 0 0"/> + </StackPanel> + </UniformGrid> + </StackPanel> + <Rectangle Height="1" Fill="{StaticResource TangoDividerBrush}" Grid.ColumnSpan="2" Grid.Row="1" VerticalAlignment="Center" Margin="0 0 0 0"></Rectangle> + <DockPanel Grid.Row="2" Grid.ColumnSpan="2"> + <StackPanel Orientation="Vertical" Margin="0 0 0 0"> + <TextBlock FontSize="{StaticResource TangoComboBoxItemFontSize}" FontWeight="SemiBold" >Enter Manual Correction:</TextBlock> + <Grid Height="Auto" Margin="0 10 0 0"> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="55"/> + <ColumnDefinition Width="1*"/> + <ColumnDefinition Width="55"/> + </Grid.ColumnDefinitions> + <Border BorderBrush="Transparent" Background="{Binding VisualCorrectionModel.MinLightness.ColorBrush}" CornerRadius="8" Margin="0 25 0 0" Height="55" /> + + <StackPanel Grid.Column="1" Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Top"> + <TextBlock Text="Lightness:" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0 0 0 5" FontSize="{StaticResource TangoSmallFontSize}"></TextBlock> + <touch:TouchNumericUpDownConrol Margin="10 16 10 0" Height="35" NumericPartWidth="50" HorizontalAlignment="Center" BorderThickness="2" MaxValue="6" MinValue="-6" Style="{StaticResource TouchNumericBorderUpDownControl}" Step="0.5" Value="{Binding LightnessOffset, Mode=TwoWay}" VerticalAlignment="Center" /> + </StackPanel> + <Border BorderBrush="Transparent" Background="{Binding VisualCorrectionModel.MaxLightness.ColorBrush}" CornerRadius="8" Grid.Column="2" Height="55" Margin="0 25 0 0" /> + + </Grid> + <Grid Height="Auto" Margin="0 0 0 0"> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="55"/> + <ColumnDefinition Width="1*"/> + <ColumnDefinition Width="55"/> + </Grid.ColumnDefinitions> + <Border BorderBrush="Transparent" Background="{Binding VisualCorrectionModel.MinChroma.ColorBrush}" CornerRadius="8" Margin="0 25 0 0" Height="55"/> + + <StackPanel Grid.Column="1" Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Top"> + <TextBlock Text="Chroma:" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0 0 0 5" FontSize="{StaticResource TangoSmallFontSize}"></TextBlock> + <touch:TouchNumericUpDownConrol Margin="10 16 10 0" Padding="0" Height="35" NumericPartWidth="50" HorizontalAlignment="Center" BorderThickness="2" MaxValue="6" MinValue="-6" Style="{StaticResource TouchNumericBorderUpDownControl}" Step="0.5" Value="{Binding ChromaOffset, Mode=TwoWay}" VerticalAlignment="Center"/> + </StackPanel> + <Border BorderBrush="Transparent" Background="{Binding VisualCorrectionModel.MaxChroma.ColorBrush}" CornerRadius="8" Grid.Column="2" Height="55" Margin="0 25 0 0" /> + </Grid> + <Grid Height="Auto" Margin="0 0 0 0"> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="55"/> + <ColumnDefinition Width="1*"/> + <ColumnDefinition Width="55"/> + </Grid.ColumnDefinitions> + <Border BorderBrush="Transparent" Background="{Binding VisualCorrectionModel.MinHue.ColorBrush}" CornerRadius="8" Margin="0 25 0 0" Height="55" /> + <StackPanel Grid.Column="1" Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Top"> + <TextBlock Text="Hue:" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0 0 0 0" FontSize="{StaticResource TangoSmallFontSize}"></TextBlock> + <touch:TouchNumericUpDownConrol Margin="10 20 10 0" Height="35" NumericPartWidth="50" HorizontalAlignment="Center" BorderThickness="2" MaxValue="6" MinValue="-6" Style="{StaticResource TouchNumericBorderUpDownControl}" Step="0.5" Value="{Binding HueOffset, Mode=TwoWay}" VerticalAlignment="Center"/> + </StackPanel> + <Border BorderBrush="Transparent" Background="{Binding VisualCorrectionModel.MaxHue.ColorBrush}" CornerRadius="8" Grid.Column="2" Height="55" Margin="0 25 0 0" /> + </Grid> + </StackPanel> + + <Grid Height="Auto" Margin="40 0 0 0" VerticalAlignment="Center" HorizontalAlignment="Stretch"> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="1*"/> + <ColumnDefinition Width="1.8*"/> + </Grid.ColumnDefinitions> + <Grid.RowDefinitions> + <RowDefinition Height="20"/> + <RowDefinition Height="1*"/> + </Grid.RowDefinitions> + <TextBlock FontSize="{StaticResource TangoComboBoxItemFontSize}" FontWeight="SemiBold" Grid.ColumnSpan="2" VerticalAlignment="Center">Adjustment Preview:</TextBlock> + <StackPanel Orientation="Vertical" Grid.ColumnSpan="2" Grid.Row="1" Margin="0 10 0 0"> + <TextBlock FontSize="{StaticResource TangoSmallFontSize}" FontWeight="SemiBold" Margin="10 0 0 -5" >Previous</TextBlock> + <Border Grid.Row="1" Height="220" Margin="0 10 0 0" BorderBrush="{StaticResource TangoGrayBrush}" BorderThickness="1" Background="{Binding VisualCorrectionModel.SourceColorBrush}" CornerRadius="12" > + <UniformGrid Rows="3" Columns="1" VerticalAlignment="Bottom" Background="Transparent"> + <TextBlock FontWeight="Medium" Margin="10 10 0 0" VerticalAlignment="Center" Foreground="{Binding VisualCorrectionModel.ManualColorBrush, Converter={StaticResource ColorContrastConverter}}" FontSize="{StaticResource TangoSmallFontSize}"> + <Run Text="L:" ></Run> + <Run Text="{Binding VisualCorrectionModel.SourceL, StringFormat=0.##}"></Run> + </TextBlock> + <TextBlock FontWeight="Medium" Margin="10 5 0 0" VerticalAlignment="Center" Foreground="{Binding VisualCorrectionModel.ManualColorBrush, Converter={StaticResource ColorContrastConverter}}" FontSize="{StaticResource TangoSmallFontSize}"> + <Run Text="a:" ></Run> + <Run Text="{Binding VisualCorrectionModel.SourceA, StringFormat=0.##}" ></Run> + </TextBlock> + <TextBlock FontWeight="Medium" Margin="10 5 0 10" VerticalAlignment="Center" Foreground="{Binding VisualCorrectionModel.ManualColorBrush, Converter={StaticResource ColorContrastConverter}}" FontSize="{StaticResource TangoSmallFontSize}"> + <Run Text="b:"></Run> + <Run Text="{Binding VisualCorrectionModel.SourceB, StringFormat=0.##}"></Run> + </TextBlock> + </UniformGrid> + </Border> + </StackPanel> + <StackPanel Orientation="Vertical" Grid.Column="1" Grid.Row="1" Margin="0 10 0 0"> + <TextBlock FontSize="{StaticResource TangoSmallFontSize}" FontWeight="SemiBold" Margin="10 0 0 -5" HorizontalAlignment="Center" >New</TextBlock> + + <Border Grid.Row="1" Height="220" Margin="0 10 0 0" CornerRadius="12" BorderThickness="1" BorderBrush="{StaticResource TangoGrayBrush}" Background="{Binding VisualCorrectionModel.ManualColorBrush}" > + <UniformGrid Rows="3" Columns="1" VerticalAlignment="Bottom" Background="Transparent"> + <TextBlock FontWeight="Medium" Margin="10 10 0 0" VerticalAlignment="Center" Foreground="{Binding VisualCorrectionModel.ManualColorBrush, Converter={StaticResource ColorContrastConverter}}" FontSize="{StaticResource TangoSmallFontSize}"> + <Run Text="L:" ></Run> + <Run Text="{Binding VisualCorrectionModel.L, StringFormat=0.##}"></Run> + </TextBlock> + <TextBlock FontWeight="Medium" Margin="10 5 0 0" VerticalAlignment="Center" Foreground="{Binding VisualCorrectionModel.ManualColorBrush, Converter={StaticResource ColorContrastConverter}}" FontSize="{StaticResource TangoSmallFontSize}"> + <Run Text="a:" ></Run> + <Run Text="{Binding VisualCorrectionModel.A, StringFormat=0.##}" ></Run> + </TextBlock> + <TextBlock FontWeight="Medium" Margin="10 5 0 10" VerticalAlignment="Center" Foreground="{Binding VisualCorrectionModel.ManualColorBrush, Converter={StaticResource ColorContrastConverter}}" FontSize="{StaticResource TangoSmallFontSize}"> + <Run Text="b:"></Run> + <Run Text="{Binding VisualCorrectionModel.B, StringFormat=0.##}"></Run> + </TextBlock> + </UniformGrid> + </Border> + </StackPanel> + </Grid> + </DockPanel> + </Grid> + </Grid> + </Grid> </Grid> + + </Grid> - <Border BorderThickness="0" Grid.Row="1"> + <Border BorderThickness="0" Grid.RowSpan="01" VerticalAlignment="Bottom"> <!--<Border.Style > <Style TargetType="Border"> <Setter Property="IsEnabled" Value="True"/> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/VectorFineTuningDialog.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/VectorFineTuningDialog.xaml.cs index cc4d9d424..01c4a2193 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/VectorFineTuningDialog.xaml.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/VectorFineTuningDialog.xaml.cs @@ -29,5 +29,10 @@ namespace Tango.PPC.Jobs.Dialogs _vm = DataContext as VectorFineTuningDialogVM; }; } + + private void TouchNavigationLinks_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + + } } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/VectorFineTuningDialogVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/VectorFineTuningDialogVM.cs index 752ae08b2..85505379e 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/VectorFineTuningDialogVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/VectorFineTuningDialogVM.cs @@ -1,4 +1,6 @@ using Newtonsoft.Json; +using Colourful; +using Colourful.Conversion; using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -18,10 +20,13 @@ using Tango.BL.FineTuning; using Tango.Core; using Tango.Core.Commands; using Tango.Core.DI; +using Tango.Core.Helpers; +using Tango.Documents; using Tango.Explorer; using Tango.Integration.Operation; using Tango.PDF; using Tango.PPC.Common; +using Tango.PPC.Common.Application; using Tango.PPC.Common.Connection; using Tango.PPC.Common.Navigation; using Tango.PPC.Common.Notifications; @@ -29,6 +34,7 @@ using Tango.PPC.Common.Notifications.NotificationItems; using Tango.PPC.Common.Printing; using Tango.PPC.Common.Storage; using Tango.PPC.Jobs.ColorCorrectionTool; +using Tango.PPC.Jobs.FineTuning; using Tango.PPC.Jobs.Models; using Tango.PPC.Jobs.Reports; using Tango.PPC.Storage; @@ -82,8 +88,28 @@ namespace Tango.PPC.Jobs.Dialogs [TangoInject] public IStorageProvider StorageProvider { get; set; } + [TangoInject] + public IPPCApplicationManager ApplicationManager { get; set; } + public BrushStopModel BrushStopModel { get; set; } + private bool _isOutOfGamut; + /// <summary> + /// Gets or sets a value indicating whether this instance is out of gamut. + /// </summary> + public bool IsOutOfGamut + { + get { return _isOutOfGamut; } + set + { + if (_isOutOfGamut != value) + { + _isOutOfGamut = value; + RaisePropertyChangedAuto(); + } + } + } + private System.Windows.Media.Color _targetcolor; public System.Windows.Media.Color TargetColor @@ -170,7 +196,7 @@ namespace Tango.PPC.Jobs.Dialogs protected Double? _measuredL; /// <summary> - /// Gets or sets the BrushStopModel l. + /// Gets or sets the Measured l. /// </summary> public Double? MeasuredL @@ -196,7 +222,7 @@ namespace Tango.PPC.Jobs.Dialogs protected Double? _measuredA; /// <summary> - /// Gets or sets the BrushStopModel a. + /// Gets or sets the Measured a. /// </summary> public Double? MeasuredA { @@ -220,7 +246,7 @@ namespace Tango.PPC.Jobs.Dialogs protected Double? _measuredB; /// <summary> - /// Gets or sets the BrushStopModel b. + /// Gets or sets the Measured b. /// </summary> public Double? MeasuredB { @@ -240,7 +266,100 @@ namespace Tango.PPC.Jobs.Dialogs } } } + + protected Double? _dL; + /// <summary> + /// Gets or sets the delta L + /// </summary> + public Double? DL + { + get { return _dL; } + set + { + if (_dL != value) + { + _dL = value; + if (ActiveLogModel != null) + ActiveLogModel.dL = _dL == null? 0: (double)_dL; + RaisePropertyChangedAuto(); + } + } + } + + protected Double? _dC; + /// <summary> + /// Gets or sets the delta C + /// </summary> + public Double? DC + { + get { return _dC; } + set + { + if (_dC != value) + { + _dC = value; + if (ActiveLogModel != null) + ActiveLogModel.dC = _dC == null ? 0 : (double)_dC; + RaisePropertyChangedAuto(); + } + } + } + + protected Double? _dH; + /// <summary> + /// Gets or sets the delta Hue + /// </summary> + public Double? DH + { + get { return _dH; } + set + { + if (_dH != value) + { + _dH = value; + if (ActiveLogModel != null) + ActiveLogModel.dH = _dH == null ? 0 : (double)_dH; + RaisePropertyChangedAuto(); + } + } + } + + protected Double? _deltaE; + /// <summary> + /// Gets or sets the delta Hue + /// </summary> + public Double? DeltaE + { + get { return _deltaE; } + set + { + if (_deltaE != value) + { + _deltaE = value; + RaisePropertyChangedAuto(); + } + } + } + + private bool _CorrectOnlyHue; + + public bool CorrectOnlyHue + { + get { return _CorrectOnlyHue; } + set + { + if(_CorrectOnlyHue != value) + { + _CorrectOnlyHue = value; + if (ActiveLogModel != null) + ActiveLogModel.CorrectOnlyHue = _CorrectOnlyHue; + VectorCorrection(); + RaisePropertyChangedAuto(); + } + } + } + protected Double _cyan; /// <summary> @@ -432,12 +551,120 @@ namespace Tango.PPC.Jobs.Dialogs } } + private bool _isManualFineTuning; + /// <summary> + /// Gets or sets a value indicating whether this instance is vector fine tuning. + /// </summary> + /// <value> + /// <c>true</c> if this instance is Automatic tab selected; otherwise, manual . + /// </value> + public bool IsManualFineTuning + { + get { return _isManualFineTuning; } + set { + if(_isManualFineTuning != value) + { + _isManualFineTuning = value; + if(_isManualFineTuning ) + { + _selectedTabIndex = 1; + RaisePropertyChanged(nameof(SelectedTabIndex)); + } + else + { + _selectedTabIndex = 0; + RaisePropertyChanged(nameof(SelectedTabIndex)); + } + if(ActiveLogModel != null) + { + ActiveLogModel.IsManualCorrection = IsManualFineTuning; + } + RaisePropertyChangedAuto(); + } + } + } + + private int _selectedTabIndex; + /// <summary> + /// Gets or sets the index of the selected category. + /// </summary> + public int SelectedTabIndex + { + get { return _selectedTabIndex; } + set + { + if (_selectedTabIndex != value) + { + _selectedTabIndex = value; + RaisePropertyChangedAuto(); + IsManualFineTuning = (value == 1); + } + } + } + + + + public VisualOffsetModel VisualCorrectionModel { get; set; } + + private double _lightnessOffset; + + public double LightnessOffset + { + get { return _lightnessOffset; } + set { + if(_lightnessOffset != value) + { + _lightnessOffset = value; + if (ActiveLogModel != null) + ActiveLogModel.LightnessOffset = _lightnessOffset; + + OnLightnessOffsetChanged(); + RaisePropertyChangedAuto(); + } + } + } + + private double _chromaOffset; + + public double ChromaOffset + { + get { return _chromaOffset; } + set + { + if (_chromaOffset != value) + { + _chromaOffset = value; + if (ActiveLogModel != null) + ActiveLogModel.ChromaOffset = _chromaOffset; + OnChromaOffsetChanged(); + RaisePropertyChangedAuto(); + } + } + } + private double _hueOffset; + public double HueOffset + { + get { return _hueOffset; } + set + { + if (_hueOffset != value) + { + _hueOffset = value; + if (ActiveLogModel != null) + ActiveLogModel.HueOffset = _hueOffset; + OnHueOffsetChanged(); + RaisePropertyChangedAuto(); + } + } + } + #endregion #region Commands public RelayCommand TestCommand { get; set; } + public RelayCommand ByPassTestCommand { get; set; } public RelayCommand StopCommand { get; set; } public RelayCommand ClearTrialsCommand { get; set; } public RelayCommand ExportTrialsCommand { get; set; } @@ -459,6 +686,7 @@ namespace Tango.PPC.Jobs.Dialogs ClearTrialsCommand = new RelayCommand(ClearTrialsLog); ExportTrialsCommand = new RelayCommand(ExportTrialsLog); TestCommand = new RelayCommand(StartJob, CanStartJob); + ByPassTestCommand = new RelayCommand(BypassTest, CanStartJob); StopCommand = new RelayCommand(StopTest); DeleteTrialCommand = new RelayCommand(DeleteTrialLog); PressedCommand = new RelayCommand((x) => { }); ; @@ -466,10 +694,29 @@ namespace Tango.PPC.Jobs.Dialogs IsExpanderOpened = true; TangoIOC.Default.Inject(this); + + _CorrectOnlyHue = true; + IsManualFineTuning = false; + VisualCorrectionModel = new VisualOffsetModel(); } + /// <summary> + /// Initializes at open the dialog. + /// </summary> public void Init(BrushStopModel brushstop, double l, double a, double b, System.Windows.Media.Color targetColor) { + SelectedTabIndex = 0; + CorrectOnlyHue = false; + + LightnessOffset = 0.0; + ChromaOffset = 0.0; + HueOffset = 0.0; + + DC = null; + DL = null; + DH = null; + DeltaE = null; + _sessionID = brushstop.Guid + $"{l}{a}{b}"; MachineProvider.MachineOperator.PrintingStarted += MachineOperator_PrintingStarted; @@ -479,6 +726,7 @@ namespace Tango.PPC.Jobs.Dialogs BrushStopModel = brushstop.Clone(); BrushStopModel.Guid = brushstop.Guid; + IsOutOfGamut = brushstop.IsOutOfGamut; TargetL = l; TargetB = b; TargetA = a; @@ -496,8 +744,9 @@ namespace Tango.PPC.Jobs.Dialogs TestColor = null; TestColor = TrialsLogEngine.Default.GetByBrushStopGuid(BrushStopModel.Guid); + - if (TestColor == null) + if (TestColor == null ) { ActiveLogModel = new TrialsLogModel(0, Cyan, Magenta, Yellow, Black); ActiveLogModel.SuggestionL = TargetL; @@ -505,6 +754,7 @@ namespace Tango.PPC.Jobs.Dialogs ActiveLogModel.SuggestionB = TargetB; TrialsLogitems = new SynchronizedObservableCollection<TrialsLogModel>(); TrialsLogitems.Add(ActiveLogModel); + InitManualCorrection(); //TEST //for(int i = 1; i < 10; i++) //{ @@ -529,40 +779,59 @@ namespace Tango.PPC.Jobs.Dialogs } if (ActiveLogModel.IsTested == false) { - if (ActiveLogModel.L != null) - { MeasuredL = ActiveLogModel.L; - } - if (ActiveLogModel.A != null) - { MeasuredA = ActiveLogModel.A; - } - if (ActiveLogModel.B != null) - { MeasuredB = ActiveLogModel.B; - } - TestCommand.RaiseCanExecuteChanged(); + } - ActiveLogModel.IsActiveTrial = true; ActiveLogModel.IsSelectionEnable = true; - - var minValue = TrialsLogitems.Min(x => x.DeltaE); - if (minValue != null && minValue < 2) + + var minValue = TrialsLogitems.Min(x => (double?)x.DeltaE); + if(minValue != null && minValue < 2) { - TrialsLogitems.Where(x => x.DeltaE == minValue).ToList().ForEach(i => i.IsBest = true); + TrialsLogitems.Where(x=> (double?)x.DeltaE == minValue).ToList().ForEach(i => i.IsBest = true); } - - OKCommand.RaiseCanExecuteChanged(); - TestCommand.RaiseCanExecuteChanged(); - + + UpdateManualCorrection(); + LightnessOffset = ActiveLogModel.LightnessOffset; + ChromaOffset = ActiveLogModel.ChromaOffset; + HueOffset = ActiveLogModel.HueOffset; } + OKCommand.RaiseCanExecuteChanged(); + TestCommand.RaiseCanExecuteChanged(); + ByPassTestCommand.RaiseCanExecuteChanged(); IsVisible = true; RaisePropertyChanged(nameof(TrialsLogitems)); RaisePropertyChanged(nameof(IsDisableInputLAB)); RaisePropertyChanged(nameof(TrialNumber)); } + public void InitManualCorrection() + { + if (ActiveLogModel == null) + return; + double l = MeasuredL == null ? TargetL : (double)MeasuredL; + double a = MeasuredA == null ? TargetA : (double)MeasuredA; + double b = MeasuredB == null ? TargetB : (double)MeasuredB; + LabColor labColor = new LabColor(l, a, b); + var converter = new ColourfulConverter { WhitePoint = Illuminants.D65 }; + var last_LCH = converter.ToLChab(labColor); + VisualCorrectionModel.InitLAB(l, a, b, last_LCH.C, last_LCH.h); + } + + public void UpdateManualCorrection() + { + if(ActiveLogModel == null) + return; + double l = MeasuredL == null ? ActiveLogModel.SuggestionL: (double) MeasuredL; + double a = MeasuredA == null ? ActiveLogModel.SuggestionA : (double)MeasuredA; + double b = MeasuredB == null ? ActiveLogModel.SuggestionB : (double)MeasuredB; + + VisualCorrectionModel.UpdateSourceLAB(l, a, b ); + VisualCorrectionModel.UpdateManualColors(); + } + #region Methods protected override bool CanOK() @@ -641,6 +910,9 @@ namespace Tango.PPC.Jobs.Dialogs } ActiveLogModel = TrialsLogitems.FirstOrDefault(x => x.TrialNumber == 0); ActiveLogModel.L = ActiveLogModel.A = ActiveLogModel.B = null; + ActiveLogModel.SuggestionL = TargetL; + ActiveLogModel.SuggestionA = TargetA; + ActiveLogModel.SuggestionB = TargetB; ActiveLogModel.NewSuggestionL = ActiveLogModel.NewSuggestionA = ActiveLogModel.NewSuggestionB = 0; ActiveLogModel.DeltaE = null; ActiveLogModel.IsTested = false; @@ -653,6 +925,8 @@ namespace Tango.PPC.Jobs.Dialogs RaisePropertyChanged(nameof(TrialsLogitems)); RaisePropertyChanged(nameof(IsDisableInputLAB)); RaisePropertyChanged(nameof(TrialNumber)); + VectorCorrection(); + ClearFoNextTrial(); } } @@ -718,7 +992,13 @@ namespace Tango.PPC.Jobs.Dialogs RaisePropertyChanged(nameof(MeasuredB)); RaisePropertyChanged(nameof(TrialsLogitems)); RaisePropertyChanged(nameof(IsDisableInputLAB)); + } + VectorCorrection(); + UpdateManualCorrection(); + LightnessOffset = ActiveLogModel.LightnessOffset; + ChromaOffset = ActiveLogModel.ChromaOffset; + HueOffset = ActiveLogModel.HueOffset; } } @@ -735,8 +1015,8 @@ namespace Tango.PPC.Jobs.Dialogs base.Accept(); return; } - var prevtrial = TrialsLogitems.FirstOrDefault(x => x.TrialNumber == (SelectedLog.TrialNumber - 1)); - if (prevtrial != null && prevtrial.DeltaE >= 2) + var prevtrial = TrialsLogitems.FirstOrDefault( x=> x.TrialNumber == (SelectedLog.TrialNumber -1)); + if(prevtrial != null && prevtrial.DeltaE != null && prevtrial.DeltaE >=2) { if (false == await NotificationProvider.ShowQuestion("Please note that the color you have chosen is not the closest one.")) { @@ -744,7 +1024,8 @@ namespace Tango.PPC.Jobs.Dialogs return; } } - + SaveTest(GetExcelDataItems(SelectedLog, true)); + BrushStopModel.PreventPropertyUpdate = true; BrushStopModel.Cyan = SelectedLog.C; BrushStopModel.Magenta = SelectedLog.M; @@ -791,10 +1072,14 @@ namespace Tango.PPC.Jobs.Dialogs protected override void Cancel() { OnClose(); - - if (TestColor != null) + + if (TestColor != null )// update test { - if (TrialsLogitems.Count > 0) + if (TrialsLogitems.Count == 1 && (MeasuredL == null || MeasuredA == null || MeasuredB == null)) + { + TrialsLogEngine.Default.Delete(TestColor); + } + else if (TrialsLogitems.Count > 0) { TestColor.L = TargetL; TestColor.A = TargetA; @@ -803,11 +1088,16 @@ namespace Tango.PPC.Jobs.Dialogs TestColor.TrialslogList.Clear(); TestColor.TrialslogList.AddRange(TrialsLogitems); TrialsLogEngine.Default.UpdateTest(TestColor); + if(ActiveLogModel != null && !ActiveLogModel.IsTested) + { + SaveTest(GetExcelDataItems(ActiveLogModel, false)); + } } - //else - // TrialsLogEngine.Default.Delete(TestColor); } - else if (TrialsLogitems.Count > 0) + else if(TrialsLogitems.Count > 0 + && (TrialsLogitems.Count > 1 + || (MeasuredL != null && MeasuredA != null && MeasuredB != null) + || ( IsManualFineTuning && (LightnessOffset != 0 || HueOffset != 0 || ChromaOffset != 0)))) { TestColor = new TestColor(); TestColor.BrushStopGuid = BrushStopModel.Guid; @@ -816,6 +1106,12 @@ namespace Tango.PPC.Jobs.Dialogs TestColor.B = TargetB; TestColor.TrialslogList.AddRange(TrialsLogitems); TrialsLogEngine.Default.AddTest(TestColor); + if (ActiveLogModel != null && !ActiveLogModel.IsTested + && (MeasuredL != null && MeasuredA != null && MeasuredB != null) + || (IsManualFineTuning && (LightnessOffset != 0 || HueOffset != 0 || ChromaOffset != 0))) + { + SaveTest(GetExcelDataItems(ActiveLogModel, false)); + } } base.Cancel(); } @@ -837,7 +1133,37 @@ namespace Tango.PPC.Jobs.Dialogs return true; } - private void OnLABChanged() + public void ClearFoNextTrial() + { + SelectedTabIndex = 0; + CorrectOnlyHue = false; + + _measuredL = null; + _measuredB = null; + _measuredA = null; + RaisePropertyChanged(nameof(MeasuredL)); + RaisePropertyChanged(nameof(MeasuredA)); + RaisePropertyChanged(nameof(MeasuredB)); + if (ActiveLogModel != null) + { + VisualCorrectionModel.UpdateSourceLAB(ActiveLogModel.SuggestionL, ActiveLogModel.SuggestionA, ActiveLogModel.SuggestionB); + } + else + { + VisualCorrectionModel.UpdateSourceLAB(TargetL, TargetA, TargetB); + } + LightnessOffset = 0.0; + ChromaOffset = 0.0; + HueOffset = 0.0; + + DC = null; + DL = null; + DH = null; + DeltaE = null; + + VisualCorrectionModel.UpdateManualColors(); + } + private void OnLABChanged() { if (ActiveLogModel == null) return; @@ -854,21 +1180,100 @@ namespace Tango.PPC.Jobs.Dialogs //{ // await NotificationProvider.ShowInfo("Color is out of gamut!"); //} + + double dL, dC, dH; + DeltaE = DeltaE_CMC(TargetL, TargetA, TargetB, (double)MeasuredL, (double)MeasuredA, (double)MeasuredB, out dL, out dC, out dH); - var deltaE = DeltaE_CMC(TargetL, TargetA, TargetB, (double)MeasuredL, (double)MeasuredA, (double)MeasuredB); - ActiveLogModel.DeltaE = deltaE; + DL = dL; + DC = (Double?)dC; + DH = (Double?)dH; + ActiveLogModel.DeltaE = DeltaE; + VectorCorrection(); + UpdateManualCorrection(); + OnLightnessOffsetChanged(); + OnChromaOffsetChanged(); + OnHueOffsetChanged(); ValidationTests(); } TestCommand.RaiseCanExecuteChanged(); + ByPassTestCommand.RaiseCanExecuteChanged(); + } + + private void OnLightnessOffsetChanged() + { + if (ActiveLogModel == null ) + return; + + VisualCorrectionModel.LightnessOffset = LightnessOffset; + VisualCorrectionModel.ManualCorrection(LightnessOffset, ChromaOffset, HueOffset); + ActiveLogModel.VectorCorrectionL = VisualCorrectionModel.L; + ActiveLogModel.VectorCorrectionA = VisualCorrectionModel.A; + ActiveLogModel.VectorCorrectionB = VisualCorrectionModel.B; + TestCommand.RaiseCanExecuteChanged(); + ByPassTestCommand.RaiseCanExecuteChanged(); + + } + + private void OnChromaOffsetChanged() + { + if (ActiveLogModel == null ) + return; + VisualCorrectionModel.ChromaOffset = ChromaOffset; + VisualCorrectionModel.ManualCorrection(LightnessOffset, ChromaOffset, HueOffset); + ActiveLogModel.VectorCorrectionL = VisualCorrectionModel.L; + ActiveLogModel.VectorCorrectionA = VisualCorrectionModel.A; + ActiveLogModel.VectorCorrectionB = VisualCorrectionModel.B; + TestCommand.RaiseCanExecuteChanged(); + ByPassTestCommand.RaiseCanExecuteChanged(); + } + + private void OnHueOffsetChanged() + { + if (ActiveLogModel == null ) + return; + + VisualCorrectionModel.HueOffset = HueOffset; + VisualCorrectionModel.ManualCorrection(LightnessOffset, ChromaOffset, HueOffset); + ActiveLogModel.VectorCorrectionL = VisualCorrectionModel.L; + ActiveLogModel.VectorCorrectionA = VisualCorrectionModel.A; + ActiveLogModel.VectorCorrectionB = VisualCorrectionModel.B; + TestCommand.RaiseCanExecuteChanged(); + ByPassTestCommand.RaiseCanExecuteChanged(); } #endregion #region Job + private void BypassTest() + { + BrushStopModel.PreventPropertyUpdate = true; + + CalculateSuggestionLAB(ActiveLogModel); + + BrushStopModel.PreventPropertyUpdate = true; + BrushStopModel.L = ActiveLogModel.NewSuggestionL; + BrushStopModel.A = ActiveLogModel.NewSuggestionA; + BrushStopModel.B = ActiveLogModel.NewSuggestionB; + BrushStopModel.PreventPropertyUpdate = false; + + //calculate CMYK + BrushStopModel.FineTuningConverter(ActiveLogModel.C, ActiveLogModel.M, ActiveLogModel.Y, ActiveLogModel.K); + //if (BrushStopModel.IsOutOfGamut) + //{ + // ActiveLogModel.NewSuggestionL = BrushStopModel.L; + // ActiveLogModel.NewSuggestionA = BrushStopModel.A; + // ActiveLogModel.NewSuggestionB = BrushStopModel.B; + //} + + BrushStopModel.ColorSpace = ColorSpaces.LAB; + UpdateOnEndJob(); + InvalidateRelayCommands(); + } + private async void StartJob() { - if (ActiveLogModel.DeltaE <= 0.5) + if (ActiveLogModel.DeltaE != null && ActiveLogModel.DeltaE <= 0.5) { if (true == await NotificationProvider.ShowQuestion("Previous trial seems to be very close; no more trials are recommended")) return; @@ -886,8 +1291,8 @@ namespace Tango.PPC.Jobs.Dialogs //calculate CMYK - BrushStopModel.FineTuningConverter(); - if (BrushStopModel.IsOutOfGamut) + BrushStopModel.FineTuningConverter(ActiveLogModel.C, ActiveLogModel.M, ActiveLogModel.Y, ActiveLogModel.K); + if(BrushStopModel.IsOutOfGamut) { ActiveLogModel.NewSuggestionL = BrushStopModel.L; ActiveLogModel.NewSuggestionA = BrushStopModel.A; @@ -957,7 +1362,9 @@ namespace Tango.PPC.Jobs.Dialogs private bool CanStartJob(object arg) { - return (ActiveLogModel != null && IsValidLAB() && TrialsLogitems.Count <= 10 && !IsJobRunning); + return (!IsJobRunning && ActiveLogModel != null && (ActiveLogModel.TrialNumber == 0 || + (IsValidLAB() || (IsManualFineTuning && VisualCorrectionModel != null && (LightnessOffset != 0.0 || ChromaOffset != 0.0 || HueOffset != 0.0)))) + && TrialsLogitems.Count <= 10 ); } private void MachineOperator_PrintingStarted(object sender, PrintingEventArgs e) @@ -1062,8 +1469,7 @@ namespace Tango.PPC.Jobs.Dialogs //} } - - + private void JobHandler_Completed(object sender, EventArgs e) { if (_handler != null) @@ -1071,43 +1477,7 @@ namespace Tango.PPC.Jobs.Dialogs if (IsVisible) { IsJobRunning = false; - // Dispatcher.CurrentDispatcher.Invoke(() => - // { - ActiveLogModel.IsTested = true; - Cyan = BrushStopModel.Cyan; - Magenta = BrushStopModel.Magenta; - Yellow = BrushStopModel.Yellow; - Black = BrushStopModel.Black; - //ActiveLogModel.TestC = BrushStopModel.Cyan; - //ActiveLogModel.TestM = BrushStopModel.Magenta; - //ActiveLogModel.TestY = BrushStopModel.Yellow; - //ActiveLogModel.TestK = BrushStopModel.Black; - if (ActiveLogModel != null && TrialsLogitems.Count <= 10) - { - var suggestionL = ActiveLogModel.NewSuggestionL; - var suggestionA = ActiveLogModel.NewSuggestionA; - var suggestionB = ActiveLogModel.NewSuggestionB; - ActiveLogModel = new TrialsLogModel(ActiveLogModel.TrialNumber + 1, Cyan, Magenta, Yellow, Black); - ActiveLogModel.SuggestionL = suggestionL; - ActiveLogModel.SuggestionA = suggestionA; - ActiveLogModel.SuggestionB = suggestionB; - TrialsLogitems.Insert(0, ActiveLogModel); - var minDelataE = TrialsLogitems.Min(x => x.DeltaE); - if (minDelataE != null && minDelataE < 2) - TrialsLogitems.ToList().ForEach(x => x.IsBest = (x.DeltaE == minDelataE)); - - RaisePropertyChanged(nameof(TrialsLogitems)); - _measuredL = null; - _measuredB = null; - _measuredA = null; - RaisePropertyChanged(nameof(MeasuredL)); - RaisePropertyChanged(nameof(MeasuredA)); - RaisePropertyChanged(nameof(MeasuredB)); - RaisePropertyChanged(nameof(TrialNumber)); - } - RaisePropertyChanged(nameof(IsDisableInputLAB)); - - //}); + UpdateOnEndJob(); } _handler.StatusChanged -= JobHandler_StatusChanged; @@ -1129,11 +1499,50 @@ namespace Tango.PPC.Jobs.Dialogs } } + private void UpdateOnEndJob() + { + ActiveLogModel.IsTested = true; + Cyan = BrushStopModel.Cyan; + Magenta = BrushStopModel.Magenta; + Yellow = BrushStopModel.Yellow; + Black = BrushStopModel.Black; + //ActiveLogModel.TestC = BrushStopModel.Cyan; + //ActiveLogModel.TestM = BrushStopModel.Magenta; + //ActiveLogModel.TestY = BrushStopModel.Yellow; + //ActiveLogModel.TestK = BrushStopModel.Black; + SaveTest(GetExcelDataItems(ActiveLogModel, false)); + if (ActiveLogModel != null && TrialsLogitems.Count <= 10) + { + var suggestionL = ActiveLogModel.NewSuggestionL; + var suggestionA = ActiveLogModel.NewSuggestionA; + var suggestionB = ActiveLogModel.NewSuggestionB; + ActiveLogModel = new TrialsLogModel(ActiveLogModel.TrialNumber + 1, Cyan, Magenta, Yellow, Black); + ActiveLogModel.SuggestionL = suggestionL; + ActiveLogModel.SuggestionA = suggestionA; + ActiveLogModel.SuggestionB = suggestionB; + + ActiveLogModel.VectorCorrectionL = suggestionL; + ActiveLogModel.VectorCorrectionA = suggestionA; + ActiveLogModel.VectorCorrectionB = suggestionB; + + TrialsLogitems.Insert(0, ActiveLogModel); + var minDelataE = TrialsLogitems.Min(x => (double?)x.DeltaE); + if (minDelataE != null && minDelataE < 2) + TrialsLogitems.ToList().ForEach(x => x.IsBest = ((double?)x.DeltaE == minDelataE)); + + RaisePropertyChanged(nameof(TrialsLogitems)); + RaisePropertyChanged(nameof(TrialNumber)); + + // UpdateManualCorrection(); + ClearFoNextTrial(); + } + RaisePropertyChanged(nameof(IsDisableInputLAB)); + } #endregion #region Delta E - double DeltaE_CMC(double L1, double a1, double b1, double L2, double a2, double b2) + double DeltaE_CMC(double L1, double a1, double b1, double L2, double a2, double b2, out double dL, out double dC, out double dH) { double h1 = Math.Atan2(b1, a1) * (180 / Math.PI); if (h1 < 0) @@ -1171,11 +1580,11 @@ namespace Tango.PPC.Jobs.Dialogs //chroma calculation double samX_C = Math.Sqrt(a2 * a2 + b2 * b2); - double dL = L1 - L2; - double dC = samX_C - refX_C; + dL = L1 - L2; + dC = samX_C - refX_C; double da = a1 - a2; double db = b1 - b2; - double dH = Math.Sqrt(Math.Max(da * da + db * db - dC * dC, 0.0)); + dH = Math.Sqrt(Math.Max(da * da + db * db - dC * dC, 0.0)); double dECMC = Math.Sqrt(Math.Pow(dL / (2 * refX_SL), 2) + Math.Pow(dC / refX_SC, 2) + Math.Pow(dH / refX_SH, 2)); return dECMC; @@ -1203,9 +1612,9 @@ namespace Tango.PPC.Jobs.Dialogs var item = TrialsLogitems.FirstOrDefault(x => x.TrialNumber == currentTrialNumber - 2); var item1 = TrialsLogitems.FirstOrDefault(x => x.TrialNumber == currentTrialNumber - 1); var item2 = ActiveLogModel; - if (item1 != null && item2 != null && item != null) + if(item1 != null && item2 != null && item != null && item2.DeltaE != null && item1.DeltaE != null && item.DeltaE != null) {//dEi+2- dEi+1>0.5 and dEi+1-dEi>0.5 - if ((item2.DeltaE - item1.DeltaE) > 0.5 && (item1.DeltaE - item.DeltaE) > 0.5) + if ( ( item2.DeltaE - item1.DeltaE) > 0.5 && (item1.DeltaE - item.DeltaE) > 0.5) { await NotificationProvider.ShowInfo("It seems that we can’t get you any closer"); return; @@ -1226,13 +1635,6 @@ namespace Tango.PPC.Jobs.Dialogs if (item == null || item1 == null) return; - var deltaE_reg = DeltaE_regular(TargetL, TargetA, TargetB, (double)MeasuredL, (double)MeasuredA, (double)MeasuredB); - if ((Math.Abs((double)item1.L - (double)item.L) < 0.1 && Math.Abs((double)item1.A - (double)item.A) < 0.1 && Math.Abs((double)item1.B - (double)item.B) < 0.1) - || deltaE_reg < 0.2) - { - await NotificationProvider.ShowInfo("It seems that we can’t get you any closer"); - return; - } if (Math.Abs((double)item1.C - (double)item.C) < 0.1 && Math.Abs((double)item1.M - (double)item.M) < 0.1 && Math.Abs((double)item1.Y - (double)item.Y) < 0.1 @@ -1241,21 +1643,80 @@ namespace Tango.PPC.Jobs.Dialogs await NotificationProvider.ShowInfo("It seems that we can’t get you any closer"); return; } + if( MeasuredL == null || MeasuredA == null || MeasuredB == null || item.L == null || item1.L == null || item.A == null || item1.B == null || item.A == null || item1.A == null) + return; + + var deltaE_reg = DeltaE_regular(TargetL, TargetA, TargetB, (double)MeasuredL, (double)MeasuredA, (double)MeasuredB); + if ((Math.Abs((double)item1.L - (double)item.L) < 0.1 && Math.Abs((double)item1.A - (double)item.A) < 0.1 && Math.Abs((double)item1.B - (double)item.B) < 0.1) + || deltaE_reg < 0.2) + { + await NotificationProvider.ShowInfo("It seems that we can’t get you any closer"); + return; + } } return; } private bool CalculateSuggestionLAB(TrialsLogModel trial) { - if (MeasuredL != null && MeasuredA != null && MeasuredB != null) + if ((MeasuredL != null && MeasuredA != null && MeasuredB != null) + || IsManualFineTuning && (LightnessOffset != 0.0 || ChromaOffset != 0.0 || HueOffset != 0.0)) + { - trial.NewSuggestionL = LimitToRange((trial.SuggestionL + (TargetL - (double)MeasuredL)), 0, 100); - trial.NewSuggestionA = LimitToRange((trial.SuggestionA + (TargetA - (double)MeasuredA)), -128, 127); - trial.NewSuggestionB = LimitToRange((trial.SuggestionB + (TargetB - (double)MeasuredB)), -128, 127); - LogManager.Log($" Fine Tuning. Suggestion (calculated) LAB L:'{trial.NewSuggestionL}'A:'{trial.NewSuggestionA}' B:'{trial.NewSuggestionB}'."); - return true; + if (!IsManualFineTuning && CorrectOnlyHue) + { + var converter = new ColourfulConverter { WhitePoint = Illuminants.D65 }; + + LabColor labColorTarget = new LabColor(TargetL, TargetA, TargetB); + var LCH_target = converter.ToLChab(labColorTarget); + + + LabColor labColorSuggestion = new LabColor(ActiveLogModel.SuggestionL, ActiveLogModel.SuggestionA, ActiveLogModel.SuggestionB); + var LCH_suggestion = converter.ToLChab(labColorSuggestion); + + LabColor labColorNew = new LabColor((double)trial.VectorCorrectionL, (double)trial.VectorCorrectionA, (double)trial.VectorCorrectionB); + var LCH_new = converter.ToLChab(labColorNew); + + double L = LCH_suggestion.L; + double C = LCH_suggestion.C; + double H = LCH_suggestion.h + (LCH_target.h - LCH_new.h); + + LabColor lab = converter.ToLab(new LChabColor(L, C, H)); + trial.NewSuggestionL = lab.L; + trial.NewSuggestionA = lab.a; + trial.NewSuggestionB = lab.b; + + LogManager.Log($" Fine Tuning. Suggestion (calculated) LAB L:'{trial.NewSuggestionL}'A:'{trial.NewSuggestionA}' B:'{trial.NewSuggestionB}'."); + return true; + } + else + { + var settings = SettingsManager.Default.GetOrCreate<PPCSettings>(); + bool bNotChangeL = false; + if(settings.FineTuningMinLimitdL > 0) + { + var dL = Math.Abs((double)trial.VectorCorrectionL - trial.SuggestionL); + var dA = Math.Abs((double)trial.VectorCorrectionA - trial.SuggestionA); + var dB = Math.Abs((double)trial.VectorCorrectionB - trial.SuggestionB); + if(dL < settings.FineTuningMinLimitdL && (dL < dA || dL < dB)) + { + bNotChangeL = true; + } + } + trial.NewSuggestionL = bNotChangeL ? trial.SuggestionL : LimitToRange((trial.SuggestionL + (TargetL - (double)trial.VectorCorrectionL)), 0, 100); + trial.NewSuggestionA = LimitToRange((trial.SuggestionA + (TargetA - (double)trial.VectorCorrectionA)), -128, 127); + trial.NewSuggestionB = LimitToRange((trial.SuggestionB + (TargetB - (double)trial.VectorCorrectionB)), -128, 127); + LogManager.Log($" Fine Tuning. Suggestion (calculated) LAB L:'{trial.NewSuggestionL}'A:'{trial.NewSuggestionA}' B:'{trial.NewSuggestionB}'."); + return true; + } } + else + { + trial.NewSuggestionL = trial.SuggestionL; + trial.NewSuggestionA = trial.SuggestionA; + trial.NewSuggestionB = trial.SuggestionB; + } return false; } @@ -1304,8 +1765,142 @@ namespace Tango.PPC.Jobs.Dialogs ActiveLogModel.JobRunGuid = e.JobRun.Guid; } + /// <summary> + /// Vectors the correction. + /// </summary> + protected void VectorCorrection() + { + if(ActiveLogModel == null) + return; + + if ( !IsValidLAB()) + { + ActiveLogModel.VectorCorrectionL = MeasuredL == null ? ActiveLogModel.SuggestionL : (double)MeasuredL; + ActiveLogModel.VectorCorrectionA = MeasuredA == null ? ActiveLogModel.SuggestionA : (double)MeasuredA; + ActiveLogModel.VectorCorrectionB = MeasuredB == null ? ActiveLogModel.SuggestionB : (double)MeasuredB; + return; + } + + ActiveLogModel.VectorCorrectionL = (double)MeasuredL; + ActiveLogModel.VectorCorrectionA = (double)MeasuredA; + ActiveLogModel.VectorCorrectionB = (double)MeasuredB; + return; + } + #endregion + #region save in excel + + protected List<ExcelFTTestsData> GetExcelDataItems(TrialsLogModel model, bool isAccepted) + { + String nameRML = BrushStopModel.SegmentModel.Job.Rml.DisplayName; + String jobName = BrushStopModel.SegmentModel.Job.Name; + String machine_SN = BrushStopModel.SegmentModel.Job.Machine.DeviceName; + + List<ExcelFTTestsData> items = new List<ExcelFTTestsData>(){ new ExcelFTTestsData() + { + Date = model.Date.ToString(), + Job_Name = jobName, + FVT_ID = model.TrialNumber.ToString(), + Machine_SN = machine_SN, + RML = nameRML, + Target_L = TargetL.ToString("###.##"), + Target_A = TargetA.ToString("###.##"), + Target_B = TargetB.ToString("###.##"), + Suggested_L = model.SuggestionL.ToString("###.##"), + Suggested_A = model.SuggestionA.ToString("###.##"), + Suggested_B = model.SuggestionB.ToString("###.##"), + Suggested_C = model.C.ToString("0.##"), + Suggested_M = model.M.ToString("0.##"), + Suggested_Y = model.Y.ToString("0.##"), + Suggested_K = model.K.ToString("0.##"), + Result_L = model.NewSuggestionL.ToString("###.##"), + Result_A = model.NewSuggestionA.ToString("###.##"), + Result_B = model.NewSuggestionB.ToString("###.##"), + delta_L = model.dL.ToString("###.##"), + delta_C = model.dC.ToString("###.##"), + delta_H = model.dH.ToString("###.##"), + delta_E_CMC = model.DeltaEDisplay, + OOG = model.SuggestedColor, + Type = model.IsManualCorrection ? "Visual " + model.LightnessOffset.ToString("#.#") + "L+ " + model.ChromaOffset.ToString("#.#") + "C+ " + model.HueOffset.ToString("#.#") + "H" : model.CorrectOnlyHue ? "Vector H" : "Vector", + User_selected_option = isAccepted? "accepted" : "",//????? + User_finished_process = model.IsTested ? "tested" : "not tested" + + } }; + return items; + } + + protected void SaveTest(List<ExcelFTTestsData> items) + { + if (items == null || items.Count == 0) + return; + + Task.Factory.StartNew(() => + { + ExcelWriter writer = null; + try + { + IsFree = false; + String dbFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Twine", "Tango", "Color Fine tuning"); + Directory.CreateDirectory(dbFolder); + + Stream stream = null; + String nameRML = BrushStopModel.SegmentModel.Job.Rml.DisplayName; + String jobName = BrushStopModel.SegmentModel.Job.Name; + String mashine_SN = BrushStopModel.SegmentModel.Job.Machine.DeviceName; + string fileName = String.Format($"{TargetL.ToString("##0")}_{TargetA.ToString("##0")}_{TargetB.ToString("##0")}_{nameRML}_{jobName}.xlsx"); + string file = Path.Combine(dbFolder, fileName); + + bool dispose = false; + + if (File.Exists(file)) + { + stream = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); + dispose = true; + } + else + { + stream = EmbeddedResourceHelper.GetEmbeddedResourceStream("Tango.PPC.Jobs.FineTuning.FTVTemplate.xlsx"); + } + if (stream == null) + return; + + byte[] data = new byte[stream.Length]; + stream.Read(data, 0, data.Length); + File.WriteAllBytes(file, data); + + if (dispose) + { + stream.Dispose(); + } + + writer = new ExcelWriter(file); + writer.WriteData(items, "Sheet1"); + writer.Dispose(); + writer = null; + } + catch (Exception ex) + { + LogManager.Log(ex, $"Error exporting data."); + + InvokeUI(async () => + { + await NotificationProvider.ShowError($"An error occurred while trying to export the data. Make sure the excel file is closed and data is valid.\n{ex.FlattenMessage()}"); + }); + } + finally + { + IsFree = true; + if (writer != null) + writer.Dispose(); + + } + }); + } + + #endregion + + } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/FineTuning/ExcelFTTestsData.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/FineTuning/ExcelFTTestsData.cs new file mode 100644 index 000000000..1c8e920ff --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/FineTuning/ExcelFTTestsData.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Media; + +namespace Tango.PPC.Jobs.FineTuning +{ + public class ExcelFTTestsData + { + public String Date { get; set; } + public String Job_Name { get; set; } + public String FVT_ID { get; set; } + public String Machine_SN { get; set; } + public String RML { get; set; } + public String Target_L { get; set; } + public String Target_A { get; set; } + public String Target_B { get; set; } + public String Suggested_L { get; set; } + public String Suggested_A { get; set; } + public String Suggested_B { get; set; } + public String Suggested_C { get; set; } + public String Suggested_M { get; set; } + public String Suggested_Y { get; set; } + public String Suggested_K { get; set; } + public String Result_L { get; set; } + public String Result_A { get; set; } + public String Result_B { get; set; } + public String delta_E_CMC { get; set; } + public String delta_L { get; set; } + public String delta_C { get; set; } + public String delta_H { get; set; } + public Color OOG { get; set; } + public String Type { get; set; } + + public String User_selected_option { get; set; } + + public String User_finished_process { get; set; } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/FineTuning/FTVTemplate.xlsx b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/FineTuning/FTVTemplate.xlsx Binary files differnew file mode 100644 index 000000000..301ed2e96 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/FineTuning/FTVTemplate.xlsx 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 2a347df3d..d9d8142af 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 @@ -863,6 +863,30 @@ namespace Tango.PPC.Jobs.Models return s; } + public BrushStop CreateBrushStopForFineTuning(ColorSpaces colorSpace, double cyan, double yellow, double magenta, double black) + { + List<Tango.BL.Entities.ColorSpace> list = SegmentModel.Job.ColorSpacesList; + + BrushStop s = new BrushStop(); + s.ColorSpace = list.FirstOrDefault(x => x.Space == colorSpace); + + Configuration configuration = SegmentModel.Job.Machine.Configuration; + Rml rml = SegmentModel.Job.Rml; + s.SetLiquidVolumes(configuration, rml, rml.GetActiveProcessGroup().ProcessParametersTables.FirstOrDefault()); + + + s.ColorSpace.Space = BL.Enumerations.ColorSpaces.LAB; + s.L = this.L; + s.A = this.A; + s.B = this.B; + s.Cyan = cyan; + s.Yellow = yellow; + s.Magenta = magenta; + s.Black = black; + + return s; + } + public BrushStopModel Clone() { var cloned = new BrushStopModel(SegmentModel); @@ -943,6 +967,7 @@ namespace Tango.PPC.Jobs.Models LiquidVolumesOutOfRange = false; } + /// <summary> /// Creates the brush stop. /// </summary> @@ -1404,19 +1429,17 @@ namespace Tango.PPC.Jobs.Models } } - public void FineTuningConverter() + public void FineTuningConverter(double cyan, double yellow, double magenta, double black) { RequiredMaxLiquidTest = true; ColorSpaces colorSpace = ColorSpaces.LAB; - BrushStop stop = CreateBrushStop(colorSpace); - - ConversionOutput output = null; - + BrushStop stop = CreateBrushStopForFineTuning(colorSpace, cyan, yellow, magenta, black); + try { IsBusy = true; - output = _converter.Convert(stop, SegmentModel.Job.Machine.Configuration, SegmentModel.Job.Rml, false, false, false); + var output = _converter.Convert(stop, SegmentModel.Job.Machine.Configuration, SegmentModel.Job.Rml, false, false, false, true); _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); diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/TrialsLogModel.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/TrialsLogModel.cs index bae1df037..ec3a7b8be 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/TrialsLogModel.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/TrialsLogModel.cs @@ -1,9 +1,11 @@ -using LiteDB; +using ColorMine.ColorSpaces; +using LiteDB; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows.Media; using Tango.Core; namespace Tango.PPC.Jobs.Models @@ -36,7 +38,7 @@ namespace Tango.PPC.Jobs.Models return TrialNumber.ToString(); } } - + //LAB private double? _l; public double? L @@ -51,7 +53,9 @@ namespace Tango.PPC.Jobs.Models public double? A { get { return _a; } - set { _a = value; RaisePropertyChanged(nameof(LAB)); OnLABChanged(); } + set { _a = value; + + RaisePropertyChanged(nameof(LAB)); OnLABChanged(); } } private double? _b; @@ -60,12 +64,45 @@ namespace Tango.PPC.Jobs.Models get { return _b; } set { _b = value; RaisePropertyChanged(nameof(LAB)); OnLABChanged(); } } + public double VectorCorrectionL { get; set; } + public double VectorCorrectionA { get; set; } + public double VectorCorrectionB { get; set; } + + public double LightnessOffset { get; set; } + public double ChromaOffset { get; set; } + public double HueOffset { get; set; } + + public bool IsManualCorrection { get; set; } + //LCH + private double _LCH_C; + + public double LCH_C + { + get { return _LCH_C; } + set { + _LCH_C = value; + //RaisePropertyChanged(nameof(LAB)); + } + } + + private double _h; + + public double H + { + get { return _h; } + set { _h = value; + //RaisePropertyChanged(nameof(LAB)); + } + } + + public double dL { get; set; } + public double dC { get; set; } + public double dH { get; set; } + + public bool CorrectOnlyHue { get; set; } - public double SuggestionL { get; set; } - public double SuggestionA { get; set; } - public double SuggestionB { get; set; } public double C { get; set; } @@ -83,9 +120,7 @@ namespace Tango.PPC.Jobs.Models } public double NewSuggestionL { get; set; } - public double NewSuggestionA { get; set; } - public double NewSuggestionB { get; set; } private DateTime _date; @@ -175,6 +210,19 @@ namespace Tango.PPC.Jobs.Models } } + [BsonIgnore] + public System.Windows.Media.Color SuggestedColor + { + get { + Lab lab = new Lab() { L = NewSuggestionL, A = NewSuggestionA, B = NewSuggestionB }; + //Cmyk cmyk = new Cmyk { C = C, M = M, Y = Y, K = K}; + IRgb RGB = lab.ToRgb(); + //IRgb RGB = cmyk.ToRgb(); + return Color.FromRgb((byte)RGB.R, (byte)RGB.G, (byte)RGB.B); + } + + } + #endregion diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/VisualOffsetModel.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/VisualOffsetModel.cs new file mode 100644 index 000000000..042350cb0 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/VisualOffsetModel.cs @@ -0,0 +1,407 @@ +using ColorMine.ColorSpaces; +using Colourful; +using Colourful.Conversion; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Media; +using Tango.Core.Commands; +using Tango.SharedUI; + +namespace Tango.PPC.Jobs.Models +{ + + public class VisualOffsetModel : ViewModel + { + public enum TypeColorCorrection + { + Lightness = 1, + Chroma = 2, + Hue = 3, + } + + public class VisualLCHOffset : ViewModel + { + public TypeColorCorrection ColorType { get; set; } + + public int Offset { get; set; } + + public double L { get; set; } + public double C { get; set; } + public double H { get; set; } + + public SolidColorBrush ColorBrush + { + get + { + Lch lch = new Lch() { L = L, C = C, H = H }; + IRgb RGB = lch.ToRgb(); + return new SolidColorBrush() { Color = Color.FromRgb(System.Convert.ToByte(RGB.R), System.Convert.ToByte(RGB.G), System.Convert.ToByte(RGB.B)) }; + } + } + + private bool _isVisible; + + public bool IsVisible + { + get { return _isVisible; } + set + { + _isVisible = value; + RaisePropertyChangedAuto(); + } + } + + + public VisualLCHOffset(TypeColorCorrection colorType, int offset) + { + ColorType = colorType; + Offset = offset; + } + + public void Init(Lch lch) + { + L = lch.L; + C = lch.C; + H = lch.H; + RaisePropertyChanged( nameof(ColorBrush)); + } + } + + #region Property + + + private double _l; + public double L + { + get { return _l; } + set + { + if (_l != value) + { + _l = value; + RaisePropertyChangedAuto(); + } + } + } + private double _a; + public double A + { + get { return _a; } + set + { + if (_a != value) + { + _a = value; + RaisePropertyChangedAuto(); + } + } + } + private double _b; + public double B + { + get { return _b; } + set + { + if (_b != value) + { + _b = value; + RaisePropertyChangedAuto(); + } + } + } + + public double C { get; set; } + public double H { get; set; } + + private double _sourcel; + public double SourceL + { + get { return _sourcel; } + set { + if(_sourcel != value) + { + _sourcel = value; + RaisePropertyChangedAuto(); + ManualCorrection(LightnessOffset, ChromaOffset, HueOffset); + } + } + } + + private double _sourcea; + public double SourceA + { + get { return _sourcea; } + set + { + if (_sourcea != value) + { + _sourcea = value; + RaisePropertyChangedAuto(); + ManualCorrection(LightnessOffset, ChromaOffset, HueOffset); + } + } + } + + private double _sourceb; + public double SourceB + { + get { return _sourceb; } + set + { + if (_sourceb != value) + { + _sourceb = value; + RaisePropertyChangedAuto(); + ManualCorrection(LightnessOffset, ChromaOffset, HueOffset); + } + } + } + + private double _sourceh; + public double SourceH + { + get { return _sourceh; } + set + { + if (_sourceh != value) + { + _sourceh = value; + RaisePropertyChangedAuto(); + } + } + } + + private double _sourcec; + public double SourceC + { + get { return _sourcec; } + set + { + if (_sourcec != value) + { + _sourcec = value; + RaisePropertyChangedAuto(); + } + } + } + + public double LightnessOffset { get; set; } + public double ChromaOffset { get; set; } + public double HueOffset { get; set; } + + + + public VisualLCHOffset MinLightness { get; set; } + public VisualLCHOffset MaxLightness { get; set; } + public VisualLCHOffset MinChroma { get; set; } + public VisualLCHOffset MaxChroma { get; set; } + public VisualLCHOffset MinHue { get; set; } + public VisualLCHOffset MaxHue { get; set; } + + public SolidColorBrush SourceColorBrush + { + get + { + //Lch lch = new Lch() { L = L, C = C, H = H }; + //IRgb RGB = lch.ToRgb(); + Lab lab = new Lab(SourceL, SourceA, SourceB); + Rgb rgb = new Rgb(lab.ToRgb()); + return new SolidColorBrush() { Color = Color.FromRgb((byte)rgb.R, (byte)rgb.G, (byte)rgb.B) }; + } + } + + public SolidColorBrush ManualColorBrush + { + get + { + //Lch lch = new Lch() { L = L, C = C, H = H }; + //IRgb rgb = lch.ToRgb(); + if(LightnessOffset == 0 && ChromaOffset == 0 && HueOffset == 0) + { + return SourceColorBrush; + } + Lab lab = new Lab(L, A, B); + Rgb rgb = new Rgb(lab.ToRgb()); + return new SolidColorBrush() { Color = Color.FromRgb((byte)rgb.R, (byte)rgb.G, (byte)rgb.B) }; + } + } + + #endregion + + public VisualOffsetModel() + { + MinLightness = new VisualLCHOffset(TypeColorCorrection.Lightness, -1); + MaxLightness = new VisualLCHOffset(TypeColorCorrection.Lightness, 1); + MinChroma = new VisualLCHOffset(TypeColorCorrection.Chroma, -1); + MaxChroma = new VisualLCHOffset(TypeColorCorrection.Chroma, 1); + MinHue = new VisualLCHOffset(TypeColorCorrection.Hue, -1); + MaxHue = new VisualLCHOffset(TypeColorCorrection.Hue, 1); + + } + + public void InitLAB(double l, double a, double b, double c, double h) + { + L = l; + A = a; + B = b; + C = c; + H = h; + LightnessOffset = ChromaOffset = HueOffset = 0; + + _sourcel = l; + RaisePropertyChanged(nameof(SourceL)); + _sourcea = a; + RaisePropertyChanged(nameof(SourceA)); + _sourceb = b; + RaisePropertyChanged(nameof(SourceB)); + _sourcec = c; + RaisePropertyChanged(nameof(SourceC)); + _sourceh = h; + RaisePropertyChanged(nameof(SourceH)); + + Lch lch = Correction(-6, 0, 0); + MinLightness.Init(lch); + lch = Correction(6, 0, 0); + MaxLightness.Init(lch); + lch = Correction(0, -6, 0); + MinChroma.Init(lch); + lch = Correction(0, 6, 0); + MaxChroma.Init(lch); + lch = Correction(0, 0, -6); + MinHue.Init(lch); + lch = Correction(0, 0, 6); + MaxHue.Init(lch); + + RaisePropertyChanged(nameof(SourceColorBrush)); + RaisePropertyChanged(nameof(ManualColorBrush)); + } + + public void UpdateSourceLAB(double l, double a, double b) + { + LabColor labColor = new LabColor(l, a, b); + var converter = new ColourfulConverter { WhitePoint = Illuminants.D65 }; + var last_LCH = converter.ToLChab(labColor); + SourceL = l; + SourceA = a; + SourceB = b; + SourceC = last_LCH.C; + SourceH = last_LCH.h; + } + + public void UpdateManualColors() + { + Lch lch = Correction(-6, 0, 0); + MinLightness.Init(lch); + lch = Correction(6, 0, 0); + MaxLightness.Init(lch); + lch = Correction(0, -6, 0); + MinChroma.Init(lch); + lch = Correction(0, 6, 0); + MaxChroma.Init(lch); + lch = Correction(0, 0, -6); + MinHue.Init(lch); + lch = Correction(0, 0, 6); + MaxHue.Init(lch); + + RaisePropertyChanged(nameof(SourceColorBrush)); + RaisePropertyChanged(nameof(ManualColorBrush)); + } + + /// <summary> + /// Manuals the correction. During change lightnessOffset, chromaOffset or hueOffset in app caused to change LAB of visual correction. + /// </summary> + /// <param name="lightnessOffset">The lightness offset.</param> + /// <param name="chromaOffset">The chroma offset.</param> + /// <param name="hueOffset">The hue offset.</param> + public void ManualCorrection(double lightnessOffset, double chromaOffset, double hueOffset) + { + Lch lch = Correction(lightnessOffset, chromaOffset, hueOffset); + + L = lch.L; + A = lch.C * Math.Cos(lch.H * (Math.PI / 180)); + B = lch.C * Math.Sin(lch.H * (Math.PI / 180)); + RaisePropertyChanged(nameof(SourceColorBrush)); + RaisePropertyChanged(nameof(ManualColorBrush)); + + } + + /// <summary> + /// Calculate Lch on the specified lightness offset. + /// </summary> + /// <param name="lightnessOffset">The lightness offset.</param> + /// <param name="chromaOffset">The chroma offset.</param> + /// <param name="hueOffset">The hue offset.</param> + /// <returns></returns> + public Lch Correction( double lightnessOffset, double chromaOffset, double hueOffset) + { + //LightnessOffset = lightnessOffset; + //ChromaOffset = chromaOffset; + //HueOffset = hueOffset; + + double L1 = SourceL; + double C1 = SourceC; + double H1 = SourceH; + if (H1 < 0) + H1 += 360; + double refX_C = C1; + ///lightness + double SL = 0; + if (L <= 16) + SL = 0.511; + else + SL = L1 * 0.040975 / (1 + 0.01765 * L1); + L1 += lightnessOffset * 2 * SL; + if(L1 > 100) + L1 = 100; + if(L1 < 0) + L1 = 0; + + double SC = (0.638 + 0.0638 * refX_C / (1 + 0.0131 * refX_C)); + C1 += chromaOffset * SC; + if (C1 > 128) + L1 = 128; + if (C1 < 0) + C1 = 0; + + //double h1 = H1; + //if (h1 < 0) + // h1 = h1 + 360; + double refX_CQ = Math.Pow(refX_C, 4); + double refX_H = H1; + double refX_F = Math.Sqrt(refX_CQ / (refX_CQ + 1900)); + double refX_T = 0; + if ((refX_H > 164) & (refX_H < 345)) + refX_T = 0.56 + Math.Abs(0.2 * Math.Cos(Math.PI * (refX_H + 168) / 180)); + else if ((refX_H >= 345) | (refX_H <= 164)) + refX_T = 0.36 + Math.Abs(0.4 * Math.Cos(Math.PI * (refX_H + 35) / 180)); + + double refX_SC = (0.638 + 0.0638 * refX_C / (1 + 0.0131 * refX_C)); + double refX_SH = refX_SC * (refX_T * refX_F + 1 - refX_F); + if(C1 != 0) + { + var argum = 1 - (refX_SH * refX_SH * hueOffset * hueOffset / (2 * C1 * C1)); + if(argum < -1) + argum = -1; + if (argum > 1) + argum = 1; + + double tmp = (180 / Math.PI) * Math.Acos(argum); + if (hueOffset < 0)//? + tmp *= -1; + H1 += tmp; + } + Lch lch = new Lch() { L = L1, C = C1, H = H1 }; + return lch; + + } + + + #region Converter + + + #endregion + } +} 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 26c059d15..2c62b4208 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 @@ -216,9 +216,12 @@ <Compile Include="Controls\TwineCatalogViewer.xaml.cs"> <DependentUpon>TwineCatalogViewer.xaml</DependentUpon> </Compile> + <Compile Include="Converters\ColorContrastConverter.cs" /> <Compile Include="Converters\ColorSpaceToImageConverter.cs" /> <Compile Include="Converters\ColorSpaceToVisibilityConverter.cs" /> <Compile Include="Converters\ColorTabToVisibilityConverter.cs" /> + <Compile Include="Converters\DeltaLCHToTextConverter.cs" /> + <Compile Include="Converters\DoubleNullConverter.cs" /> <Compile Include="Converters\InterSegmentLengthToWidthConverter.cs" /> <Compile Include="Converters\JobsCategoryToOpacityConverter.cs" /> <Compile Include="Converters\JobProgressToPositionConverter.cs" /> @@ -286,6 +289,7 @@ <DependentUpon>VectorFineTuningDialog.xaml</DependentUpon> </Compile> <Compile Include="Dialogs\VectorFineTuningDialogVM.cs" /> + <Compile Include="FineTuning\ExcelFTTestsData.cs" /> <Compile Include="Helpers\BindingProxy.cs" /> <Compile Include="Helpers\ColorLibraryNamesValidationRule.cs" /> <Compile Include="Helpers\GroupSegmentTemplateSelector.cs" /> @@ -303,6 +307,7 @@ <Compile Include="Models\SegmentsGroupModel.cs" /> <Compile Include="Models\TestColor.cs" /> <Compile Include="Models\TrialsLogModel.cs" /> + <Compile Include="Models\VisualOffsetModel.cs" /> <Compile Include="MyColors\MyColorsEngine.cs" /> <Compile Include="NavigationObjects\JobNavigationObject.cs" /> <Compile Include="NavigationObjects\JobSummeryNavigationObject.cs" /> @@ -377,6 +382,7 @@ <LastGenOutput>Resources.Designer.cs</LastGenOutput> </EmbeddedResource> <None Include="app.config" /> + <EmbeddedResource Include="FineTuning\FTVTemplate.xlsx" /> <None Include="packages.config"> <SubType>Designer</SubType> </None> @@ -390,6 +396,10 @@ <Project>{37e4ceab-b54b-451f-b535-04cf7da9c459}</Project> <Name>ColorMine</Name> </ProjectReference> + <ProjectReference Include="..\..\..\SideChains\Tango.Colorful\Tango.Colorful.csproj"> + <Project>{C89C1866-C76B-401F-A232-40FC58065CBF}</Project> + <Name>Tango.Colorful</Name> + </ProjectReference> <ProjectReference Include="..\..\..\Tango.BL\Tango.BL.csproj"> <Project>{f441feee-322a-4943-b566-110e12fd3b72}</Project> <Name>Tango.BL</Name> @@ -406,6 +416,10 @@ <Project>{a34ee0f0-649d-41c8-8489-b6f1cc6924ee}</Project> <Name>Tango.Core</Name> </ProjectReference> + <ProjectReference Include="..\..\..\Tango.Documents\Tango.Documents.csproj"> + <Project>{ca87a608-7b17-4c98-88f2-42abee10f4c1}</Project> + <Name>Tango.Documents</Name> + </ProjectReference> <ProjectReference Include="..\..\..\Tango.DragAndDrop\Tango.DragAndDrop.csproj"> <Project>{b112d89a-a106-41ae-a0c1-4abc84c477f5}</Project> <Name>Tango.DragAndDrop</Name> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Views/MainView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Views/MainView.xaml index 3dee81192..6871eb330 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Views/MainView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Views/MainView.xaml @@ -460,6 +460,11 @@ <touch:TouchToggleSlider IsChecked="{Binding EnableUWF}" Margin="0 0 100 0" DockPanel.Dock="Right" Style="{StaticResource TangoToggleButtonGrayAccent}" HorizontalAlignment="Right" Width="90"></touch:TouchToggleSlider> </DockPanel> + <DockPanel Margin="0 20 0 0" TextElement.FontSize="{StaticResource TangoDefaultFontSize}"> + <TextBlock VerticalAlignment="Center">Min limit dL (Fine Tuning)</TextBlock> + <touch:TouchNumericTextBox Minimum="0" Maximum="10" KeyboardContainer="{Binding ElementName=Container}" Value="{Binding Settings.FineTuningMinLimitdL}" Margin="0 0 100 0" DockPanel.Dock="Right" HorizontalAlignment="Right" Width="90" HasDecimalPoint="True"></touch:TouchNumericTextBox> + </DockPanel> + <DockPanel Margin="0 20 0 0"> <touch:TouchIcon VerticalAlignment="Top" Icon="InformationOutline" Foreground="{StaticResource TangoGrayTextBrush}"></touch:TouchIcon> <TextBlock Margin="10 0 0 0" VerticalAlignment="Top" TextWrapping="Wrap" FontSize="{StaticResource TangoSmallFontSize}" Foreground="{StaticResource TangoGrayTextBrush}"> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs index cb90442eb..6fb521838 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs @@ -345,6 +345,11 @@ namespace Tango.PPC.Common public bool EnableRemoteJobUpload { get; set; } /// <summary> + /// Gets or sets the fine tuning minimum limit dL to avoid change L. + /// </summary> + public double FineTuningMinLimitdL { get; set; } + + /// <summary> /// Gets the machine service address. /// </summary> /// <returns></returns> @@ -361,6 +366,7 @@ namespace Tango.PPC.Common LubricationLevels = new List<RmlLubricationLevel>(); JobUploadStrategy = JobUploadStrategy.JobDescriptionFile; FineTuningTrialLengthMeters = 200; + FineTuningMinLimitdL = 0.0; EnableGradientGeneration = true; GradientGenerationResolution = 40; MachineScanningTimeoutSeconds = 20; diff --git a/Software/Visual_Studio/Tango.ColorConversion/DefaultColorConverter.cs b/Software/Visual_Studio/Tango.ColorConversion/DefaultColorConverter.cs index deb820923..f76e3bd39 100644 --- a/Software/Visual_Studio/Tango.ColorConversion/DefaultColorConverter.cs +++ b/Software/Visual_Studio/Tango.ColorConversion/DefaultColorConverter.cs @@ -65,7 +65,7 @@ namespace Tango.ColorConversion return output; } - public ConversionOutput Convert(BrushStop stop, Configuration configuration, Rml rml, bool generateHive, bool lightInksInstalled, bool useLightInks = false) + public ConversionOutput Convert(BrushStop stop, Configuration configuration, Rml rml, bool generateHive, bool lightInksInstalled, bool useLightInks = false, bool forFineTuning = false) { if (stop == null) { @@ -99,6 +99,8 @@ namespace Tango.ColorConversion conversionInput.InputCoordinates = new InputCoordinates(); + conversionInput.ForFineTuning = forFineTuning; + if (stop.BrushColorSpace == ColorSpaces.RGB) { conversionInput.InputCoordinates.Red = Math.Max(stop.Red, 0); @@ -110,8 +112,15 @@ namespace Tango.ColorConversion conversionInput.InputCoordinates.L = stop.L; conversionInput.InputCoordinates.A = stop.A; conversionInput.InputCoordinates.B = stop.B; + if(forFineTuning) + { + conversionInput.InputCoordinates.Cyan = stop.Cyan; + conversionInput.InputCoordinates.Magenta = stop.Magenta; + conversionInput.InputCoordinates.Yellow = stop.Yellow; + conversionInput.InputCoordinates.Key = stop.Black; + } } - else if (stop.BrushColorSpace == ColorSpaces.CMYK) + else if (stop.BrushColorSpace == ColorSpaces.CMYK ) { conversionInput.InputCoordinates.Cyan = stop.Cyan; conversionInput.InputCoordinates.Magenta = stop.Magenta; @@ -687,11 +696,11 @@ namespace Tango.ColorConversion return processParameters; } - public Task<ConversionOutput> ConvertAsync(BrushStop stop, Configuration configuration, Rml rml, bool generateHive, bool lightInksInstalled, bool useLightInks = false) + public Task<ConversionOutput> ConvertAsync(BrushStop stop, Configuration configuration, Rml rml, bool generateHive, bool lightInksInstalled, bool useLightInks = false, bool forFineTuning = false) { return Task.Factory.StartNew<ConversionOutput>(() => { - return Convert(stop, configuration, rml, generateHive, lightInksInstalled, useLightInks); + return Convert(stop, configuration, rml, generateHive, lightInksInstalled, useLightInks, forFineTuning); }); } diff --git a/Software/Visual_Studio/Tango.ColorConversion/IColorConverter.cs b/Software/Visual_Studio/Tango.ColorConversion/IColorConverter.cs index 1cb5245e7..92733cf0b 100644 --- a/Software/Visual_Studio/Tango.ColorConversion/IColorConverter.cs +++ b/Software/Visual_Studio/Tango.ColorConversion/IColorConverter.cs @@ -15,10 +15,10 @@ namespace Tango.ColorConversion public interface IColorConverter { ConversionOutput Convert(ConversionInput conversionInput, int version); - ConversionOutput Convert(BrushStop stop, Configuration configuration, Rml rml, bool generateHive, bool lightInksInstalled, bool useLightInks = false); + ConversionOutput Convert(BrushStop stop, Configuration configuration, Rml rml, bool generateHive, bool lightInksInstalled, bool useLightInks = false, bool forFineTuning = false); ConversionOutput Convert(BrushStop stop, bool generateHive, bool useLightInks = false); ConversionOutput Convert(Job job, Color color, bool generateHive, bool useLightInks = false); - Task<ConversionOutput> ConvertAsync(BrushStop stop, Configuration configuration, Rml rml, bool generateHive, bool lightInksInstalled, bool useLightInks = false); + Task<ConversionOutput> ConvertAsync(BrushStop stop, Configuration configuration, Rml rml, bool generateHive, bool lightInksInstalled, bool useLightInks = false, bool forFineTuning = false); Task<ConversionOutput> ConvertAsync(BrushStop stop, bool generateHive, bool useLightInks = false); Task<ConversionOutput> ConvertAsync(Job job, Color color, bool generateHive, bool useLightInks = false); bool IsOutOfGamut(BrushStop stop); diff --git a/Software/Visual_Studio/Tango.PMR/ColorLab/ConversionInput.cs b/Software/Visual_Studio/Tango.PMR/ColorLab/ConversionInput.cs index a1f1538d3..aa55383a7 100644 --- a/Software/Visual_Studio/Tango.PMR/ColorLab/ConversionInput.cs +++ b/Software/Visual_Studio/Tango.PMR/ColorLab/ConversionInput.cs @@ -24,7 +24,7 @@ namespace Tango.PMR.ColorLab { string.Concat( "ChVDb252ZXJzaW9uSW5wdXQucHJvdG8SElRhbmdvLlBNUi5Db2xvckxhYhoW", "SW5wdXRDb29yZGluYXRlcy5wcm90bxoQQ29sb3JTcGFjZS5wcm90bxoSUHJv", - "Y2Vzc1JhbmdlLnByb3RvItIDCg9Db252ZXJzaW9uSW5wdXQSDwoHVGhyZWFk", + "Y2Vzc1JhbmdlLnByb3RvIukDCg9Db252ZXJzaW9uSW5wdXQSDwoHVGhyZWFk", "TBgBIAEoARIPCgdUaHJlYWRBGAIgASgBEg8KB1RocmVhZEIYAyABKAESMgoK", "Q29sb3JTcGFjZRgEIAEoDjIeLlRhbmdvLlBNUi5Db2xvckxhYi5Db2xvclNw", "YWNlEj4KEElucHV0Q29vcmRpbmF0ZXMYBSABKAsyJC5UYW5nby5QTVIuQ29s", @@ -34,12 +34,13 @@ namespace Tango.PMR.ColorLab { "UmFuZ2VzGAsgAygLMiAuVGFuZ28uUE1SLkNvbG9yTGFiLlByb2Nlc3NSYW5n", "ZRIUCgxHZW5lcmF0ZUhpdmUYDCABKAgSFAoMVXNlTGlnaHRJbmtzGA0gASgI", "EgwKBFZNYXgYDiABKAESDwoHR2JkRGF0YRgPIAEoDBIPCgdMdWJEYXRhGBAg", - "ASgMEh0KFVVzZUx1YnJpY2FudFRyYW5zZm9ybRgRIAEoCEIeChxjb20udHdp", - "bmUudGFuZ28ucG1yLmNvbG9ybGFiYgZwcm90bzM=")); + "ASgMEh0KFVVzZUx1YnJpY2FudFRyYW5zZm9ybRgRIAEoCBIVCg1Gb3JGaW5l", + "VHVuaW5nGBIgASgIQh4KHGNvbS50d2luZS50YW5nby5wbXIuY29sb3JsYWJi", + "BnByb3RvMw==")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { global::Tango.PMR.ColorLab.InputCoordinatesReflection.Descriptor, global::Tango.PMR.ColorLab.ColorSpaceReflection.Descriptor, global::Tango.PMR.ColorLab.ProcessRangeReflection.Descriptor, }, new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.ColorLab.ConversionInput), global::Tango.PMR.ColorLab.ConversionInput.Parser, new[]{ "ThreadL", "ThreadA", "ThreadB", "ColorSpace", "InputCoordinates", "ForwardData", "InverseData", "SegmentLength", "DeltaChroma", "DeltaL", "ProcessRanges", "GenerateHive", "UseLightInks", "VMax", "GbdData", "LubData", "UseLubricantTransform" }, null, null, null) + new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.ColorLab.ConversionInput), global::Tango.PMR.ColorLab.ConversionInput.Parser, new[]{ "ThreadL", "ThreadA", "ThreadB", "ColorSpace", "InputCoordinates", "ForwardData", "InverseData", "SegmentLength", "DeltaChroma", "DeltaL", "ProcessRanges", "GenerateHive", "UseLightInks", "VMax", "GbdData", "LubData", "UseLubricantTransform", "ForFineTuning" }, null, null, null) })); } #endregion @@ -87,6 +88,7 @@ namespace Tango.PMR.ColorLab { gbdData_ = other.gbdData_; lubData_ = other.lubData_; useLubricantTransform_ = other.useLubricantTransform_; + forFineTuning_ = other.forFineTuning_; } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -280,6 +282,17 @@ namespace Tango.PMR.ColorLab { } } + /// <summary>Field number for the "ForFineTuning" field.</summary> + public const int ForFineTuningFieldNumber = 18; + private bool forFineTuning_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool ForFineTuning { + get { return forFineTuning_; } + set { + forFineTuning_ = value; + } + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as ConversionInput); @@ -310,6 +323,7 @@ namespace Tango.PMR.ColorLab { if (GbdData != other.GbdData) return false; if (LubData != other.LubData) return false; if (UseLubricantTransform != other.UseLubricantTransform) return false; + if (ForFineTuning != other.ForFineTuning) return false; return true; } @@ -333,6 +347,7 @@ namespace Tango.PMR.ColorLab { if (GbdData.Length != 0) hash ^= GbdData.GetHashCode(); if (LubData.Length != 0) hash ^= LubData.GetHashCode(); if (UseLubricantTransform != false) hash ^= UseLubricantTransform.GetHashCode(); + if (ForFineTuning != false) hash ^= ForFineTuning.GetHashCode(); return hash; } @@ -408,6 +423,10 @@ namespace Tango.PMR.ColorLab { output.WriteRawTag(136, 1); output.WriteBool(UseLubricantTransform); } + if (ForFineTuning != false) { + output.WriteRawTag(144, 1); + output.WriteBool(ForFineTuning); + } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -462,6 +481,9 @@ namespace Tango.PMR.ColorLab { if (UseLubricantTransform != false) { size += 2 + 1; } + if (ForFineTuning != false) { + size += 2 + 1; + } return size; } @@ -522,6 +544,9 @@ namespace Tango.PMR.ColorLab { if (other.UseLubricantTransform != false) { UseLubricantTransform = other.UseLubricantTransform; } + if (other.ForFineTuning != false) { + ForFineTuning = other.ForFineTuning; + } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -603,6 +628,10 @@ namespace Tango.PMR.ColorLab { UseLubricantTransform = input.ReadBool(); break; } + case 144: { + ForFineTuning = input.ReadBool(); + break; + } } } } diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericUpDownConrol.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericUpDownConrol.cs index 2b85e8168..d12dd27b6 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericUpDownConrol.cs +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericUpDownConrol.cs @@ -60,6 +60,17 @@ namespace Tango.Touch.Controls public static readonly DependencyProperty MaxValueProperty = DependencyProperty.Register("MaxValue", typeof(double), typeof(TouchNumericUpDownConrol), new PropertyMetadata(100.0)); + public double Step + { + get { return (double)GetValue(StepProperty); } + set { SetValue(StepProperty, value); } + } + + /// <summary> + /// The slider minimum value property + /// </summary> + public static readonly DependencyProperty StepProperty = + DependencyProperty.Register("Step", typeof(double), typeof(TouchNumericUpDownConrol), new PropertyMetadata(1.0)); public double NumericPartWidth @@ -105,11 +116,11 @@ namespace Tango.Touch.Controls { IncrementCommand = new RelayCommand(()=> { - Value += 1; - } , (x)=> { return (Value + 1) <= MaxValue; }); + Value += Step; + } , (x)=> { return (Value + Step) <= MaxValue; }); DecrementCommand = new RelayCommand(() => { - Value -= 1; - }, (x) => { return (Value - 1) >= MinValue; }); + Value -= Step; + }, (x) => { return (Value - Step) >= MinValue; }); _changedFromAnotherControl = false; } diff --git a/Software/Visual_Studio/Tango.Touch/Styles/TouchNumericUpDownControl.xaml b/Software/Visual_Studio/Tango.Touch/Styles/TouchNumericUpDownControl.xaml index 961b22c0f..3978e6c4c 100644 --- a/Software/Visual_Studio/Tango.Touch/Styles/TouchNumericUpDownControl.xaml +++ b/Software/Visual_Studio/Tango.Touch/Styles/TouchNumericUpDownControl.xaml @@ -82,7 +82,7 @@ </RepeatButton> <controls:TouchNumericTextBox x:Name="Number_PART" Margin="50 4 0 0" FontSize="{StaticResource TangoMessageBoxMessageFontSize}" HorizontalContentAlignment="Center" VerticalAlignment="Center" BorderBrush="{TemplateBinding BorderBrush}" VerticalContentAlignment="Center" UpdateBindingOnlyWhenFocused="True" - Value="{Binding Value,RelativeSource={RelativeSource AncestorType=controls:TouchNumericUpDownConrol}, Mode=TwoWay}" Minimum="{Binding MinValue,RelativeSource={RelativeSource AncestorType=controls:TouchNumericUpDownConrol}}" Maximum="{Binding MaxValue,RelativeSource={RelativeSource AncestorType=controls:TouchNumericUpDownConrol}, Mode=TwoWay}" HideUnderline="True"/> + Value="{Binding Value,RelativeSource={RelativeSource AncestorType=controls:TouchNumericUpDownConrol}, Mode=TwoWay}" Minimum="{Binding MinValue,RelativeSource={RelativeSource AncestorType=controls:TouchNumericUpDownConrol}}" Maximum="{Binding MaxValue,RelativeSource={RelativeSource AncestorType=controls:TouchNumericUpDownConrol}, Mode=TwoWay}" HideUnderline="True" HasDecimalPoint="True"/> <RepeatButton Background="Transparent" Height="40" Margin="50 0 0 0" Padding="2" Style="{StaticResource emptyButton}" Command="{Binding Path=IncrementCommand,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=controls:TouchNumericUpDownConrol}, Mode=TwoWay}" VerticalAlignment="Center"> @@ -94,5 +94,93 @@ </Setter.Value> </Setter> </Style> + <Style x:Key="TouchNumericBorderUpDownControl" TargetType="{x:Type controls:TouchNumericUpDownConrol}"> + <Setter Property="Background" Value="{StaticResource TangoNotificationBarMaskBrush}"/> + <Setter Property="Height" Value="40"/> + <Setter Property="Width" Value="160"/> + <Setter Property="BorderBrush" Value="{StaticResource TangoDividerBrush}"/> + <Setter Property="Template"> + <Setter.Value> + <ControlTemplate TargetType="controls:TouchNumericUpDownConrol"> + <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="0.6" Height="{TemplateBinding Height}"> + <Grid Width="{TemplateBinding Width}"> + <Grid.Resources> + <Style x:Key="emptyButton" TargetType="RepeatButton" > + <Setter Property="Background" Value="Transparent" /> + <Setter Property="Focusable" Value="False"></Setter> + <Setter Property="Foreground" Value="{StaticResource TangoMidAccentBrush}" /> + <Setter Property="Stylus.IsPressAndHoldEnabled" Value="False"/> + <Setter Property="Template"> + <Setter.Value> + <ControlTemplate TargetType="RepeatButton"> + <Border Margin="{TemplateBinding Padding}" Background="{TemplateBinding Background}"> + <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" /> + </Border> + </ControlTemplate> + </Setter.Value> + </Setter> + <Style.Triggers> + <Trigger Property="RepeatButton.IsPressed" Value="True"> + <Setter Property="Background" Value="Transparent" /> + <Setter Property="Foreground" Value="{StaticResource TangoKeyboardKeyLightBrush}" /> + </Trigger> + <EventTrigger RoutedEvent="RepeatButton.TouchDown"> + <EventTrigger.Actions> + <BeginStoryboard> + <Storyboard> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource TransparentBrush}"></DiscreteObjectKeyFrame> + </ObjectAnimationUsingKeyFrames> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource TangoKeyboardKeyLightTextBrush}"></DiscreteObjectKeyFrame> + </ObjectAnimationUsingKeyFrames> + </Storyboard> + </BeginStoryboard> + </EventTrigger.Actions> + </EventTrigger> + <EventTrigger RoutedEvent="RepeatButton.TouchLeave"> + <EventTrigger.Actions> + <BeginStoryboard> + <Storyboard> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource TransparentBrush}"></DiscreteObjectKeyFrame> + </ObjectAnimationUsingKeyFrames> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource TangoKeyboardKeyDarkTextBrush}"></DiscreteObjectKeyFrame> + </ObjectAnimationUsingKeyFrames> + </Storyboard> + </BeginStoryboard> + </EventTrigger.Actions> + </EventTrigger> + </Style.Triggers> + </Style> + </Grid.Resources> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="1*"/> + <ColumnDefinition Width="1*"/> + <ColumnDefinition Width="1*"/> + </Grid.ColumnDefinitions> + + <RepeatButton Margin="2 0 2 0" Background="Transparent" BorderBrush="Transparent" HorizontalAlignment="Stretch" HorizontalContentAlignment="Center" Height="{TemplateBinding Height}" VerticalContentAlignment="Stretch" Padding="2" Style="{StaticResource emptyButton}" Command="{Binding Path=DecrementCommand,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=controls:TouchNumericUpDownConrol}, Mode=TwoWay}" VerticalAlignment="Stretch" KeyboardNavigation.TabNavigation ="None"> + <controls:TouchIcon Icon="Minus" Width="22" Height="Auto" VerticalAlignment="Center"/> + </RepeatButton> + + <Rectangle DockPanel.Dock="Right" Width="0.6" Fill="{Binding RelativeSource={RelativeSource AncestorType=controls:TouchNumericUpDownConrol}, Path= BorderBrush}" Height="32" HorizontalAlignment="Right"></Rectangle> + + <controls:TouchNumericTextBox x:Name="Number_PART" Grid.Column="1" Margin="1 4 1 0" FontSize="{StaticResource TangoMessageBoxMessageFontSize}" HorizontalAlignment="Stretch" HorizontalContentAlignment="Center" VerticalAlignment="Center" BorderBrush="Transparent" VerticalContentAlignment="Center" UpdateBindingOnlyWhenFocused="True" + Value="{Binding Value,RelativeSource={RelativeSource AncestorType=controls:TouchNumericUpDownConrol}, Mode=TwoWay}" Minimum="{Binding MinValue,RelativeSource={RelativeSource AncestorType=controls:TouchNumericUpDownConrol}}" Maximum="{Binding MaxValue,RelativeSource={RelativeSource AncestorType=controls:TouchNumericUpDownConrol}, Mode=TwoWay}" HideUnderline="True" HasDecimalPoint="True" KeyboardNavigation.TabNavigation="Continue"/> + + <Rectangle Grid.Column="1" Width="0.6" Fill="{Binding RelativeSource={RelativeSource AncestorType=controls:TouchNumericUpDownConrol}, Path= BorderBrush}" Height="40" HorizontalAlignment="Right"></Rectangle> + + <RepeatButton Grid.Column="2" Background="Transparent" BorderBrush="Transparent" Margin="0 0 0 0" Padding="2" Style="{StaticResource emptyButton}" Command="{Binding Path=IncrementCommand,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=controls:TouchNumericUpDownConrol}, Mode=TwoWay}" VerticalAlignment="Center" HorizontalAlignment="Stretch" HorizontalContentAlignment="Center" KeyboardNavigation.TabNavigation ="None"> + <controls:TouchIcon Icon="Plus" Width="22" VerticalAlignment="Center"/> + </RepeatButton> + + </Grid> + </Border> + </ControlTemplate> + </Setter.Value> + </Setter> + </Style> </ResourceDictionary>
\ No newline at end of file |
