diff options
| author | Roy Ben-Shabat <Roy.mail.net@gmail.com> | 2022-05-24 16:03:33 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy.mail.net@gmail.com> | 2022-05-24 16:03:33 +0300 |
| commit | d63f3dcebd33aa7ea925dca33c63fc9994526c1b (patch) | |
| tree | 05ba9875a598e8e9cb11785571109393a46546e4 /Software | |
| parent | af1b5b025b7f2e7d2d70ce02d7004c439325c9b3 (diff) | |
| parent | 98b1a778572c2384ada8bd6b1ec799a8eb896d49 (diff) | |
| download | Tango-d63f3dcebd33aa7ea925dca33c63fc9994526c1b.tar.gz Tango-d63f3dcebd33aa7ea925dca33c63fc9994526c1b.zip | |
Merged PPC VFT
Diffstat (limited to 'Software')
58 files changed, 2812 insertions, 250 deletions
diff --git a/Software/PMR/Messages/Exports/JobFile.proto b/Software/PMR/Messages/Exports/JobFile.proto index 3516076cd..f409e09f5 100644 --- a/Software/PMR/Messages/Exports/JobFile.proto +++ b/Software/PMR/Messages/Exports/JobFile.proto @@ -29,4 +29,5 @@ message JobFile double LengthPercentageFactor = 20; repeated JobFileSegment Segments = 21; string ColorCatalogGuid = 22; + int32 Version = 23; }
\ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ColorCorrectionTool/TrialsLogEngine.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ColorCorrectionTool/TrialsLogEngine.cs new file mode 100644 index 000000000..97d6307fe --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ColorCorrectionTool/TrialsLogEngine.cs @@ -0,0 +1,80 @@ +using LiteDB; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.PPC.Jobs.Models; + +namespace Tango.PPC.Jobs.ColorCorrectionTool +{ + public class TrialsLogEngine : IDisposable + { + private LiteDatabase _db; + private ILiteCollection<TestColor> _collection; + + private static Lazy<TrialsLogEngine> _default = new Lazy<TrialsLogEngine>(() => new TrialsLogEngine()); + + public static TrialsLogEngine Default + { + get + { + return _default.Value; + } + } + + private TrialsLogEngine() + { + Init(); + } + + private void Init() + { + String dbFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Twine", "Tango", "Test Color"); + Directory.CreateDirectory(dbFolder); + _db = new LiteDatabase($"Filename={Path.Combine(dbFolder, "test_color.db")}"); + _collection = _db.GetCollection<TestColor>("TestColor"); + } + + public void UpdateTest(TestColor test) + { + _collection.Update(test); + } + + public void AddTest(TestColor test) + { + _collection.Insert(test); + } + + public List<TestColor> GetAll() + { + return _collection.FindAll().ToList(); + } + + public TestColor GetByBrushStopGuid(String brushStopGuid) + { + return _collection.FindOne(x => x.BrushStopGuid == brushStopGuid); + } + + ~TrialsLogEngine() + { + Dispose(); + } + + public void Dispose() + { + try + { + _db?.Dispose(); + } + catch { } + } + + public void Delete(TestColor test) + { + _collection.Delete(test.BrushStopGuid); + } + } +} + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionView.xaml index 9b95fbb5c..c4d35c1b7 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionView.xaml @@ -30,6 +30,7 @@ <BitmapImage x:Key="Close_mycolorsdlg" UriSource="../Images/ColorSelection/close_mycolorsdlg.png" /> <BitmapImage x:Key="Add_group_mycolors" UriSource="../Images/ColorSelection/add_group.png" /> <BitmapImage x:Key="Close_SaveMyColor" UriSource="../Images/ColorSelection/arrow_top_bottom.png"/> + <BitmapImage x:Key="VFineTuning_Dialog" UriSource="../Images/ColorSelection/VFineTuning.png"/> <Style TargetType="{x:Type ListBox}" x:Key="ListBoxVerticalScroll" BasedOn="{StaticResource BlankListBox}"> <Setter Property="BorderThickness" Value="0"></Setter> @@ -140,17 +141,17 @@ <touch:TouchToggleButton Canvas.Left="0" Canvas.Top="0" x:Name="addColorToGroup" EnableDropShadow="False" Foreground="{StaticResource TangoKeyboardKeyDarkTextBrush}" Background="Transparent" BorderThickness="0" Command="{Binding SaveMyColorsCommand}" IsEnabled="{Binding SelectedBrushStop.IsLiquidVolumesOutOfRange, Converter={StaticResource BooleanInverseConverter}}"> <touch:TouchToggleButton.Style > - <Style TargetType="touch:TouchToggleButton" > - <Setter Property="Background" Value="{StaticResource TangoPrimaryAccentBrush}"/> - <Setter Property="Foreground" Value="{StaticResource TangoLightForegroundBrush}"/> - <Style.Triggers> - <Trigger Property="IsEnabled" Value="False"> - <Setter Property="Foreground" Value="{StaticResource TangoLightForegroundBrush}"></Setter> - <Setter Property="Background" Value="{StaticResource TangoPrimaryAccentBrush}"></Setter> - </Trigger> - </Style.Triggers> - </Style> - </touch:TouchToggleButton.Style> + <Style TargetType="touch:TouchToggleButton" > + <Setter Property="Background" Value="{StaticResource TangoPrimaryAccentBrush}"/> + <Setter Property="Foreground" Value="{StaticResource TangoLightForegroundBrush}"/> + <Style.Triggers> + <Trigger Property="IsEnabled" Value="False"> + <Setter Property="Foreground" Value="{StaticResource TangoLightForegroundBrush}"></Setter> + <Setter Property="Background" Value="{StaticResource TangoPrimaryAccentBrush}"></Setter> + </Trigger> + </Style.Triggers> + </Style> + </touch:TouchToggleButton.Style> <Border Height="26" Width="28" BorderThickness="0" BorderBrush="{StaticResource TangoKeyboardKeyDarkBrush}" Background="Transparent" HorizontalAlignment="Left"> <Image Stretch="Fill" RenderOptions.BitmapScalingMode="Fant"> <Image.Style> @@ -166,7 +167,7 @@ </Style.Triggers> </Style> </Image.Style> - </Image> + </Image> </Border> </touch:TouchToggleButton> </Canvas> @@ -238,10 +239,10 @@ <ItemsControl.ItemTemplate> <DataTemplate DataType="{ x:Type models:FavoriteColor}"> <Grid Margin="0 0 34 0" HorizontalAlignment="Left" VerticalAlignment="Top"> - <Grid.RowDefinitions> - <RowDefinition Height="65"/> - <RowDefinition Height="1*"/> - </Grid.RowDefinitions> + <Grid.RowDefinitions> + <RowDefinition Height="65"/> + <RowDefinition Height="1*"/> + </Grid.RowDefinitions> <Border Background="{Binding Brush}" Width="65" Height="65" CornerRadius="10" BorderBrush="{StaticResource TangoKeyboardKeyDarkBrush}" HorizontalAlignment="Left" Visibility="{Binding DataContext.EditColorsGroupMode , ElementName=colorLibraryList , Converter={StaticResource BooleanToVisibilityInverseConverter}}"> <touch:TouchButton Width="65" Height="65" EnableDropShadow="False" Background="Transparent" BorderThickness="0" Command="{Binding DataContext.SelectColorCommand , ElementName=colorSelectionView}" CommandParameter="{Binding }" /> </Border> @@ -259,7 +260,7 @@ </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> - + </DockPanel> </DataTemplate> @@ -275,21 +276,21 @@ <Border Background="{StaticResource TangoPrimaryBackgroundBrush}" CornerRadius="12" BorderThickness="0" Padding="10" MinHeight="100" Margin="0 20 0 0"> <StackPanel Orientation="Vertical"> <Grid Margin="14 10 14 10" > - <ListBox HorizontalAlignment="Stretch" MaxHeight="320" ItemsSource="{Binding Libraries}" Style="{StaticResource ListBoxVerticalScroll}" + <ListBox HorizontalAlignment="Stretch" MaxHeight="320" ItemsSource="{Binding Libraries}" Style="{StaticResource ListBoxVerticalScroll}" ScrollViewer.VerticalScrollBarVisibility="Visible" > - <ListBox.ItemsPanel> - <ItemsPanelTemplate> - <WrapPanel Orientation="Vertical" /> - </ItemsPanelTemplate> - </ListBox.ItemsPanel> - <ListBox.ItemTemplate> - <DataTemplate DataType="{x:Type models:ColorLibrary}"> - <touch:TouchButton Command="{Binding DataContext.AddColorToLibraryCommand, ElementName=colorSelectionView}" Style="{StaticResource TangoFlatButton}" CommandParameter="{Binding }" Background="Transparent"> - <TextBlock Text="{Binding Name}" FontSize="{StaticResource TangoButtonFontSize}"></TextBlock> - </touch:TouchButton> - </DataTemplate> - </ListBox.ItemTemplate> - </ListBox> + <ListBox.ItemsPanel> + <ItemsPanelTemplate> + <WrapPanel Orientation="Vertical" /> + </ItemsPanelTemplate> + </ListBox.ItemsPanel> + <ListBox.ItemTemplate> + <DataTemplate DataType="{x:Type models:ColorLibrary}"> + <touch:TouchButton Command="{Binding DataContext.AddColorToLibraryCommand, ElementName=colorSelectionView}" Style="{StaticResource TangoFlatButton}" CommandParameter="{Binding }" Background="Transparent"> + <TextBlock Text="{Binding Name}" FontSize="{StaticResource TangoButtonFontSize}"></TextBlock> + </touch:TouchButton> + </DataTemplate> + </ListBox.ItemTemplate> + </ListBox> </Grid> <Rectangle Height="1" HorizontalAlignment="Stretch" Fill="{StaticResource TangoDividerBrush}"></Rectangle> <StackPanel Orientation="Horizontal" Height="60" Margin="20 10 0 20" Visibility="{Binding AddGroupMode, Converter={StaticResource BooleanToVisibilityInverseConverter}}" > @@ -334,13 +335,14 @@ </Border> <Grid Grid.Row="1" Background="{StaticResource TangoPrimaryBackgroundBrush}" Margin="10"> <Grid.RowDefinitions> - <RowDefinition Height="100"/> + <RowDefinition Height="60.6"/> + <RowDefinition Height="39.4"/> <RowDefinition Height="1*"/> </Grid.RowDefinitions> <touch:TouchNavigationLinks x:Name="navigationCSTLinks" SelectionChanged="TouchNavigationLinks_SelectionChanged" - SelectedIndex="{Binding SelectedColorTabIndex,Mode=TwoWay}" VerticalAlignment="Bottom" Margin="20" - FontSize="{StaticResource TangoNavigationLinksFontSize}" HorizontalContentAlignment="Stretch" PreviewMouseDown="TouchNavigationLinks_OnPreviewMouseDown"> + SelectedIndex="{Binding SelectedColorTabIndex,Mode=TwoWay}" VerticalAlignment="Bottom" Margin="20,0,20.4,20" + FontSize="{StaticResource TangoNavigationLinksFontSize}" HorizontalContentAlignment="Stretch" PreviewMouseDown="TouchNavigationLinks_OnPreviewMouseDown" Grid.RowSpan="2"> <TextBlock HorizontalAlignment="Center" >HSB</TextBlock> <TextBlock HorizontalAlignment="Center" >CIELab</TextBlock> <TextBlock HorizontalAlignment="Center" >RGB</TextBlock> @@ -360,7 +362,7 @@ </touch:TouchNavigationLinks> - <Grid Grid.Row="1" x:Name="HSBGrid"> + <Grid Grid.Row="2" x:Name="HSBGrid" Margin="0,0,0.4,0"> <Grid Visibility="{Binding SelectedColorTab,Converter={StaticResource ColorTabToVisibilityConverter},ConverterParameter='HSB'}"> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> @@ -391,6 +393,9 @@ <RowDefinition Height="1*" /> </Grid.RowDefinitions> + <touch:TouchImageButton Grid.Row="0" Margin="0 2 45 0" HorizontalAlignment="Right" Width="70" EnableDropShadow="False" Background="Transparent" BorderThickness="0" + Command="{ Binding VectorFineTuningCommand}" Image="{StaticResource VFineTuning_Dialog}"/> + <ContentControl Name="myLabColors" Grid.Row="0" ContentTemplate="{StaticResource myColorsBtn}" Content="{Binding}"/> <ContentControl Name="segmentContentLab" Grid.Row="1" ContentTemplate="{StaticResource brushColorPanel}" Content="{Binding}"/> @@ -403,6 +408,8 @@ Margin="0 0 0 0" MinWidth="200" BorderBrush="{StaticResource TangoKeyboardKeyDarkTextBrush}" + PreviewTouchDown="LABPicker_PreviewTouchDown" + PreviewMouseDown="LABPicker_OnPreviewMouseDown" L="{Binding SelectedBrushStop.L, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" A="{Binding SelectedBrushStop.A, Mode=TwoWay}" B="{ Binding SelectedBrushStop.B, Mode=TwoWay}" /> </Grid> @@ -490,7 +497,7 @@ </Grid> <!--<commonControls:TwineCatalogControl Margin="0 30 0 0 " DataContext="{Binding SelectedCatalog, Mode=TwoWay}" SelectedItem="{Binding DataContext.ColorCatalogsItem, Mode=TwoWay, ElementName=catalogsGrid, UpdateSourceTrigger=PropertyChanged, Delay=500}" />--> - + <controls:TwineCatalogViewer Margin="80 0 0 0 " Catalog="{Binding SelectedCatalog, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" SelectedItem="{Binding SelectedBrushStop.ColorCatalogsItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" CollectionFilter="{Binding CollectionFilter, Mode=OneWay}"/> </DockPanel> <Grid Grid.Row="2" Margin="60 27 30 40"> @@ -512,41 +519,44 @@ <DropShadowEffect Opacity="0.5" ShadowDepth="6" Color="Silver" BlurRadius="10" Direction="270"/> </Border.Effect> <Border CornerRadius="20" Background="{StaticResource TangoPrimaryBackgroundBrush}"> - <Grid> - <DockPanel > - <Grid DockPanel.Dock="Bottom" Height="137"> - <Rectangle Height="1" Stroke="{StaticResource TangoDividerBrush}" HorizontalAlignment="Stretch"/> - <Grid Margin="48 50 0 0" > - <Grid.ColumnDefinitions> - <ColumnDefinition Width="Auto"/> - <ColumnDefinition Width="1*"/> - </Grid.ColumnDefinitions> - <touch:TouchImageButton HorizontalAlignment="Left" Width="28" Height="38" Margin="0 20 23 0" EnableDropShadow="False" Background="Transparent" BorderThickness="0" Command="{ Binding AddGroupCommand}" Image="{StaticResource Add_group_mycolors}"/> - <TextBlock Grid.Column="1" Margin="20 20 0 0" HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="{StaticResource TangoButtonFontSize}" FontWeight="SemiBold" Visibility="{Binding AddGroupMode, Converter={StaticResource BooleanToVisibilityInverseConverter}}">Add Group</TextBlock> - <DockPanel Visibility="{Binding AddGroupMode, Converter={StaticResource BooleanToVisibilityConverter}}" Grid.Column="1" Margin=" 20 0 0 20"> - <touch:TouchTextBox DockPanel.Dock="Left" Margin="0 0 80 0" x:Name="newGroupNametext" MinWidth="200" Height="Auto" Text="{Binding NewGroupName, Mode=TwoWay,UpdateSourceTrigger=LostFocus}"></touch:TouchTextBox> - <touch:TouchButton DockPanel.Dock="Right" Width="160" Height="40" CornerRadius="20" Background="Transparent" EnableDropShadow="False" TextElement.Foreground="{StaticResource TangoKeyboardKeyDarkTextBrush}" HorizontalAlignment="Right" Margin="10 26 20 0" VerticalAlignment="Bottom" + <Grid> + <DockPanel > + <Grid DockPanel.Dock="Bottom" Height="137"> + <Rectangle Height="1" Stroke="{StaticResource TangoDividerBrush}" HorizontalAlignment="Stretch"/> + <Grid Margin="48 50 0 0" > + <Grid.ColumnDefinitions> + <ColumnDefinition Width="Auto"/> + <ColumnDefinition Width="1*"/> + </Grid.ColumnDefinitions> + <touch:TouchImageButton HorizontalAlignment="Left" Width="28" Height="38" Margin="0 20 23 0" EnableDropShadow="False" Background="Transparent" BorderThickness="0" Command="{ Binding AddGroupCommand}" Image="{StaticResource Add_group_mycolors}"/> + <TextBlock Grid.Column="1" Margin="20 20 0 0" HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="{StaticResource TangoButtonFontSize}" FontWeight="SemiBold" Visibility="{Binding AddGroupMode, Converter={StaticResource BooleanToVisibilityInverseConverter}}">Add Group</TextBlock> + <DockPanel Visibility="{Binding AddGroupMode, Converter={StaticResource BooleanToVisibilityConverter}}" Grid.Column="1" Margin=" 20 0 0 20"> + <touch:TouchTextBox DockPanel.Dock="Left" Margin="0 0 80 0" x:Name="newGroupNametext" MinWidth="200" Height="Auto" Text="{Binding NewGroupName, Mode=TwoWay,UpdateSourceTrigger=LostFocus}"></touch:TouchTextBox> + <touch:TouchButton DockPanel.Dock="Right" Width="160" Height="40" CornerRadius="20" Background="Transparent" EnableDropShadow="False" TextElement.Foreground="{StaticResource TangoKeyboardKeyDarkTextBrush}" HorizontalAlignment="Right" Margin="10 26 20 0" VerticalAlignment="Bottom" BorderThickness="1" BorderBrush="{StaticResource TangoKeyboardKeyDarkBrush}" Command="{Binding AddNewGroupCommand}" CommandParameter="{Binding ElementName=newGroupNametext, Path=Text}">Add</touch:TouchButton> - </DockPanel> + </DockPanel> + </Grid> </Grid> - </Grid> - <DockPanel x:Name="headerPanel" Height="122" DockPanel.Dock="Top"> - <Rectangle DockPanel.Dock="Bottom" Margin="43 0 63 10" Height="1" Stroke="{StaticResource TangoDividerBrush}" VerticalAlignment="Bottom"/> - <TextBlock DockPanel.Dock="Left" Margin="43 53 0 28" HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="{StaticResource TangoHeaderFontSize}" FontWeight="SemiBold">My Colors</TextBlock> - <touch:TouchImageButton DockPanel.Dock="Top" Width="32" Height="32" Image="{StaticResource Close_mycolorsdlg}" HorizontalAlignment="Right" Margin="0 20 23 0" EnableDropShadow="False" Background="Transparent" BorderThickness="0" Command="{Binding CloseMyColorsCommand}"/> - </DockPanel> - <Grid> - <ListBox x:Name="listLibraries" Grid.Row="1" Margin="10 0 10 60" ItemsSource="{Binding Libraries}" Style="{StaticResource ListBoxVerticalScroll}" + <DockPanel x:Name="headerPanel" Height="122" DockPanel.Dock="Top"> + <Rectangle DockPanel.Dock="Bottom" Margin="43 0 63 10" Height="1" Stroke="{StaticResource TangoDividerBrush}" VerticalAlignment="Bottom"/> + <TextBlock DockPanel.Dock="Left" Margin="43 53 0 28" HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="{StaticResource TangoHeaderFontSize}" FontWeight="SemiBold">My Colors</TextBlock> + <touch:TouchImageButton DockPanel.Dock="Top" Width="32" Height="32" Image="{StaticResource Close_mycolorsdlg}" HorizontalAlignment="Right" Margin="0 20 23 0" EnableDropShadow="False" Background="Transparent" BorderThickness="0" Command="{Binding CloseMyColorsCommand}"/> + </DockPanel> + <Grid> + <ListBox x:Name="listLibraries" Grid.Row="1" Margin="10 0 10 60" ItemsSource="{Binding Libraries}" Style="{StaticResource ListBoxVerticalScroll}" ScrollViewer.VerticalScrollBarVisibility="Visible" Width="560" ItemTemplate="{StaticResource ColorLibrary_Template}"> - </ListBox> - </Grid> - </DockPanel> - </Grid> - </Border> + </ListBox> + </Grid> + </DockPanel> + </Grid> </Border> + </Border> </Grid> </Border> + <Border Visibility="{Binding IsOpenVectorFineTuningDialog, Converter={StaticResource BooleanToVisibilityConverter}}"> + <local:VectorFineTuningDialog DataContext="{Binding VectorFineTuningDialogVM}" /> + </Border> </Grid> </UserControl> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionView.xaml.cs index 4f18dc853..3400ca55c 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionView.xaml.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionView.xaml.cs @@ -12,7 +12,6 @@ using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; -using Tango.PPC.Jobs.ViewModels; namespace Tango.PPC.Jobs.Dialogs { @@ -66,5 +65,27 @@ namespace Tango.PPC.Jobs.Dialogs { } + + private async void LABPicker_PreviewTouchDown(object sender, TouchEventArgs e) + { + if (_vm != null) + { + if (false == await _vm.NotifyAboutTrialsData()) + { + e.Handled = true; + } + } + } + + private async void LABPicker_OnPreviewMouseDown(object sender, MouseButtonEventArgs e) + { + if (_vm != null) + { + if (false == await _vm.NotifyAboutTrialsData()) + { + e.Handled = true; + } + } + } } } 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 431e8696b..cd51334a5 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 @@ -16,6 +16,7 @@ using Tango.Core.Threading; using Tango.PPC.Common; using Tango.PPC.Common.Navigation; using Tango.PPC.Common.Notifications; +using Tango.PPC.Jobs.ColorCorrectionTool; using Tango.PPC.Jobs.Models; using Tango.PPC.Jobs.MyColors; using Tango.PPC.Jobs.NavigationObjects; @@ -40,6 +41,7 @@ namespace Tango.PPC.Jobs.Dialogs [Description("Catalog")] Catalog = 2 } + public class DialogObject { @@ -388,7 +390,23 @@ namespace Tango.PPC.Jobs.Dialogs } } + private bool _isOpenVectorFineTuningDialog; + + public bool IsOpenVectorFineTuningDialog + { + get { return _isOpenVectorFineTuningDialog; } + set { _isOpenVectorFineTuningDialog = value; + RaisePropertyChangedAuto();} + } + + private VectorFineTuningDialogVM _vectorFineTuningDialogVM; + public VectorFineTuningDialogVM VectorFineTuningDialogVM + { + get { return _vectorFineTuningDialogVM; } + set { _vectorFineTuningDialogVM = value; RaisePropertyChangedAuto(); } + } + #endregion #region commands @@ -411,6 +429,8 @@ namespace Tango.PPC.Jobs.Dialogs public RelayCommand<ColorLibrary> EditColorsLibraryCommand { get; set; } public RelayCommand<FavoriteColor> DeleteColorCommand { get; set; } + public RelayCommand VectorFineTuningCommand { get; set; } + #endregion public ColorSelectionViewVM() @@ -459,6 +479,10 @@ namespace Tango.PPC.Jobs.Dialogs MyColorsMode = false; EditColorsGroupMode = false; SaveMyColorMode = false; + + VectorFineTuningCommand = new RelayCommand(OpenVectorFineTuning); + IsOpenVectorFineTuningDialog = false; + VectorFineTuningDialogVM = new VectorFineTuningDialogVM(); } #region Show and Selection tab @@ -478,6 +502,7 @@ namespace Tango.PPC.Jobs.Dialogs InitialBrushStop = DialogEditObject.BrushStopForEdit; SelectedBrushStop = InitialBrushStop.Clone(); + SelectedBrushStop.Guid = InitialBrushStop.Guid; SelectedBrushStop.ColorSpace = InitialBrushStop.ColorSpace; if (SelectedBrushStop.ColorSpace == ColorSpaces.Volume) @@ -911,5 +936,57 @@ namespace Tango.PPC.Jobs.Dialogs #endregion + #region Vector Fine tuning + private void OpenVectorFineTuning() + { + VectorFineTuningDialogVM.Init( SelectedBrushStop, SelectedBrushStop.L, SelectedBrushStop.A, SelectedBrushStop.B, SelectedBrushStop.Color); + + IsOpenVectorFineTuningDialog = true; + + VectorFineTuningDialogVM.Accepted += VectorFineTuningDialogAccepted; + VectorFineTuningDialogVM.Canceled += VectorFineTuningDialogCanceled; + + //SelectedView = ColorView.ManualFineTuningView; + } + + private void VectorFineTuningDialogCanceled() + { + VectorFineTuningDialogVM.Canceled -= VectorFineTuningDialogCanceled; + IsOpenVectorFineTuningDialog = false; + } + + private void VectorFineTuningDialogAccepted() + { + VectorFineTuningDialogVM.Accepted -= VectorFineTuningDialogAccepted; + IsOpenVectorFineTuningDialog = false; + + _selectedBrushStop.PreventPropertyUpdate = true; + _selectedBrushStop.L = (double)VectorFineTuningDialogVM.SelectedLog.L; + _selectedBrushStop.A = (double)VectorFineTuningDialogVM.SelectedLog.A; + _selectedBrushStop.B = (double)VectorFineTuningDialogVM.SelectedLog.B; + _selectedBrushStop.PreventPropertyUpdate = false; + _selectedBrushStop.ConvertColor(); + + Accept(); + } + + public async Task<bool> NotifyAboutTrialsData() + { + var testColor = TrialsLogEngine.Default.GetByBrushStopGuid(SelectedBrushStop.Guid); + 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?")) + { + TrialsLogEngine.Default.Delete( testColor); + return true; + } + return false; + } + return true; + } + + + #endregion + } } 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 new file mode 100644 index 000000000..af21c5abc --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/VectorFineTuningDialog.xaml @@ -0,0 +1,394 @@ +<UserControl x:Class="Tango.PPC.Jobs.Dialogs.VectorFineTuningDialog" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:local="clr-namespace:Tango.PPC.Jobs.Dialogs" + 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" + xmlns:sharedConverters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" + xmlns:fa="http://schemas.fontawesome.io/icons/" + xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" + xmlns:appBarItems="clr-namespace:Tango.PPC.Jobs.AppBarItems" + mc:Ignorable="d" + Background="{StaticResource TangoMidBackgroundBrush}" + d:DesignHeight="1280" d:DesignWidth="800" Width="750" Height="1200" + d:DataContext="{d:DesignInstance Type=vm:VectorFineTuningDialogVM, IsDesignTimeCreatable=False}" > + + <UserControl.Resources> + <ResourceDictionary> + <ResourceDictionary.MergedDictionaries> + <ResourceDictionary Source="../Resources/Styles.xaml" /> + </ResourceDictionary.MergedDictionaries> + <sharedConverters:DateTimeUTCToShortDateTimeConverter x:Key="DateTimeUTCToShortDateTimeConverter" /> + <sharedConverters:GreaterThanToBooleanConverter x:Key="GreaterThanToBooleanConverter"/> + <BitmapImage x:Key="Close_mycolorsdlg" UriSource="../Images/ColorSelection/close_mycolorsdlg.png" /> + + <Style x:Key="GreyTextStyle" TargetType="TextBlock"> + <Setter Property="Foreground" Value="{StaticResource TangoGrayTextBrush}"></Setter> + <Setter Property="FontSize" Value="{StaticResource TangoSmallFontSize}"></Setter> + <Setter Property="VerticalAlignment" Value="Center"></Setter> + <Setter Property="HorizontalAlignment" Value="Center"></Setter> + </Style> + </ResourceDictionary> + </UserControl.Resources> + <Grid x:Name="VFTgrid" DataContext="{Binding Path=DataContext.VectorFineTuningDialogVM, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:ColorSelectionView}}}" d:DataContext="{d:DesignInstance Type=local:VectorFineTuningDialogVM, IsDesignTimeCreatable=False}"> + + <Grid.RowDefinitions> + <RowDefinition Height="Auto"/> + <RowDefinition Height="1*"/> + </Grid.RowDefinitions> + + <Border Height="90" Background="{StaticResource TangoPrimaryBackgroundBrush}" BorderThickness="0 0 0 1" BorderBrush="{StaticResource TangoDividerBrush}"> + <Grid> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="1*"/> + <ColumnDefinition Width="Auto"/> + </Grid.ColumnDefinitions> + <!--<Canvas> + <Border Canvas.Right="-20" Canvas.Top="0" BorderThickness="0 0 0 0" BorderBrush="{StaticResource TangoDividerBrush}" Margin="0 0 0 0"> + <touch:TouchImageButton Padding="0" Width="Auto" Height="32" Image="{StaticResource Close_mycolorsdlg}" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0 2 20 2" EnableDropShadow="False" Background="Transparent" BorderThickness="0" Command="{Binding CloseCommand}"/> + </Border> + </Canvas>--> + + + <Grid Visibility="{Binding IsJobRunning,Converter={StaticResource BooleanToVisibilityInverseConverter}}"> + <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="{StaticResource TangoHeaderFontSize}" FontWeight="SemiBold">Color Correction Tool</TextBlock> + </Grid> + + <Grid Visibility="{Binding IsJobRunning,Converter={StaticResource BooleanToVisibilityConverter}}" Margin="40 0 0 0"> + <DockPanel> + <StackPanel VerticalAlignment="Center" Background="Transparent" DockPanel.Dock="Right" Margin="15 0"> + <commonControls:MachineStatusControl HorizontalAlignment="Center" DataContext="{Binding MachineProvider.MachineOperator}" /> + <TextBlock Margin="0 10 0 0" Text="{Binding MachineProvider.MachineOperator.Status,Converter={StaticResource EnumToDescriptionConverter}}"></TextBlock> + </StackPanel> + + <Grid> + <appBarItems:JobProgressAppBarItemView /> + </Grid> + </DockPanel> + </Grid> + + <Grid Background="{StaticResource TangoPrimaryBackgroundBrush}" Margin="20 0 0 0" Visibility="{Binding IsJobFailed,Converter={StaticResource BooleanToVisibilityConverter}}"> + <DockPanel Margin="10"> + <touch:TouchIcon VerticalAlignment="Top" Margin="0 5 0 0" Width="42" Icon="Alert" Foreground="{StaticResource TangoErrorBrush}" /> + <Grid> + <StackPanel Margin="20 0 0 0"> + <TextBlock FontSize="{StaticResource TangoButtonFontSize}">Job Failed</TextBlock> + <TextBlock Margin="0 5 0 0" Text="{Binding JobFailedReason}" FontSize="{StaticResource TangoDefaultFontSize}"></TextBlock> + </StackPanel> + </Grid> + </DockPanel> + </Grid> + + <touch:TouchButton Grid.Column="1" Visibility="{Binding IsJobRunning,Converter={StaticResource BooleanToVisibilityInverseConverter}}" Command="{Binding TestCommand}" CornerRadius="25" Width="180" Height="50" Margin="0 2 10 2" Content="TEST" HorizontalAlignment="Right" TextElement.Foreground="{StaticResource TangoLightForegroundBrush}" EnableDropShadow="False" FontSize="{StaticResource TangoButtonFontSize}"> + <touch:TouchButton.Style > + <Style TargetType="touch:TouchButton" > + <Setter Property="Foreground" Value="{StaticResource TangoLightForegroundBrush}"></Setter> + <Setter Property="Background" Value="{StaticResource TangoPrimaryAccentBrush}"/> + <Style.Triggers> + <Trigger Property="IsEnabled" Value="False"> + <Setter Property="Foreground" Value="{StaticResource TangoDisabledForegroundBrush}"></Setter> + <Setter Property="Background" Value="{StaticResource TangoDisabledBackgroundBrush}"></Setter> + </Trigger> + </Style.Triggers> + </Style> + </touch:TouchButton.Style> + </touch:TouchButton> + <touch:TouchButton Grid.Column="1" Visibility="{Binding IsJobRunning,Converter={StaticResource BooleanToVisibilityConverter}}" Command="{Binding StopCommand}" CornerRadius="25" Width="180" Height="50" Margin="0 2 10 2" Content="STOP" HorizontalAlignment="Right" TextElement.Foreground="{StaticResource TangoLightForegroundBrush}" EnableDropShadow="False" FontSize="{StaticResource TangoButtonFontSize}"> + <touch:TouchButton.Style > + <Style TargetType="touch:TouchButton" > + <Setter Property="Foreground" Value="{StaticResource TangoLightForegroundBrush}"></Setter> + <Setter Property="Background" Value="{StaticResource TangoPrimaryAccentBrush}"/> + <Style.Triggers> + <Trigger Property="IsEnabled" Value="False"> + <Setter Property="Foreground" Value="{StaticResource TangoDisabledForegroundBrush}"></Setter> + <Setter Property="Background" Value="{StaticResource TangoDisabledBackgroundBrush}"></Setter> + </Trigger> + </Style.Triggers> + </Style> + </touch:TouchButton.Style> + </touch:TouchButton> + + + </Grid> + + </Border> + <Border Padding="24 16 24 0" Grid.Row="1" > + <Border BorderThickness="0" Background="{StaticResource TangoPrimaryBackgroundBrush}" > + <Grid > + <Grid.RowDefinitions> + <RowDefinition Height="1*"/> + <RowDefinition Height="Auto"/> + <RowDefinition Height="Auto"/> + </Grid.RowDefinitions> + + <Grid Background="{StaticResource TangoPrimaryBackgroundBrush}"> + <Grid.RowDefinitions> + <RowDefinition Height="200"></RowDefinition> + <RowDefinition Height="1*"></RowDefinition> + </Grid.RowDefinitions> + <StackPanel Orientation="Vertical"> + <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}" FontWeight="SemiBold" 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> + <UniformGrid Rows="1" Columns="3" Height="30" MinWidth="150" Margin="14 0 0 0"> + <StackPanel Orientation="Horizontal"> + <TextBlock Text="L" FontSize="{StaticResource TangoSmallFontSize}" VerticalAlignment="Center"/> + <Border Margin="10 0 0 0" Background="Transparent" BorderBrush="{StaticResource TangoGrayBrush}" BorderThickness="0.8" Width="50"> + <TextBlock Style="{StaticResource GreyTextStyle}" Text="{Binding TargetL, StringFormat=0.00}" ></TextBlock> + </Border> + </StackPanel> + <StackPanel Orientation="Horizontal" Margin="5 0 0 0"> + <TextBlock Text="a" FontSize="{StaticResource TangoSmallFontSize}" VerticalAlignment="Center"/> + <Border Margin="10 0 0 0" Background="Transparent" BorderBrush="{StaticResource TangoGrayBrush}" BorderThickness="0.8" Width="50"> + <TextBlock Style="{StaticResource GreyTextStyle}" Text="{Binding TargetA, StringFormat=0.00}" ></TextBlock> + </Border> + </StackPanel> + <StackPanel Orientation="Horizontal" Margin="10 0 0 0"> + <TextBlock Text="b" FontSize="{StaticResource TangoSmallFontSize}" VerticalAlignment="Center"/> + <Border Margin="10 0 0 0" Background="Transparent" BorderBrush="{StaticResource TangoGrayBrush}" BorderThickness="0.8" Width="50"> + <TextBlock Style="{StaticResource GreyTextStyle}" Text="{Binding TargetB, StringFormat=0.00}" ></TextBlock> + </Border> + </StackPanel> + </UniformGrid> + </StackPanel> + </StackPanel> + <Grid Grid.Row="1"> + <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}" FontWeight="SemiBold" > + <Run Text="Correction Trial #" ></Run> + <Run Text="{Binding TrialNumber, Mode=OneWay}"></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 IsJobRunning}" Value="True"> + <Setter Property="IsEnabled" Value="False"/> + </DataTrigger> + </Style.Triggers> + </Style> + </UniformGrid.Style> + <StackPanel Orientation="Horizontal"> + <TextBlock Text="L" FontSize="{StaticResource TangoComboBoxItemFontSize}" 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 TangoComboBoxItemFontSize}"/> + </StackPanel> + <StackPanel Orientation="Horizontal"> + <TextBlock Text="a" FontSize="{StaticResource TangoComboBoxItemFontSize}" 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 TangoComboBoxItemFontSize}"/> + </StackPanel> + <StackPanel Orientation="Horizontal"> + <TextBlock Text="b" FontSize="{StaticResource TangoComboBoxItemFontSize}" 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 TangoComboBoxItemFontSize}"/> + </StackPanel> + </UniformGrid> + + <UniformGrid Grid.Column="1" x:Name="cmyk_grid" Margin="0 16 0 0" Rows="4" Columns="1" Width="180" 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> + </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> + </UniformGrid> + + </Grid> + + </Grid> + </Grid> + + <Border BorderThickness="0" Grid.Row="1" > + <Border.Style > + <Style TargetType="Border"> + <Setter Property="IsEnabled" Value="True"/> + <Style.Triggers> + <DataTrigger Binding="{Binding IsJobRunning}" Value="True"> + <Setter Property="IsEnabled" Value="False"/> + </DataTrigger> + </Style.Triggers> + </Style> + </Border.Style> + <touch:TouchExpander Grid.Row="1" x:Name="trailsListExpander" IsExpanded="{Binding IsExpanderOpened, Mode=TwoWay}" Margin="0 0 0 0 " FontSize="{StaticResource TangoSmallFontSize}" BorderThickness="0" + Style="{StaticResource TouchRoundedExpander}"> + <touch:TouchExpander.Header> + <DockPanel > + <StackPanel Orientation="Horizontal" DockPanel.Dock="Right" Margin="0 0 20 0" Visibility="{Binding IsExpanderOpened, Converter={StaticResource BooleanToVisibilityConverter}, Mode=TwoWay}"> + <touch:TouchButton HorizontalAlignment="Right" VerticalAlignment="Center" EnableDropShadow="False" Background="Transparent" BorderThickness="0" Command="{Binding ClearTrialsCommand}" > + <DockPanel Width="Auto" Height="44" VerticalAlignment="Center"> + <Image Source="../Images/ColorSelection/Clear.png" Width="19" DockPanel.Dock="Top"></Image> + <TextBlock DockPanel.Dock="Bottom" Margin="0 8 0 0" VerticalAlignment="Bottom" HorizontalAlignment="Center" FontSize="{StaticResource TangoSmallFontSize}" Foreground="{StaticResource TangoDarkForegroundBrush}">Clear</TextBlock> + </DockPanel> + </touch:TouchButton> + <touch:TouchButton Margin="46 0 20 0" HorizontalAlignment="Right" VerticalAlignment="Center" EnableDropShadow="False" Background="Transparent" BorderThickness="0" Command="{Binding ExportTrialsCommand}" > + <DockPanel Width="Auto" Height="44" VerticalAlignment="Center"> + <Image Source="../Images/ColorSelection/Export.png" Width="19" DockPanel.Dock="Top"></Image> + <TextBlock DockPanel.Dock="Bottom" VerticalAlignment="Bottom" HorizontalAlignment="Center" FontSize="{StaticResource TangoSmallFontSize}" Foreground="{StaticResource TangoDarkForegroundBrush}">Export</TextBlock> + </DockPanel> + </touch:TouchButton> + </StackPanel> + <StackPanel DockPanel.Dock="Left" Orientation="Horizontal" VerticalAlignment="Center" > + <Image Source="../Images/JobView/job-summary.png" Width="39" /> + <TextBlock FontWeight="Medium" Margin="20 0 0 0" VerticalAlignment="Center"> + <Run Text="Trials Log" FontSize="{StaticResource TangoDefaultFontSize}"></Run> + <Run Text="(Max 10 Trials)" FontWeight="Normal"></Run></TextBlock> + </StackPanel> + </DockPanel> + </touch:TouchExpander.Header> + <Grid Margin=" 0 10 0 0" > + <touch:LightTouchDataGrid MaxHeight="450" AnimateSorting="False" EnableDragAndDrop="False" RenderOptions.EdgeMode="Unspecified" x:Name="dataGridTrialsLog" Style="{StaticResource TangoJobsGrid}" SelectedItem="{Binding SelectedLog, Mode=TwoWay}" SelectionMode="Single" IsMultiSelecting="False" ItemsSource="{Binding TrialsLogitems, Mode=OneWay}" Margin="0"> + <touch:LightTouchDataGrid.Resources> + <Style TargetType="{x:Type touch:LightTouchDataGridRow}"> + <Setter Property="Background" Value="{StaticResource TangoPrimaryBackgroundBrush}"></Setter> + <Setter Property="Foreground" Value="{StaticResource TangoDarkForegroundBrush}"></Setter> + <Setter Property="BorderThickness" Value="1"></Setter> + <Setter Property="BorderBrush" Value="{StaticResource TangoLightBorderBrush}"></Setter> + <Setter Property="Padding" Value="5"></Setter> + <Setter Property="CornerRadius" Value="2"></Setter> + <Setter Property="Margin" Value="5 0"></Setter> + <Setter Property="Height" Value="44"></Setter> + <Setter Property="IsEnabled" Value="True"/> + <Style.Triggers> + <DataTrigger Binding="{Binding IsSelectionEnable}" Value="False"> + <Setter Property="IsEnabled" Value="False"/> + </DataTrigger> + </Style.Triggers> + </Style> + </touch:LightTouchDataGrid.Resources> + <touch:LightTouchDataGrid.Columns> + <touch:LightTouchDataGridColumn Width="50" Header="#" > + <touch:LightTouchDataGridColumn.CellTemplate > + <DataTemplate> + <TextBlock IsHitTestVisible="False" Text="{Binding Trial}" FontSize="{StaticResource TangoSmallFontSize}" HorizontalAlignment="Left" VerticalAlignment="Center"></TextBlock> + </DataTemplate> + </touch:LightTouchDataGridColumn.CellTemplate> + </touch:LightTouchDataGridColumn> + <touch:LightTouchDataGridColumn Width="140" Header="Date" HorizontalContentAlignment="Left"> + <touch:LightTouchDataGridColumn.CellTemplate> + <DataTemplate> + <TextBlock IsHitTestVisible="False" Text="{Binding Date,Converter={StaticResource DateTimeUTCToShortDateTimeConverter}}" FontSize="{StaticResource TangoSmallFontSize}" HorizontalAlignment="Left" ></TextBlock> + </DataTemplate> + </touch:LightTouchDataGridColumn.CellTemplate> + </touch:LightTouchDataGridColumn> + <touch:LightTouchDataGridColumn Width="200" Header="CMYK" HorizontalContentAlignment="Left"> + <touch:LightTouchDataGridColumn.CellTemplate> + <DataTemplate> + <TextBlock IsHitTestVisible="False" Text="{Binding CMYK}" FontSize="{StaticResource TangoSmallFontSize}" HorizontalAlignment="Left" VerticalAlignment="Center"></TextBlock> + </DataTemplate> + </touch:LightTouchDataGridColumn.CellTemplate> + </touch:LightTouchDataGridColumn> + <touch:LightTouchDataGridColumn Width="1*" Header="Measured L*a*b*" HorizontalContentAlignment="Left"> + <touch:LightTouchDataGridColumn.CellTemplate> + <DataTemplate> + <TextBlock IsHitTestVisible="False" Text="{Binding LAB}" FontSize="{StaticResource TangoSmallFontSize}" HorizontalAlignment="Left" VerticalAlignment="Center"></TextBlock> + </DataTemplate> + </touch:LightTouchDataGridColumn.CellTemplate> + </touch:LightTouchDataGridColumn> + <touch:LightTouchDataGridColumn Header="dE(CMC)" Width="85" HorizontalContentAlignment="Left"> + <touch:LightTouchDataGridColumn.CellTemplate> + <DataTemplate> + <DockPanel> + <TextBlock DockPanel.Dock="Left" IsHitTestVisible="False" Text="{Binding DeltaEDisplay}" FontSize="{StaticResource TangoSmallFontSize}" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="0 0 10 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> + <touch:TouchButton DockPanel.Dock="Right" HorizontalAlignment="Right" VerticalAlignment="Center" EnableDropShadow="False" Background="Transparent" BorderThickness="0" Command="{Binding DataContext.DeleteTrialCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type touch:LightTouchDataGrid}}}" > + <DockPanel Width="Auto" Height="44" VerticalAlignment="Center"> + <Image Source="../Images/ColorSelection/Clear.png" Width="19" DockPanel.Dock="Top"></Image> + </DockPanel> + <touch:TouchButton.Style> + <Style TargetType="touch:TouchButton"> + <Setter Property="Visibility" Value="Hidden"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=touch:LightTouchDataGridRow},Path=IsSelected}" Value="True"> + <Setter Property="Visibility" Value="Visible"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </touch:TouchButton.Style> + </touch:TouchButton> + </DockPanel> + </DataTemplate> + </touch:LightTouchDataGridColumn.CellTemplate> + </touch:LightTouchDataGridColumn> + </touch:LightTouchDataGrid.Columns> + </touch:LightTouchDataGrid> + </Grid> + </touch:TouchExpander> + </Border> + <DockPanel Grid.Row="2" Margin="0 20 0 41" Background="{StaticResource TangoPrimaryBackgroundBrush}" > + <touch:TouchButton DockPanel.Dock="Right" HorizontalAlignment="Center" CornerRadius="25" Command="{Binding OKCommand}" Width="200" Height="50" VerticalAlignment="Bottom" TextElement.Foreground="{StaticResource TangoLightForegroundBrush}" FontSize="{StaticResource TangoButtonFontSize}" ShadowDepth="0" Content="APPLY" Margin="0 0 82 0"> + <touch:TouchButton.Style > + <Style TargetType="touch:TouchButton" > + <Setter Property="Foreground" Value="{StaticResource TangoPrimaryAccentBrush}"></Setter> + <Setter Property="Background" Value="{StaticResource TangoPrimaryAccentBrush}"/> + <Style.Triggers> + <Trigger Property="IsEnabled" Value="False"> + <Setter Property="Foreground" Value="{StaticResource TangoDisabledForegroundBrush}"></Setter> + <Setter Property="Background" Value="{StaticResource TangoDisabledBackgroundBrush}"></Setter> + </Trigger> + </Style.Triggers> + </Style> + </touch:TouchButton.Style> + </touch:TouchButton> + <touch:TouchButton x:Name="VFTCancelBtn" HorizontalAlignment="Left" Margin="82 0 0 0" BorderThickness="1" RippleBrush="{StaticResource TangoRippleDarkBrush}" CornerRadius="25" Command="{Binding CloseCommand}" Width="200" Height="50" VerticalAlignment="Bottom" FontSize="{StaticResource TangoButtonFontSize}" ShadowDepth="0" Content="EXIT" EnableDropShadow="False" > + <touch:TouchButton.Style > + <Style TargetType="touch:TouchButton" > + <Setter Property="IsEnabled" Value="True"/> + <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"/> + <Style.Triggers> + <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> + </Style.Triggers> + </Style> + </touch:TouchButton.Style> + </touch:TouchButton> + </DockPanel> + </Grid> + </Border> + </Border> + </Grid> +</UserControl> 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 new file mode 100644 index 000000000..cc4d9d424 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/VectorFineTuningDialog.xaml.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.PPC.Jobs.Dialogs +{ + /// <summary> + /// Interaction logic for VectorFineTuningDialog.xaml + /// </summary> + public partial class VectorFineTuningDialog : UserControl + { + private VectorFineTuningDialogVM _vm; + public VectorFineTuningDialog() + { + InitializeComponent(); + Loaded += (_, __) => + { + _vm = DataContext as VectorFineTuningDialogVM; + }; + } + } +} 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 new file mode 100644 index 000000000..954e2a521 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/VectorFineTuningDialogVM.cs @@ -0,0 +1,1040 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Media; +using System.Windows.Threading; +using Tango.BL; +using Tango.BL.Builders; +using Tango.BL.Entities; +using Tango.BL.Enumerations; +using Tango.Core; +using Tango.Core.Commands; +using Tango.Core.DI; +using Tango.Explorer; +using Tango.Integration.Operation; +using Tango.PDF; +using Tango.PPC.Common; +using Tango.PPC.Common.Connection; +using Tango.PPC.Common.Navigation; +using Tango.PPC.Common.Notifications; +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.Models; +using Tango.PPC.Jobs.Reports; +using Tango.PPC.Storage; +using Tango.PPC.Storage.Models; +using Tango.Settings; +using Tango.SharedUI; + +namespace Tango.PPC.Jobs.Dialogs +{ + public class VectorFineTuningDialogVM : DialogViewVM + { + private JobHandler _handler; + + #region Properties + + private RunningJobStatus _runningJobStatus; + /// <summary> + /// Gets or sets the running job status. + /// </summary> + public RunningJobStatus RunningJobStatus + { + get { return _runningJobStatus; } + set { _runningJobStatus = value; RaisePropertyChangedAuto(); } + } + + /// <summary> + /// Gets or sets the machine provider. + /// </summary> + [TangoInject] + public IMachineProvider MachineProvider { get; set; } + + /// <summary> + /// Gets or sets the notification provider. + /// </summary> + [TangoInject] + public INotificationProvider NotificationProvider { get; set; } + + /// <summary> + /// Gets or sets the printing manager. + /// </summary> + [TangoInject] + public IPrintingManager PrintingManager { get; set; } + + [TangoInject] + public INavigationManager NavigationManager { get; set; } + + /// <summary> + /// Gets or sets the storage provider. + /// </summary> + [TangoInject] + public IStorageProvider StorageProvider { get; set; } + + public BrushStopModel BrushStopModel { get; set; } + + private System.Windows.Media.Color _targetcolor; + + public System.Windows.Media.Color TargetColor + { + get { return _targetcolor; } + set + { + _targetcolor = value; + RaisePropertyChanged(nameof(ColorBrush)); + } + } + + public SolidColorBrush ColorBrush + { + get + { + return new SolidColorBrush(TargetColor); + } + } + + protected Double _targetL; + + public Double TargetL + { + get + { + return _targetL; + } + + set + { + if (_targetL != value) + { + _targetL = value; + RaisePropertyChangedAuto(); + } + } + } + + protected Double _targetA; + + /// <summary> + /// Gets or sets the BrushStopModel a. + /// </summary> + public Double TargetA + { + get + { + return _targetA; + } + set + { + if (_targetA != value) + { + _targetA = value; + RaisePropertyChangedAuto(); + OnLABChanged(); + } + } + } + + protected Double _targetB; + + /// <summary> + /// Gets or sets the BrushStopModel b. + /// </summary> + public Double TargetB + { + get + { + return _targetB; + } + set + { + if (_targetB != value) + { + _targetB = value; + RaisePropertyChangedAuto(); + OnLABChanged(); + } + } + } + + protected Double? _measuredL; + + /// <summary> + /// Gets or sets the BrushStopModel l. + /// </summary> + + public Double? MeasuredL + { + get + { + return _measuredL; + } + + set + { + if (_measuredL != value) + { + _measuredL = value; + RaisePropertyChangedAuto(); + if (ActiveLogModel != null) + ActiveLogModel.L = _measuredL; + OnLABChanged(); + } + } + } + + protected Double? _measuredA; + + /// <summary> + /// Gets or sets the BrushStopModel a. + /// </summary> + public Double? MeasuredA + { + get + { + return _measuredA; + } + set + { + if (_measuredA != value) + { + _measuredA = value; + RaisePropertyChangedAuto(); + if (ActiveLogModel != null) + ActiveLogModel.A = _measuredA; + OnLABChanged(); + } + } + } + + protected Double? _measuredB; + + /// <summary> + /// Gets or sets the BrushStopModel b. + /// </summary> + public Double? MeasuredB + { + get + { + return _measuredB; + } + set + { + if (_measuredB != value) + { + _measuredB = value; + RaisePropertyChangedAuto(); + if (ActiveLogModel != null) + ActiveLogModel.B = _measuredB; + OnLABChanged(); + } + } + } + + protected Double _cyan; + + /// <summary> + /// Gets or sets the cyan. + /// </summary> + public Double Cyan + { + get + { + return _cyan; + } + + set + { + if (_cyan != value) + { + _cyan = value; + RaisePropertyChangedAuto(); + } + } + } + + protected Double _magenta; + + /// <summary> + /// Gets or sets the magenta. + /// </summary> + + public Double Magenta + { + get + { + return _magenta; + } + + set + { + if (_magenta != value) + { + _magenta = value; + RaisePropertyChangedAuto(); + } + } + } + + protected Double _yellow; + + /// <summary> + /// Gets or sets the yellow. + /// </summary> + + public Double Yellow + { + get + { + return _yellow; + } + + set + { + if (_yellow != value) + { + _yellow = value; + RaisePropertyChangedAuto(); + } + } + } + + protected Double _black; + + /// <summary> + /// Gets or sets the black. + /// </summary> + public Double Black + { + get + { + return _black; + } + + set + { + if (_black != value) + { + _black = value; + RaisePropertyChangedAuto(); + } + } + } + + public int TrialNumber + { + get + { + if (ActiveLogModel == null) + return 1; + return ActiveLogModel.TrialNumber + 1; + } + } + + public TestColor TestColor { get; set; } + + + private SynchronizedObservableCollection<TrialsLogModel> _trialsLogItems; + + public SynchronizedObservableCollection<TrialsLogModel> TrialsLogitems + { + get { return _trialsLogItems; } + set + { + _trialsLogItems = value; + RaisePropertyChangedAuto(); + } + } + + private TrialsLogModel _activeLogModel; + + public TrialsLogModel ActiveLogModel + { + get { return _activeLogModel; } + set + { + _activeLogModel = value; + RaisePropertyChangedAuto(); + } + } + + private TrialsLogModel _selectedLog; + + public TrialsLogModel SelectedLog + { + get { return _selectedLog; } + set + { + if (value != ActiveLogModel) + { + _selectedLog = value; + RaisePropertyChangedAuto(); + OKCommand.RaiseCanExecuteChanged(); + + } + //else { _selectedLog = null;} + //RaisePropertyChangedAuto(); + //OKCommand.RaiseCanExecuteChanged(); + } + } + + private bool _isExpanderOpened; + public bool IsExpanderOpened + { + get { return _isExpanderOpened; } + set + { + _isExpanderOpened = value; + RaisePropertyChangedAuto(); + } + } + + private bool _isJobRunning; + public bool IsJobRunning + { + get { return _isJobRunning; } + set { _isJobRunning = value; RaisePropertyChangedAuto(); } + } + + private bool _isJobFailed; + public bool IsJobFailed + { + get { return _isJobFailed; } + set { _isJobFailed = value; RaisePropertyChangedAuto(); } + } + + private String _jobFailedReason; + + public String JobFailedReason + { + get { return _jobFailedReason; } + set { _jobFailedReason = value; RaisePropertyChangedAuto(); } + } + + + + #endregion + + #region Commands + public RelayCommand TestCommand { get; set; } + public RelayCommand StopCommand { get; set; } + public RelayCommand ClearTrialsCommand { get; set; } + public RelayCommand ExportTrialsCommand { get; set; } + public RelayCommand DeleteTrialCommand { get; set; } + + #endregion + + public VectorFineTuningDialogVM() + { + TargetL = 100; + TargetB = 0; + TargetA = 0; + TargetColor = Colors.White; + + ClearTrialsCommand = new RelayCommand(ClearTrialsLog); + ExportTrialsCommand = new RelayCommand(ExportTrialsLog); + TestCommand = new RelayCommand(StartJob, CanStartJob); + StopCommand = new RelayCommand(StopTest); + DeleteTrialCommand = new RelayCommand(DeleteTrialLog); + + IsExpanderOpened = true; + + TangoIOC.Default.Inject(this); + } + + public void Init(BrushStopModel brushstop, double l, double a, double b, System.Windows.Media.Color targetColor) + { + MachineProvider.MachineOperator.PrintingStarted += MachineOperator_PrintingStarted; + MachineProvider.MachineOperator.PrintingEnded += MachineOperator_PrintingEnded; + MachineProvider.MachineOperator.PrintingCompleted += MachineOperator_PrintingCompleted; + + BrushStopModel = brushstop.Clone(); + BrushStopModel.Guid = brushstop.Guid; + TargetL = l; + TargetB = b; + TargetA = a; + TargetColor = targetColor; + + BrushStopModel.ConvertColorToVolume(); + BrushStopModel.ColorSpace = ColorSpaces.LAB; + + Cyan = BrushStopModel.Cyan; + Magenta = BrushStopModel.Magenta; + Yellow = BrushStopModel.Yellow; + Black = BrushStopModel.Black; + MeasuredL = MeasuredB = MeasuredA = null; + TestColor = null; + + TestColor = TrialsLogEngine.Default.GetByBrushStopGuid(BrushStopModel.Guid); + + if (TestColor == null) + { + ActiveLogModel = new TrialsLogModel(0, Cyan, Magenta, Yellow, Black); + TrialsLogitems = new SynchronizedObservableCollection<TrialsLogModel>(); + TrialsLogitems.Add(ActiveLogModel); + } + else + { + TrialsLogitems = new SynchronizedObservableCollection<TrialsLogModel>(TestColor.TrialslogList.OrderByDescending(x=>x.TrialNumber)); + TrialsLogitems.ToList().ForEach(x => x.IsTested = true); + int maxTrialsNumber = TrialsLogitems.Max( x=>x.TrialNumber); + ActiveLogModel = TrialsLogitems.FirstOrDefault(x => x.TrialNumber == maxTrialsNumber); + if (ActiveLogModel == null) + { + ActiveLogModel = new TrialsLogModel(0, Cyan, Magenta, Yellow, Black); + TrialsLogitems.Add(ActiveLogModel); + } + ActiveLogModel.IsActiveTrial = true; + ActiveLogModel.IsTested = false; + ActiveLogModel.IsSelectionEnable = false; + var minValue = TrialsLogitems.Min(x => x.DeltaE); + if(minValue != null && minValue < 2) + { + TrialsLogitems.Where(x=>x.DeltaE == minValue).ToList().ForEach(i => i.IsBest = true); + } + + OKCommand.RaiseCanExecuteChanged(); + } + IsVisible = true; + RaisePropertyChanged(nameof(TrialsLogitems)); + } + + #region Methods + + protected override bool CanOK() + { + return (SelectedLog != null && SelectedLog.IsTested); + } + + private async void ExportTrialsLog(object obj) + { + if (!StorageProvider.IsConnected) + { + await NotificationProvider.ShowError("No storage device connected."); + return; + } + + //var result = await NavigationManager. + // NavigateForResult<StorageModule, + // Storage.Views.MainView, ExplorerFileItem, + // StorageNavigationRequest>( + // new StorageNavigationRequest() + // { + // Intent = StorageNavigationIntent.SaveFile, + // DefaultFileName = "Color_Correction_Report", + // Filter = ExplorerFileDefinition.PDFFile.Extension, + // Title = "Save Color Correction Report", + // }); + + // if (result != null) + { + ColorCorrectionRepotVM vm = new ColorCorrectionRepotVM() + { + JobName = BrushStopModel.SegmentModel.Job.Name, + TargetColor = String.Format($"L*{TargetL:0.##} a*{TargetA:0.##} b*{TargetB:0.##}") + }; + foreach (var item in TrialsLogitems) + { + vm.ReportItems.Add(new ColorCorrectionReportLogItem() + { + TrialsNumber = item.TrialNumber, + Date = item.Date, + CMYK = item.CMYK, + MeasuredLAB = item.LAB, + DeltaE = item.DeltaE, + IsBest = item.IsBest + }); + } + try + { + PdfWpfWriter writer = new PdfWpfWriter(); + writer.AddElement(new ColorCorrectionReport() { DataContext = vm }); + // writer.Save(result.Path + ExplorerFileDefinition.PDFFile.Extension); + writer.Save(StorageProvider.Drive.Name + "\\Color Correction Report" + ExplorerFileDefinition.PDFFile.Extension); + await NotificationProvider.ShowSuccess("Job saved successfully."); + } + catch (Exception ex) + { + LogManager.Log(ex, $"Error saving color correction report to file."); + await NotificationProvider.ShowError($"An error occurred while trying to save the color correction report.\n{ex.Message}"); + } + } + } + + private async void ClearTrialsLog(object obj) + { + if (TrialsLogitems.Count > 1) + { + if (false == await NotificationProvider.ShowQuestion("“All the trials will be cleared.")) + { + return; + } + ActiveLogModel = TrialsLogitems[0]; + ActiveLogModel.L = ActiveLogModel.A = ActiveLogModel.B = null; + TrialsLogitems.Clear(); + TrialsLogitems.Add(ActiveLogModel); + RaisePropertyChanged(nameof(TrialsLogitems)); + + ActiveLogModel.DeltaE = null; + } + + } + + private void DeleteTrialLog(object obj) + { + if (SelectedLog != null && SelectedLog != ActiveLogModel) + { + TrialsLogitems.Remove(SelectedLog); + SelectedLog = null; + var minDelataE = TrialsLogitems.Min(x => x.DeltaE); + if (minDelataE != null && minDelataE < 2) + TrialsLogitems.ToList().ForEach(x => x.IsBest = (x.DeltaE == minDelataE)); + } + } + + protected override async void Accept() + { + if(IsBusy) + return; + IsBusy = true; + OnClose(); + + if( SelectedLog.DeltaE >=2) + { + if( false == await NotificationProvider.ShowQuestion("Please note that the color you have chosen is not the closest one.")) + { + return; + } + } + BrushStopModel.L = (double)SelectedLog.L; + BrushStopModel.A = (double)SelectedLog.A; + BrushStopModel.PreventPropertyUpdate = false; + BrushStopModel.B = (double)SelectedLog.B; + BrushStopModel.Cyan = SelectedLog.TestC; + BrushStopModel.Magenta = SelectedLog.TestM; + BrushStopModel.Yellow = SelectedLog.TestY; + BrushStopModel.Black = SelectedLog.TestK; + + if (TestColor != null) + { + TrialsLogEngine.Default.Delete(TestColor); + } + IsBusy = false; + base.Accept(); + } + + protected override void Cancel() + { + OnClose(); + + if (TestColor != null && TrialsLogitems.Count > 1) + { + if (TrialsLogitems.Count > 1) + { + TestColor.L = TargetL; + TestColor.A = TargetA; + TestColor.B = TargetB; + TestColor.BrushStopGuid = BrushStopModel.Guid; + TestColor.TrialslogList.Clear(); + TestColor.TrialslogList.AddRange(TrialsLogitems); + TrialsLogEngine.Default.UpdateTest(TestColor); + } + else + TrialsLogEngine.Default.Delete(TestColor); + } + else if(TrialsLogitems.Count > 1) + { + TestColor = new TestColor(); + TestColor.BrushStopGuid = BrushStopModel.Guid; + TestColor.L = TargetL; + TestColor.A = TargetA; + TestColor.B = TargetB; + TestColor.TrialslogList.AddRange(TrialsLogitems); + TrialsLogEngine.Default.AddTest(TestColor); + } + base.Cancel(); + } + + private void OnClose() + { + MachineProvider.MachineOperator.PrintingStarted -= MachineOperator_PrintingStarted; + MachineProvider.MachineOperator.PrintingEnded -= MachineOperator_PrintingEnded; + MachineProvider.MachineOperator.PrintingCompleted -= MachineOperator_PrintingCompleted; + } + + private bool IsValidLAB() + { + if (MeasuredL == null || MeasuredL < 0 || MeasuredL > 100 + || MeasuredA == null || MeasuredA < -128 || MeasuredA > 127 + || MeasuredB == null || MeasuredB < -128 || MeasuredB > 127) + return false; + return true; + } + + private async void OnLABChanged() + { + if (ActiveLogModel == null) + return; + + if (IsValidLAB()) + { + BrushStopModel.PreventPropertyUpdate = true; + BrushStopModel.L = (double)MeasuredL; + BrushStopModel.A = (double)MeasuredA; + BrushStopModel.B = (double)MeasuredB; + BrushStopModel.PreventPropertyUpdate = false; + //BrushStopModel.ConvertColor(); + //if(BrushStopModel.IsOutOfGamut) + //{ + // await NotificationProvider.ShowInfo("Color is out of gamut!"); + //} + + var deltaE = DeltaE_CMC(TargetL, TargetA, TargetB, (double)MeasuredL, (double)MeasuredA, (double)MeasuredB); + ActiveLogModel.DeltaE = deltaE; + ValidationTests(); + } + TestCommand.RaiseCanExecuteChanged(); + } + + #endregion + + #region Job + + private async void StartJob() + { + if (ActiveLogModel.DeltaE <= 0.5) + { + if(true == await NotificationProvider.ShowQuestion("Previous trial seems to be very close; no more trials are recommended")) + return; + } + + IsJobRunning = true; + IsJobFailed = false; + + //calculate CMYK + BrushStopModel.ConvertColorToVolume(); + BrushStopModel.ColorSpace = ColorSpaces.LAB; + var settings = SettingsManager.Default.GetOrCreate<PPCSettings>(); + + using (ObservablesContext db = ObservablesContext.CreateDefault()) + { + Job job = new Job(); + job.Designation = JobDesignations.FineTuning; + job.Machine = await new MachineBuilder(db).Set(MachineProvider.Machine.Guid).WithConfiguration().WithSpools().WithCats().WithVersion().BuildAsync(); + job.Name = $"Manual Fine Tuning #{ActiveLogModel.TrialNumber}"; + job.Rml = await new RmlBuilder(db).Set(BrushStopModel.SegmentModel.Job.Rml.Guid).WithActiveParametersGroup().WithCAT(MachineProvider.Machine.Guid).WithCCT().WithLiquidFactors().WithSpools().BuildAsync(); + job.SpoolType = db.SpoolTypes.FirstOrDefault(x => x.Guid == settings.SpoolTypeGuid); + job.WindingMethod = db.WindingMethods.FirstOrDefault(); + + Segment segment = new Segment(); + segment.Name = "Standard Segment"; + segment.Length = settings.FineTuningTrialLengthMeters; + segment.Job = job; + segment.JobGuid = job.Guid; + + job.Segments.Add(segment); + + BrushStop stop = new BrushStop(); + stop.Segment = segment; + stop.ColorSpace = db.ColorSpaces.FirstOrDefault(x => x.Code == (int)ColorSpaces.Volume); + stop.SetLiquidVolumes(job.Machine.Configuration, job.Rml, job.Rml.GetActiveProcessGroup().ProcessParametersTables.FirstOrDefault()); + + stop.SetVolume(LiquidTypes.Cyan, BrushStopModel.Cyan); + stop.SetVolume(LiquidTypes.Magenta, BrushStopModel.Magenta); + stop.SetVolume(LiquidTypes.Yellow, BrushStopModel.Yellow); + stop.SetVolume(LiquidTypes.Black, BrushStopModel.Black); + + segment.BrushStops.Add(stop); + + try + { + await PrintingManager.Print(job, db); + } + catch (Exception ex) + { + LogManager.Log(ex, "Could not start the test job."); + await NotificationProvider.ShowError($"{ex.Message}."); + IsJobRunning = false; + } + } + //on update ActiveLogModel + } + + private bool CanStartJob(object arg) + { + return (ActiveLogModel != null && IsValidLAB() && TrialsLogitems.Count <= 10 && !IsJobRunning); + } + + private void MachineOperator_PrintingStarted(object sender, PrintingEventArgs e) + { + if (IsVisible) + { + _handler = e.JobHandler; + e.JobHandler.StatusChanged += JobHandler_StatusChanged; + e.JobHandler.Stopped += JobHandler_Stopped; + e.JobHandler.Completed += JobHandler_Completed; + e.JobHandler.Failed += JobHandler_Failed; + + //e.JobHandler.CanCancelChanged += JobHandler_CanCancelChanged; + } + } + + private void JobHandler_Failed(object sender, Exception e) + { + IsJobFailed = true; + JobFailedReason = e.FlattenMessage(); + } + + + + /// <summary> + /// Handles the Stopped event of the JobHandler. + /// </summary> + /// <param name="sender">The source of the event.</param> + /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> + private void JobHandler_Stopped(object sender, EventArgs e) + { + if (_handler != null) + { + _handler.StatusChanged -= JobHandler_StatusChanged; + _handler.Stopped -= JobHandler_Stopped; + _handler.Completed -= JobHandler_Completed; + //_handler.CanCancelChanged -= JobHandler_CanCancelChanged; + IsJobRunning = false; + InvalidateRelayCommands(); + } + } + + /// <summary> + /// Handles the JobHandler StatusChanged event. + /// </summary> + /// <param name="sender">The sender.</param> + /// <param name="e">The e.</param> + private void JobHandler_StatusChanged(object sender, RunningJobStatus e) + { + InvokeUI(() => + { + RunningJobStatus = e; + }); + } + + private void MachineOperator_PrintingEnded(object sender, PrintingEventArgs e) + { + + } + + private void MachineOperator_PrintingCompleted(object sender, PrintingEventArgs e) + { + LogManager.Log($"'{e.Job.Name}' printing complete. Job designation is {e.Job.Designation}."); + + + // if (e.Job.Designation == BL.Enumerations.JobDesignations.FineTuning) + //{ + // NotificationProvider.PushNotification(new MessageNotificationItem(String.Format("'{0}' fine tuning completed successfully", e.Job.Name), "Tap to approve or repeat.", MessageNotificationItem.MessageNotificationItemTypes.Success, () => + // { + // })); + //} + //if (IsVisible) + //{ + // IsJobRunning = false; + // Dispatcher.CurrentDispatcher.Invoke(() => + // { + // ActiveLogModel.IsTested = true; + // ActiveLogModel.Date = DateTime.UtcNow; + // if (ActiveLogModel != null && ActiveLogModel.TrialNumber < 10) + // { + // ActiveLogModel = new TrialsLogModel(ActiveLogModel.TrialNumber + 1, Cyan, Magenta, Yellow, Black); + // _trialsLogItems.Add( ActiveLogModel); + // RaisePropertyChanged(nameof(TrialsLogitems)); + // } + // _measuredL = null; + // _measuredA = null; + // _measuredB = null; + // RaisePropertyChanged(nameof(MeasuredL)); + // RaisePropertyChanged(nameof(MeasuredA)); + // RaisePropertyChanged(nameof(MeasuredB)); + // }); + //} + + } + + + private void JobHandler_Completed(object sender, EventArgs e) + { + if (_handler != null) + { + if (IsVisible) + { + IsJobRunning = false; + // Dispatcher.CurrentDispatcher.Invoke(() => + // { + ActiveLogModel.IsTested = true; + ActiveLogModel.Date = DateTime.UtcNow; + 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 && ActiveLogModel.TrialNumber < 10) + { + ActiveLogModel = new TrialsLogModel(ActiveLogModel.TrialNumber + 1, Cyan, Magenta, Yellow, Black); + 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)); + } + + //}); + } + + _handler.StatusChanged -= JobHandler_StatusChanged; + _handler.Stopped -= JobHandler_Stopped; + _handler.Completed -= JobHandler_Completed; + + InvalidateRelayCommands(); + } + } + + private void StopTest() + { + if (_handler != null) + { + _handler.Cancel(); + IsJobRunning = false; + + InvalidateRelayCommands(); + } + } + + #endregion + + #region Delta E + + double DeltaE_CMC(double L1, double a1, double b1, double L2, double a2, double b2) + { + double h1 = Math.Atan2(b1, a1) * (180 / Math.PI); + if (h1 < 0) + h1 = h1 + 360; + double h2 = Math.Atan2(b2, a2) * (180 / Math.PI); + if (h2 < 0) + h2 = h2 + 360; + double refX_H = h1; + //chroma calculation + double refX_C = Math.Sqrt(a1 * a1 + b1 * b1); + //reference SL parameter + double refX_SL; + if (L1 <= 16) + refX_SL = 0.511; + else + refX_SL = L1 * 0.040975 / (1 + 0.01765 * L1); + //reference SC parameter + double refX_SC = (0.638 + 0.0638 * refX_C / (1 + 0.0131 * refX_C)); + //reference CQ parameter + double refX_CQ = Math.Pow(refX_C, 4); + //reference F parameter + double refX_F = Math.Sqrt(refX_CQ / (refX_CQ + 1900)); + // reference T parameter + 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)); + // reference SH parameter + double refX_SH = refX_SC * (refX_T * refX_F + 1 - refX_F); + + //sample parameter calculations + //hue calculation + double samX_H = h2; + //chroma calculation + double samX_C = Math.Sqrt(a2 * a2 + b2 * b2); + + double dL = L1 - L2; + double 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)); + + 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; + + } + double DeltaE_regular(double L1, double a1, double b1, double L2, double a2, double b2) + { + return Math.Sqrt(Math.Pow(L1 - L2, 2) + Math.Pow(a1 - a2, 2) + Math.Pow(b1 - b2, 2)); + } + + private async void ValidationTests() + { + //if (ActiveLogModel.DeltaE <= 0.5) + //{ + // await NotificationProvider.ShowInfo("Previous trial seems to be very close; no more trials are recommended"); + // return ; + //} + if (TrialsLogitems.Count == 1 || ActiveLogModel.DeltaE == null) + return ; + + if(TrialsLogitems.Count >= 3) + { + var currentTrialNumber = ActiveLogModel.TrialNumber; + var item = TrialsLogitems [TrialsLogitems.Count- 3]; + var item1 = TrialsLogitems[TrialsLogitems.Count - 2]; + var item2 = TrialsLogitems[TrialsLogitems.Count - 1]; + //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) + { + await NotificationProvider.ShowInfo("It seems that we can’t get you any closer"); + return ; + } + //Math.Abs + //| dEi+1- dEi | and |dEi+2 -dEi+1|<=0.1. + if(Math.Abs((double)item1.DeltaE - (double)item.DeltaE)<= 0.1 && Math.Abs((double)item2.DeltaE - (double)item1.DeltaE) <= 0.1) + { + await NotificationProvider.ShowInfo("It seems that we can’t get you any closer"); + return; + } + } + + + if (TrialsLogitems.Count >= 2) + { + var item = TrialsLogitems[TrialsLogitems.Count - 2]; + var item1 = TrialsLogitems[TrialsLogitems.Count - 1]; + 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 + && Math.Abs((double)item1.K - (double)item.K) < 0.1) + { + await NotificationProvider.ShowInfo("It seems that we can’t get you any closer"); + return; + } + } + return; + } + + #endregion + + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/ColorSelection/Clear.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/ColorSelection/Clear.png Binary files differnew file mode 100644 index 000000000..5b99530fe --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/ColorSelection/Clear.png diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/ColorSelection/CorrectionTrial.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/ColorSelection/CorrectionTrial.png Binary files differnew file mode 100644 index 000000000..a70769131 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/ColorSelection/CorrectionTrial.png diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/ColorSelection/Export.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/ColorSelection/Export.png Binary files differnew file mode 100644 index 000000000..34ead5944 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/ColorSelection/Export.png diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/ColorSelection/VFineTuning.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/ColorSelection/VFineTuning.png Binary files differnew file mode 100644 index 000000000..7794b99e0 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/ColorSelection/VFineTuning.png diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/logo.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/logo.png Binary files differnew file mode 100644 index 000000000..75e491626 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/logo.png diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/BrushStopModel.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/BrushStopModel.cs index 01ecc239f..e2acb9e7a 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 @@ -17,12 +17,12 @@ using Tango.Core.ExtensionMethods; namespace Tango.PPC.Jobs.Models { - public class BrushStopModel : ViewModel + public class BrushStopModel : ViewModel { public enum PositionStatus { First = 1, - FirstColor = 2, + FirstColor = 2, Middle = 3, SecondColor = 4, Last = 5 @@ -37,6 +37,8 @@ namespace Tango.PPC.Jobs.Models #region Property + public String Guid { get; set; } + public bool PreventPropertyUpdate { get; set; } protected Double _cyan; @@ -444,11 +446,13 @@ namespace Tango.PPC.Jobs.Models public PositionStatus Position { get { return _position; } - set { _position = value; + set + { + _position = value; RaisePropertyChangedAuto(); } } - + protected ColorSpaces _colorspace; public virtual ColorSpaces ColorSpace @@ -489,7 +493,7 @@ namespace Tango.PPC.Jobs.Models } } - + /// <summary> /// Gets or sets the color catalog. /// </summary> @@ -500,7 +504,7 @@ namespace Tango.PPC.Jobs.Models { get { - if(ColorCatalogsItem != null && ColorCatalogsItem.ColorCatalogsGroup!= null) + if (ColorCatalogsItem != null && ColorCatalogsItem.ColorCatalogsGroup != null) return ColorCatalogsItem.ColorCatalogsGroup.ColorCatalog; return null; @@ -516,7 +520,7 @@ namespace Tango.PPC.Jobs.Models } set { - if(_color != value) + if (_color != value) { _color = value; RaisePropertyChangedAuto(); @@ -530,7 +534,8 @@ namespace Tango.PPC.Jobs.Models public System.Windows.Media.Color BestMatchColor { get { return _bestMatchColor; } - set { + set + { _bestMatchColor = value; RaisePropertyChangedAuto(); RaisePropertyChanged(nameof(BestMatchA)); @@ -539,11 +544,12 @@ namespace Tango.PPC.Jobs.Models RaisePropertyChanged(nameof(ShownBestMatchColor)); } } - + public System.Windows.Media.Color ShownBestMatchColor { - get { - if(IsOutOfGamut) + get + { + if (IsOutOfGamut) return _bestMatchColor; return System.Windows.Media.Colors.Transparent; } @@ -554,7 +560,7 @@ namespace Tango.PPC.Jobs.Models { get { - if(Color == null) + if (Color == null) { InitColor(); } @@ -569,7 +575,7 @@ namespace Tango.PPC.Jobs.Models get { return _segmentmodel; } set { _segmentmodel = value; } } - + private bool _outOfGamutChecked; /// <summary> @@ -599,15 +605,21 @@ namespace Tango.PPC.Jobs.Models } protected bool RequiredMaxLiquidTest { get; set; } + #endregion #region constructors - public BrushStopModel(SegmentModel segmentModel) + public BrushStopModel() + { + Guid = System.Guid.NewGuid().ToString(); + } + + public BrushStopModel(SegmentModel segmentModel) : this() { InitDefaultValues(); SegmentModel = segmentModel; - + Color = Colors.White; ColorSpace = ColorSpaces.Volume; ColorCatalogsItem = null; @@ -616,19 +628,22 @@ namespace Tango.PPC.Jobs.Models RequiredMaxLiquidTest = false; } - public BrushStopModel(BrushStop brushStop, SegmentModel segmentModel, int version) + public BrushStopModel(BrushStop brushStop, SegmentModel segmentModel, int version) : this() { InitDefaultValues(); + Guid = brushStop.Guid; SegmentModel = segmentModel; OffsetPercent = brushStop.OffsetPercent; Color = brushStop.Color; BestMatchColor = brushStop.Color; ColorSpace = brushStop.ColorSpace.Space; + if(ColorSpace == ColorSpaces.CMYK) + ColorSpace = ColorSpaces.Volume; _colorcatalogsitem = brushStop.ColorCatalogsItem; _stopindex = brushStop.StopIndex; - + PreventPropertyUpdate = true; - if(version == 1) + if (version == 1) { Cyan = brushStop.GetVolume(LiquidTypes.Cyan); Magenta = brushStop.GetVolume(LiquidTypes.Magenta); @@ -689,14 +704,14 @@ namespace Tango.PPC.Jobs.Models } else { - Color = Color.FromRgb((byte)_red, (byte)_green, (byte)_blue); + Color = Color.FromRgb((byte)_red, (byte)_green, (byte)_blue); } } /// <summary> /// Sets the new color from MyColors. /// </summary> - public void SetNewColor( BrushStopModel newBrushStop) + public void SetNewColor(BrushStopModel newBrushStop) { ColorSpace = newBrushStop.ColorSpace; PreventPropertyUpdate = true; @@ -717,7 +732,7 @@ namespace Tango.PPC.Jobs.Models Black = newBrushStop.Black; ColorCatalogsItem = newBrushStop.ColorCatalogsItem; PreventPropertyUpdate = false; - + Color = newBrushStop.Color; BestMatchColor = newBrushStop.BestMatchColor; } @@ -727,48 +742,48 @@ namespace Tango.PPC.Jobs.Models /// </summary> public BrushStop CreateBrushStop(ColorSpaces colorSpace) { - List<Tango.BL.Entities.ColorSpace> list = SegmentModel.Job.ColorSpacesList; + List<Tango.BL.Entities.ColorSpace> list = SegmentModel.Job.ColorSpacesList; - BrushStop s = new BrushStop(); - s.ColorSpace = list.FirstOrDefault(x => x.Space == colorSpace); + 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()); + Configuration configuration = SegmentModel.Job.Machine.Configuration; + Rml rml = SegmentModel.Job.Rml; + s.SetLiquidVolumes(configuration, rml, rml.GetActiveProcessGroup().ProcessParametersTables.FirstOrDefault()); - if (s.ColorSpace.Space == ColorSpaces.Volume) - { - s.SetVolume(configuration.NoneEmptyIdsPacks.SingleOrDefault(x => x.LiquidType.Code == LiquidTypes.Cyan.ToInt32()).PackIndex, Cyan); - s.SetVolume(configuration.NoneEmptyIdsPacks.SingleOrDefault(x => x.LiquidType.Code == LiquidTypes.Magenta.ToInt32()).PackIndex, Magenta); - s.SetVolume(configuration.NoneEmptyIdsPacks.SingleOrDefault(x => x.LiquidType.Code == LiquidTypes.Yellow.ToInt32()).PackIndex, Yellow); - s.SetVolume(configuration.NoneEmptyIdsPacks.SingleOrDefault(x => x.LiquidType.Code == LiquidTypes.Black.ToInt32()).PackIndex, Black); - } - else if(s.ColorSpace.Space == ColorSpaces.LAB) - { - s.ColorSpace.Space = BL.Enumerations.ColorSpaces.LAB; - s.L = this.L; - s.A = this.A; - s.B = this.B; - } - else if (s.ColorSpace.Space == ColorSpaces.RGB) - { - s.ColorSpace.Space = BL.Enumerations.ColorSpaces.RGB; - s.Red = this.Red; - s.Green = this.Green; - s.Blue = this.Blue; - } - else if(s.ColorSpace.Space == ColorSpaces.HSB) - { - s.ColorSpace.Space = BL.Enumerations.ColorSpaces.RGB; - s.Red = this.Red; - s.Green = this.Green; - s.Blue = this.Blue; - } + if (s.ColorSpace.Space == ColorSpaces.Volume) + { + s.SetVolume(configuration.NoneEmptyIdsPacks.SingleOrDefault(x => x.LiquidType.Code == LiquidTypes.Cyan.ToInt32()).PackIndex, Cyan); + s.SetVolume(configuration.NoneEmptyIdsPacks.SingleOrDefault(x => x.LiquidType.Code == LiquidTypes.Magenta.ToInt32()).PackIndex, Magenta); + s.SetVolume(configuration.NoneEmptyIdsPacks.SingleOrDefault(x => x.LiquidType.Code == LiquidTypes.Yellow.ToInt32()).PackIndex, Yellow); + s.SetVolume(configuration.NoneEmptyIdsPacks.SingleOrDefault(x => x.LiquidType.Code == LiquidTypes.Black.ToInt32()).PackIndex, Black); + } + else if (s.ColorSpace.Space == ColorSpaces.LAB) + { + s.ColorSpace.Space = BL.Enumerations.ColorSpaces.LAB; + s.L = this.L; + s.A = this.A; + s.B = this.B; + } + else if (s.ColorSpace.Space == ColorSpaces.RGB) + { + s.ColorSpace.Space = BL.Enumerations.ColorSpaces.RGB; + s.Red = this.Red; + s.Green = this.Green; + s.Blue = this.Blue; + } + else if (s.ColorSpace.Space == ColorSpaces.HSB) + { + s.ColorSpace.Space = BL.Enumerations.ColorSpaces.RGB; + s.Red = this.Red; + s.Green = this.Green; + s.Blue = this.Blue; + } - return s; + return s; } - + public BrushStopModel Clone() { var cloned = new BrushStopModel(SegmentModel); @@ -807,7 +822,7 @@ namespace Tango.PPC.Jobs.Models return cloned; } - public static Color GetRelativeRGB(Color first, Color second, double firstOffset, double secondOffset, double offset) + public static Color GetRelativeRGB(Color first, Color second, double firstOffset, double secondOffset, double offset) { var color = new Color(); var range = (secondOffset - firstOffset); @@ -826,15 +841,15 @@ namespace Tango.PPC.Jobs.Models Color = favoriteColor.Color; BestMatchColor = favoriteColor.Color; ColorSpace = favoriteColor.ColorSpace; - // _colorcatalogsitem = favoriteColor.ColorCatalogsItem; - + // _colorcatalogsitem = favoriteColor.ColorCatalogsItem; + PreventPropertyUpdate = true; - + Cyan = favoriteColor.Cyan; Magenta = favoriteColor.Magenta; Yellow = favoriteColor.Yellow; Black = favoriteColor.Black; - + Red = favoriteColor.Red; Green = favoriteColor.Green; Blue = favoriteColor.Blue; @@ -860,7 +875,7 @@ namespace Tango.PPC.Jobs.Models RequiredMaxLiquidTest = true; RaisePropertyChanged(nameof(IsLiquidVolumesOutOfRange)); OnBrushStopFieldValueChanged(); - + } private void OnRGBChanged() { @@ -910,7 +925,7 @@ namespace Tango.PPC.Jobs.Models InitColor(); BestMatchColor = Color; } - + if (ColorCatalogsItemChanged != null) { ColorCatalogsItemChanged.Invoke(this, new EventArgs()); @@ -920,7 +935,7 @@ namespace Tango.PPC.Jobs.Models { //lenth? } - + private void OnStopIndexChanged() { //throw new NotImplementedException(); @@ -928,19 +943,19 @@ namespace Tango.PPC.Jobs.Models private Rgb GetRGBColor() { - if(ColorSpace == ColorSpaces.LAB) + if (ColorSpace == ColorSpaces.LAB) { Lab lab = new Lab(L, A, B); Rgb rgb = new Rgb(lab.ToRgb()); return rgb; } - if(ColorSpace == ColorSpaces.HSB) + if (ColorSpace == ColorSpaces.HSB) { Hsb hsb = new Hsb(Hue, Saturation / 100, Brightness / 100); Rgb rgb = new Rgb(hsb.ToRgb()); return rgb; } - if(ColorSpace == ColorSpaces.Catalog && ColorCatalogsItem != null) + if (ColorSpace == ColorSpaces.Catalog && ColorCatalogsItem != null) { return new Rgb(ColorCatalogsItem.Red, ColorCatalogsItem.Green, ColorCatalogsItem.Blue); } @@ -949,7 +964,7 @@ namespace Tango.PPC.Jobs.Models public void ConvertColorToHSB() { - if(ColorSpace != ColorSpaces.HSB) + if (ColorSpace != ColorSpaces.HSB) { Hsb hsb = null; @@ -986,7 +1001,7 @@ namespace Tango.PPC.Jobs.Models Rgb rgb = new Rgb(Red, Green, Blue); hsb = new Hsb(rgb.To<Hsb>()); } - else if(ColorSpace == ColorSpaces.Catalog && ColorCatalogsItem != null) + else if (ColorSpace == ColorSpaces.Catalog && ColorCatalogsItem != null) { Rgb rgb = new Rgb(ColorCatalogsItem.Red, ColorCatalogsItem.Green, ColorCatalogsItem.Blue); hsb = new Hsb(rgb.To<Hsb>()); @@ -1090,7 +1105,7 @@ namespace Tango.PPC.Jobs.Models { lab = new Lab(ColorCatalogsItem.L, ColorCatalogsItem.A, ColorCatalogsItem.B); } - if(lab != null) + if (lab != null) { _l = lab.L; _a = lab.A; @@ -1143,7 +1158,7 @@ namespace Tango.PPC.Jobs.Models IsBusy = true; var output = _converter.Convert(stop, SegmentModel.Job.Machine.Configuration, SegmentModel.Job.Rml, false, false, false); - _cyan = (output.SingleCoordinates.OutputLiquids.SingleOrDefault(x => x.LiquidType == PMR.ColorLab.LiquidType.Cyan).Volume) ; + _cyan = (output.SingleCoordinates.OutputLiquids.SingleOrDefault(x => x.LiquidType == PMR.ColorLab.LiquidType.Cyan).Volume); _yellow = (output.SingleCoordinates.OutputLiquids.SingleOrDefault(x => x.LiquidType == PMR.ColorLab.LiquidType.Yellow).Volume); _magenta = (output.SingleCoordinates.OutputLiquids.SingleOrDefault(x => x.LiquidType == PMR.ColorLab.LiquidType.Magenta).Volume); _black = (output.SingleCoordinates.OutputLiquids.SingleOrDefault(x => x.LiquidType == PMR.ColorLab.LiquidType.Black).Volume); @@ -1180,13 +1195,13 @@ namespace Tango.PPC.Jobs.Models if (BestMatchColor == null) BestMatchColor = Color; var closestItem = catalogs.SelectMany(x => x.AllItemsOrdered).GetClosestItem(BestMatchColor); - + ColorCatalogsItem = closestItem; ColorSpace = ColorSpaces.Catalog; RaisePropertyChanged(nameof(ColorCatalog)); } } - + public void RaiseOffsetChanged() { RaisePropertyChanged(nameof(OffsetPercent)); @@ -1241,7 +1256,7 @@ namespace Tango.PPC.Jobs.Models } } - public double GetColorNLPerCm(double color,LiquidTypes type ) + public double GetColorNLPerCm(double color, LiquidTypes type) { StandardColorDispensingCalc calc = new StandardColorDispensingCalc(); @@ -1254,13 +1269,13 @@ namespace Tango.PPC.Jobs.Models } return 0.0; } - - + + public bool IsLiquidVolumesOutOfRange { get { - if (RequiredMaxLiquidTest ) + if (RequiredMaxLiquidTest) { var sum = GetColorNLPerCm(Cyan, LiquidTypes.Cyan) + GetColorNLPerCm(Magenta, LiquidTypes.Magenta) + GetColorNLPerCm(Yellow, LiquidTypes.Yellow) + GetColorNLPerCm(Black, LiquidTypes.Black); var maxLiq = GetTotalMaximumLiquidNlPerCMLimit(); @@ -1277,97 +1292,88 @@ namespace Tango.PPC.Jobs.Models public bool LiquidVolumesOutOfRange { get { return _liquidVolumesOutOfRange; } - set { - if(_liquidVolumesOutOfRange != value) + set + { + if (_liquidVolumesOutOfRange != value) { _liquidVolumesOutOfRange = value; LiquidVolumesOutOfRangeChanged?.Invoke(this, new EventArgs()); } } } - + public void OnBrushStopFieldValueChanged() { IsBusy = true; - _volumeConversionTimer.ResetReplace( () => - { - try - { - ColorSpaces colorSpace = ColorSpace; + _volumeConversionTimer.ResetReplace(() => + { + if (ColorSpace == BL.Enumerations.ColorSpaces.Volume) + { + //RaisePropertyChanged(nameof(IsLiquidVolumesOutOfRange)); + if (IsLiquidVolumesOutOfRange) + { + IsBusy = false; + return; + } + } + ConvertColor(); + }); + } - BrushStop stop = CreateBrushStop(colorSpace); + public void ConvertColor() + { + try + { + ColorSpaces colorSpace = ColorSpace; - Configuration configuration = SegmentModel.Job.Machine.Configuration; - Rml rml = SegmentModel.Job.Rml; - - if ( ColorSpace == BL.Enumerations.ColorSpaces.Volume) - { - //RaisePropertyChanged(nameof(IsLiquidVolumesOutOfRange)); - if(IsLiquidVolumesOutOfRange) - { - IsBusy = false; - return; - } - } - - var output = _converter.Convert(stop, configuration, rml, false, false, false); - //output.SingleCoordinates.OutputLiquids.SingleOrDefault(x => x.LiquidType == PMR.ColorLab.LiquidType.Cyan).Volume; - - if (stop.BrushColorSpace == BL.Enumerations.ColorSpaces.Volume) - { - IsOutOfGamut = false; - _red = output.SingleCoordinates.Red; - _green = output.SingleCoordinates.Green; - _blue = output.SingleCoordinates.Blue; - InitColor(); - BestMatchColor = Color.FromRgb((byte)output.SingleCoordinates.Red, (byte)output.SingleCoordinates.Green, (byte)output.SingleCoordinates.Blue); - - } - else if (stop.BrushColorSpace == BL.Enumerations.ColorSpaces.LAB) - { - IsOutOfGamut = _converter.IsOutOfGamut(stop, configuration, rml); - BestMatchL = (double)output.SingleCoordinates.L; - BestMatchA = (double)output.SingleCoordinates.A; - BestMatchB = (double)output.SingleCoordinates.B; - Lab lab = new Lab(output.SingleCoordinates.L, output.SingleCoordinates.A, output.SingleCoordinates.B); - Rgb rgb = new Rgb(lab.ToRgb()); - BestMatchColor = Color.FromRgb((byte)rgb.R, (byte)rgb.G, (byte)rgb.B); - //TODO ASK ROY - //foreach (var outputLiquid in output.SingleCoordinates.OutputLiquids) - //{ - // var liquidVolume = stop.LiquidVolumes.SingleOrDefault(x => x.IdsPack.LiquidType.Code == outputLiquid.LiquidType.ToInt32()); + BrushStop stop = CreateBrushStop(colorSpace); - // if (liquidVolume == null) - // { - // throw new NullReferenceException("Liquid volume not found for color conversion output liquid '" + outputLiquid.LiquidType + "'."); - // } + Configuration configuration = SegmentModel.Job.Machine.Configuration; + Rml rml = SegmentModel.Job.Rml; + var output = _converter.Convert(stop, configuration, rml, false, false, false); + //output.SingleCoordinates.OutputLiquids.SingleOrDefault(x => x.LiquidType == PMR.ColorLab.LiquidType.Cyan).Volume; - // liquidVolume.Volume = outputLiquid.Volume; - //} - } - else if (stop.BrushColorSpace == BL.Enumerations.ColorSpaces.RGB) - { - IsOutOfGamut = _converter.IsOutOfGamut(stop, configuration, rml); - BestMatchColor = Color.FromRgb((byte)output.SingleCoordinates.Red, (byte)output.SingleCoordinates.Green, (byte)output.SingleCoordinates.Blue); - } - else if (stop.BrushColorSpace == BL.Enumerations.ColorSpaces.HSB) - { - IsOutOfGamut = _converter.IsOutOfGamut(stop, configuration, rml); - BestMatchColor = Color.FromRgb((byte)output.SingleCoordinates.Red, (byte)output.SingleCoordinates.Green, (byte)output.SingleCoordinates.Blue); - } - } - catch (Exception ex) - { - LogManager.Log(ex, "An error occurred while trying to get volume => RGB from conversion engine." + ex); - BestMatchColor = Color.FromRgb((byte)Red, (byte)Green, (byte)Blue); - } - finally - { - IsBusy = false; - } - }); + if (stop.BrushColorSpace == BL.Enumerations.ColorSpaces.Volume) + { + IsOutOfGamut = false; + _red = output.SingleCoordinates.Red; + _green = output.SingleCoordinates.Green; + _blue = output.SingleCoordinates.Blue; + InitColor(); + BestMatchColor = Color.FromRgb((byte)output.SingleCoordinates.Red, (byte)output.SingleCoordinates.Green, (byte)output.SingleCoordinates.Blue); + } + else if (stop.BrushColorSpace == BL.Enumerations.ColorSpaces.LAB) + { + IsOutOfGamut = _converter.IsOutOfGamut(stop, configuration, rml); + BestMatchL = (double)output.SingleCoordinates.L; + BestMatchA = (double)output.SingleCoordinates.A; + BestMatchB = (double)output.SingleCoordinates.B; + Lab lab = new Lab(output.SingleCoordinates.L, output.SingleCoordinates.A, output.SingleCoordinates.B); + Rgb rgb = new Rgb(lab.ToRgb()); + BestMatchColor = Color.FromRgb((byte)rgb.R, (byte)rgb.G, (byte)rgb.B); + } + else if (stop.BrushColorSpace == BL.Enumerations.ColorSpaces.RGB) + { + IsOutOfGamut = _converter.IsOutOfGamut(stop, configuration, rml); + BestMatchColor = Color.FromRgb((byte)output.SingleCoordinates.Red, (byte)output.SingleCoordinates.Green, (byte)output.SingleCoordinates.Blue); + } + else if (stop.BrushColorSpace == BL.Enumerations.ColorSpaces.HSB) + { + IsOutOfGamut = _converter.IsOutOfGamut(stop, configuration, rml); + BestMatchColor = Color.FromRgb((byte)output.SingleCoordinates.Red, (byte)output.SingleCoordinates.Green, (byte)output.SingleCoordinates.Blue); + } + } + catch (Exception ex) + { + LogManager.Log(ex, "An error occurred while trying to get volume => RGB from conversion engine." + ex); + BestMatchColor = Color.FromRgb((byte)Red, (byte)Green, (byte)Blue); + } + finally + { + IsBusy = false; + } } #endregion diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/TestColor.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/TestColor.cs new file mode 100644 index 000000000..a83e0e595 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/TestColor.cs @@ -0,0 +1,30 @@ +using LiteDB; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core; +using Tango.PPC.Jobs.ColorCorrectionTool; + +namespace Tango.PPC.Jobs.Models +{ + public class TestColor : ExtendedObject + { + [BsonId] + public String BrushStopGuid { get; set; } + + public List<TrialsLogModel> TrialslogList { get; set; } + + public double L { get; set; } + public double A { get; set; } + public double B { get; set; } + + public TestColor() + { + TrialslogList = new List<TrialsLogModel>(); + } + } + +} 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 new file mode 100644 index 000000000..2e56c3780 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/TrialsLogModel.cs @@ -0,0 +1,214 @@ +using LiteDB; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core; + +namespace Tango.PPC.Jobs.Models +{ + public class TrialsLogModel: ExtendedObject + { + #region Properties + + private int _trialNumber; + + public int TrialNumber + { + get { return _trialNumber; } + set + { + _trialNumber = value; + RaisePropertyChangedAuto(); + RaisePropertyChanged(nameof(Trial)); + } + } + + [BsonIgnore] + public string Trial { + get { + if(TrialNumber == 0) + return "T"; + return TrialNumber.ToString(); + } + } + + private double? _l; + + public double? L + { + get { return _l; } + set { _l = value; + RaisePropertyChanged(nameof(LAB)); + OnLABChanged();} + } + private double? _a; + + public double? A + { + get { return _a; } + set { _a = value; RaisePropertyChanged(nameof(LAB)); OnLABChanged(); } + } + private double? _b; + + public double? B + { + get { return _b; } + set { _b = value; RaisePropertyChanged(nameof(LAB)); OnLABChanged(); } + } + + public double C { get; set; } + public double M { get; set; } + public double Y { get; set; } + public double K { get; set; } + + [BsonIgnore] + public string CMYK + { + get + { + return String.Format("{0:0.##},{1:0.##},{2:0.##},{3:0.##}", C, M, Y, K); + } + } + + [BsonIgnore] + public double TestC { get; set; } + [BsonIgnore] + public double TestM { get; set; } + [BsonIgnore] + public double TestY { get; set; } + [BsonIgnore] + public double TestK { get; set; } + + private DateTime _date; + + public DateTime Date + { + get { return _date; } + set { _date = value; RaisePropertyChangedAuto(); } + } + + private double? _deltaE; + + public double? DeltaE + { + get { return _deltaE; } + set { _deltaE = value; + RaisePropertyChangedAuto(); + RaisePropertyChanged(nameof(DeltaEDisplay)); + } + } + + public string DeltaEDisplay + { + get + { + if (DeltaE == null) + return ""; + // if (IsBest) + // return String.Format($"{DeltaE:0.##} Best"); + return String.Format($"{DeltaE:0.##}"); + } + } + private bool _IsActiveTrial; + [BsonIgnore] + public bool IsActiveTrial + { + get { return _IsActiveTrial; } + set { _IsActiveTrial = value; + RaisePropertyChangedAuto(); + } + } + + [BsonIgnore] + public string LAB + { + get { + if(!ValidationLAB()) + return ""; + return String.Format("{0:0.##},{1:0.##},{2:0.##}", L, A, B); } + } + + private bool _istested; + + public bool IsTested + { + get { return _istested; } + set + { + _istested = value; + if (_istested) + { + IsSelectionEnable = true; + } + } + } + + private bool _isBest; + + public bool IsBest + { + get { return _isBest; } + set { _isBest = value; + RaisePropertyChangedAuto(); + RaisePropertyChanged(nameof(DeltaEDisplay));} + } + + + + + private bool _isSelectionEnable; + [BsonIgnore] + public bool IsSelectionEnable + { + get { return _isSelectionEnable; } + set { _isSelectionEnable = value; + RaisePropertyChangedAuto(); + } + } + + + #endregion + + + public TrialsLogModel(int trial, double c, double m, double y, double k) + { + TrialNumber = trial; + IsActiveTrial = false; + C = c; + M = m; + Y = y; + K = k; + L = A = B = null; + Date = DateTime.UtcNow; + RaisePropertyChanged(nameof(CMYK)); + IsTested = false; + IsSelectionEnable = false; + IsBest = false; + } + + #region Methods + + private bool ValidationLAB() + { + if (L == null || L < 0 || L > 100 + || A == null || A < -128 || A > 127 + || B == null || B < -128 || B > 127) + return false; + return true; + } + + private void OnLABChanged() + { + if (ValidationLAB()) + { + ; + } + } + + #endregion + + + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Reports/ColorCorrectionReport.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Reports/ColorCorrectionReport.xaml new file mode 100644 index 000000000..0871dfd1b --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Reports/ColorCorrectionReport.xaml @@ -0,0 +1,79 @@ +<UserControl x:Class="Tango.PPC.Jobs.Reports.ColorCorrectionReport" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:local="clr-namespace:Tango.PPC.Jobs.Reports" + mc:Ignorable="d" + d:DesignHeight="1280" d:DesignWidth="800"> + <UserControl.Resources> + <Style x:Key="CCRGridColumnHeaderStyle" TargetType="{x:Type DataGridColumnHeader}"> + <Setter Property="Height" Value="50"/> + <Setter Property="FontSize" Value="14"/> + <Setter Property="FontWeight" Value="SemiBold"/> + <Setter Property="HorizontalAlignment" Value="Stretch"/> + <Setter Property="HorizontalContentAlignment" Value="Left"/> + <Setter Property="Background" Value="#7A7A7A"/> + <Setter Property="Foreground" Value="White"/> + <Setter Property="BorderThickness" Value="0,0,0,1"/> + </Style> + <Style x:Key="CCRDataGridStyle" TargetType="{x:Type DataGrid}"> + <Setter Property="BorderBrush" Value="#4B4B4B"/> + <Setter Property="BorderThickness" Value="0.5"/> + <Setter Property="GridLinesVisibility" Value="Horizontal"/> + <Setter Property="ColumnHeaderStyle" Value="{DynamicResource CCRGridColumnHeaderStyle}"/> + </Style> + </UserControl.Resources> + <Grid> + <StackPanel Orientation="Vertical" Margin="30"> + <DockPanel Height="120" VerticalAlignment="Top" > + <TextBlock DockPanel.Dock="Right" FontSize="12" Text="{Binding Date, StringFormat='{}{0:MM/dd/yyyy hh:mm}'}" VerticalAlignment="Bottom" HorizontalAlignment="Right"/> + <Image DockPanel.Dock="Left" Source="../Images/logo.png" Stretch="Uniform" HorizontalAlignment="Left" Margin="40 0 0 0" Width="282" VerticalAlignment="Top" MinHeight="106"></Image> + + </DockPanel> + <TextBlock Margin="0 40 0 0" Text=" Color Correction Report" FontSize="30" FontWeight="SemiBold" HorizontalAlignment="Center"/> + <TextBlock Margin="0 20 0 0"> + <Run Text="Job Name:" FontSize="19" ></Run> + <Run Text="{Binding JobName}" FontSize="19" ></Run> + </TextBlock> + <TextBlock Margin="0 20 0 0"> + <Run Text="Target color:" FontSize="19" ></Run> + <Run Text="{Binding TargetColor}" FontSize="19" ></Run> + </TextBlock> + <TextBlock Margin="0 20 0 20" FontSize="19" Text="Trials Log:"/> + <DataGrid Height="Auto" Width="550" ItemsSource="{Binding ReportItems}" RowHeight="30" HeadersVisibility="Column" CanUserAddRows="false" CanUserResizeColumns="False" IsReadOnly="true" HorizontalAlignment="Left" Style="{StaticResource CCRDataGridStyle}" Foreground="Black" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Disabled" TextBlock.TextAlignment="Left"> + <DataGrid.CellStyle> + <Style TargetType="DataGridCell"> + <Setter Property="TextBlock.TextAlignment" Value="Left" /> + </Style> + </DataGrid.CellStyle> + <DataGrid.Columns> + <DataGridTextColumn Header="#" FontSize="12" Binding="{Binding Trial}" Width="40" /> + <DataGridTextColumn Header="Date" FontSize="12" Binding="{Binding Date}" Width="130"/> + <DataGridTextColumn Header="CMYK" FontSize="12" Binding="{Binding CMYK}" Width="130"/> + <DataGridTextColumn Header="Measured L*a*b" FontSize="12" Binding="{Binding MeasuredLAB}" Width="130"/> + <DataGridTemplateColumn Header="dE(CMC)" Width="120"> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + <TextBlock Text="{Binding DeltaEPrint}" FontSize="12"> + <TextBlock.Style> + <Style TargetType="TextBlock"> + <Setter Property="Foreground" Value="Black"></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> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> + </DataGrid.Columns> + </DataGrid> + </StackPanel> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Reports/ColorCorrectionReport.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Reports/ColorCorrectionReport.xaml.cs new file mode 100644 index 000000000..9580413c7 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Reports/ColorCorrectionReport.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.PPC.Jobs.Reports +{ + /// <summary> + /// Interaction logic for ColorCorrectionReport.xaml + /// </summary> + public partial class ColorCorrectionReport : UserControl + { + public ColorCorrectionReport() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Reports/ColorCorrectionRepotVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Reports/ColorCorrectionRepotVM.cs new file mode 100644 index 000000000..7e07dfac6 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Reports/ColorCorrectionRepotVM.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.PPC.Jobs.Reports +{ + public class ColorCorrectionReportLogItem + { + public int TrialsNumber { get; set; } + public string Trial + { + get + { + if (TrialsNumber == 0) + return "T"; + return TrialsNumber.ToString(); + } + } + public DateTime Date { get; set; } + public string CMYK { get; set; } + public string MeasuredLAB { get; set; } + public double? DeltaE { get; set; } + public bool IsBest { get; set; } + public string DeltaEPrint + { + get { + if(DeltaE == null) + return""; + //if(IsBest) + // return String.Format($"{DeltaE:0.##} Best"); + return String.Format($"{DeltaE:0.##}"); + } + } + } + + public class ColorCorrectionRepotVM + { + public List<ColorCorrectionReportLogItem> ReportItems { get; set; } + public string JobName { get; set; } + public string TargetColor { get; set; } + public DateTime Date { get; set; } + + public ColorCorrectionRepotVM() + { + ReportItems = new List<ColorCorrectionReportLogItem>(); + Date = DateTime.UtcNow; + } + } +} 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 a1bf13df7..41238fda1 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 @@ -148,10 +148,18 @@ <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> + <Page Include="Dialogs\VectorFineTuningDialog.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> <Page Include="NotificationItems\NewSynchronizardJobsNotificationItemView.xaml"> <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> </Page> + <Page Include="Reports\ColorCorrectionReport.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> <Page Include="Resources\Styles.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> @@ -191,6 +199,7 @@ </Compile> <Compile Include="AppButtons\StartPrintingButton.cs" /> <Compile Include="AppButtons\StopPrintingButton.cs" /> + <Compile Include="ColorCorrectionTool\TrialsLogEngine.cs" /> <Compile Include="Controls\JobModelSummaryViewerControl.xaml.cs"> <DependentUpon>JobModelSummaryViewerControl.xaml</DependentUpon> </Compile> @@ -269,6 +278,10 @@ <DependentUpon>SpoolChangeView.xaml</DependentUpon> </Compile> <Compile Include="Dialogs\SpoolChangeViewVM.cs" /> + <Compile Include="Dialogs\VectorFineTuningDialog.xaml.cs"> + <DependentUpon>VectorFineTuningDialog.xaml</DependentUpon> + </Compile> + <Compile Include="Dialogs\VectorFineTuningDialogVM.cs" /> <Compile Include="Helpers\GroupSegmentTemplateSelector.cs" /> <Compile Include="JobsV2Module.cs" /> <Compile Include="JobsModuleSettings.cs" /> @@ -281,6 +294,8 @@ <Compile Include="Models\JobModel.cs" /> <Compile Include="Models\SegmentModel.cs" /> <Compile Include="Models\SegmentsGroupModel.cs" /> + <Compile Include="Models\TestColor.cs" /> + <Compile Include="Models\TrialsLogModel.cs" /> <Compile Include="MyColors\MyColorsEngine.cs" /> <Compile Include="NavigationObjects\JobNavigationObject.cs" /> <Compile Include="NavigationObjects\JobSummeryNavigationObject.cs" /> @@ -302,6 +317,10 @@ <DependentUpon>Settings.settings</DependentUpon> <DesignTimeSharedInput>True</DesignTimeSharedInput> </Compile> + <Compile Include="Reports\ColorCorrectionReport.xaml.cs"> + <DependentUpon>ColorCorrectionReport.xaml</DependentUpon> + </Compile> + <Compile Include="Reports\ColorCorrectionRepotVM.cs" /> <Compile Include="UndoRedoCommands\AddBrushStopCommand.cs" /> <Compile Include="UndoRedoCommands\AddNewSegmentCommand.cs" /> <Compile Include="UndoRedoCommands\ChangeLengthCommand.cs" /> @@ -398,6 +417,10 @@ <Project>{bc932dbd-7cdb-488c-99e4-f02cf441f55e}</Project> <Name>Tango.Logging</Name> </ProjectReference> + <ProjectReference Include="..\..\..\Tango.PDF\Tango.PDF.csproj"> + <Project>{84fb2b51-213e-4602-a5db-fa97d8ae907a}</Project> + <Name>Tango.PDF</Name> + </ProjectReference> <ProjectReference Include="..\..\..\Tango.PMR\Tango.PMR.csproj"> <Project>{e4927038-348d-4295-aaf4-861c58cb3943}</Project> <Name>Tango.PMR</Name> @@ -666,6 +689,17 @@ <ItemGroup> <Resource Include="Images\ColorSelection\Heart_disable.png" /> </ItemGroup> + <ItemGroup> + <Resource Include="Images\ColorSelection\VFineTuning.png" /> + </ItemGroup> + <ItemGroup> + <Resource Include="Images\ColorSelection\Clear.png" /> + <Resource Include="Images\ColorSelection\CorrectionTrial.png" /> + <Resource Include="Images\ColorSelection\Export.png" /> + </ItemGroup> + <ItemGroup> + <Resource Include="Images\logo.png" /> + </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <ProjectExtensions> <VisualStudio> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobViewVM.cs index cef55a4ad..01b819284 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobViewVM.cs @@ -428,8 +428,8 @@ namespace Tango.PPC.Jobs.ViewModels //await SetSpoolTension(Job.Rml); LogManager.Log("Loading RMLS..."); - Rmls = (await new RmlsCollectionBuilder(_db).SetAll().ForHeadType(MachineProvider.Machine.MachineHeadType).ForSite(MachineProvider.Machine.SiteGuid).BuildAsync()).OrderBy(x => x.FinalName).ToList(); - //Rmls = (await new RmlsCollectionBuilder(_db).SetAll().BuildAsync()).OrderBy(x => x.FinalName).ToList(); + //Rmls = (await new RmlsCollectionBuilder(_db).SetAll().ForHeadType(MachineProvider.Machine.MachineHeadType).ForSite(MachineProvider.Machine.SiteGuid).BuildAsync()).OrderBy(x => x.FinalName).ToList(); + Rmls = (await new RmlsCollectionBuilder(_db).SetAll().BuildAsync()).OrderBy(x => x.FinalName).ToList(); LogManager.Log("Loading Color Spaces..."); ColorSpaces = await _db.ColorSpaces.Where(x => x.Code != (int)BL.Enumerations.ColorSpaces.CMYK).ToListAsync(); LogManager.Log("Loading Spool Types..."); @@ -507,12 +507,11 @@ namespace Tango.PPC.Jobs.ViewModels Dictionary<string, SegmentsGroupModel> guidToGroup = new Dictionary<string, SegmentsGroupModel>(); if (Job.Version < 2) { + int segmentindex = 1; foreach (var segm in Job.OrderedSegments) { if(segm.BrushStops.Count > 1) { - int segmentindex = 1; - var brushes = segm.BrushStops; Segment currentSegment = segm; double lengthOfOldSegment = segm.Length; @@ -542,9 +541,11 @@ namespace Tango.PPC.Jobs.ViewModels else { SegmentModel segmentModel = LoadSegmentModel(segm, jobModel); + segmentModel.SegmentIndex = segmentindex++; jobModel.Segments.Add(segmentModel); } } + } else { @@ -613,12 +614,7 @@ namespace Tango.PPC.Jobs.ViewModels { DyeCommand.RaiseCanExecuteChanged(); } - public override void OnBeforeNavigatedFrom() - { - base.OnBeforeNavigatedFrom(); - //Save... - } - + /// <summary> /// Starts the job. /// </summary> @@ -1142,6 +1138,18 @@ namespace Tango.PPC.Jobs.ViewModels LoadJob(); } + + + public override void OnBeforeNavigatedTo() + { + base.OnBeforeNavigatedTo(); + } + + public override void OnBeforeNavigatedFrom() + { + base.OnBeforeNavigatedFrom(); + } + /// <summary> /// Called when the navigation system has navigated from this VM view. /// </summary> @@ -1360,6 +1368,7 @@ namespace Tango.PPC.Jobs.ViewModels foreach (var stop in innerSegment.BrushStops.OrderBy(x => x.StopIndex).ToList()) { var dbStop = new BrushStop(); + dbStop.Guid = stop.Guid; dbStop.Segment = dbSegment; _db.BrushStops.Add(dbStop); diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobView.xaml index 6bd4da509..51d0d80e6 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobView.xaml @@ -171,19 +171,19 @@ <StackPanel Orientation="Horizontal"> <TextBlock Text="L" FontSize="{StaticResource TangoSmallFontSize}" VerticalAlignment="Center"/> <Border Margin="10 0 0 0" Background="Transparent" BorderBrush="{StaticResource TangoGrayBrush}" BorderThickness="0.8" Width="42"> - <TextBlock Style="{StaticResource SliderGreyTextStyle}" Text="{Binding BestMatchL, StringFormat=0.0}" ></TextBlock> + <TextBlock Style="{StaticResource SliderGreyTextStyle}" Text="{Binding BestMatchL, StringFormat=0.##}" ></TextBlock> </Border> </StackPanel> <StackPanel Orientation="Horizontal" Margin="5 0 0 0"> <TextBlock Text="a" FontSize="{StaticResource TangoSmallFontSize}" VerticalAlignment="Center"/> <Border Margin="10 0 0 0" Background="Transparent" BorderBrush="{StaticResource TangoGrayBrush}" BorderThickness="0.8" Width="42"> - <TextBlock Style="{StaticResource SliderGreyTextStyle}" Text="{Binding BestMatchA, StringFormat=0.0}" ></TextBlock> + <TextBlock Style="{StaticResource SliderGreyTextStyle}" Text="{Binding BestMatchA, StringFormat=0.##}" ></TextBlock> </Border> </StackPanel> <StackPanel Orientation="Horizontal" Margin="10 0 0 0"> <TextBlock Text="b" FontSize="{StaticResource TangoSmallFontSize}" VerticalAlignment="Center"/> <Border Margin="10 0 0 0" Background="Transparent" BorderBrush="{StaticResource TangoGrayBrush}" BorderThickness="0.8" Width="42"> - <TextBlock Style="{StaticResource SliderGreyTextStyle}" Text="{Binding BestMatchB, StringFormat=0.0}" ></TextBlock> + <TextBlock Style="{StaticResource SliderGreyTextStyle}" Text="{Binding BestMatchB, StringFormat=0.##}" ></TextBlock> </Border> </StackPanel> </UniformGrid> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/ViewModels/MainViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/ViewModels/MainViewVM.cs index 59005509e..f057f2e73 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/ViewModels/MainViewVM.cs @@ -261,6 +261,14 @@ namespace Tango.PPC.MachineSettings.ViewModels set { _enableProxy = value; RaisePropertyChangedAuto(); } } + private int _manualFineTuningLength; + public int FineTuningLength + { + get { return _manualFineTuningLength; } + set { _manualFineTuningLength = value; RaisePropertyChangedAuto(); } + } + + #endregion #region Commands @@ -317,6 +325,7 @@ namespace Tango.PPC.MachineSettings.ViewModels Settings.SynchronizeDiagnostics = SynchronizeDiagnostics; Settings.AutoCheckForUpdates = AutoCheckForUpdates; Settings.LubricationLevels = LubricationLevels.Where(x => x.LubricationLevel != LubricationLevel.Standard).Select(x => x.ToRmlLubricationLevel()).ToList(); + Settings.FineTuningTrialLengthMeters = FineTuningLength; MachineDataSynchronizer.IsEnabled = SynchronizeJobs || SynchronizeDiagnostics; @@ -519,6 +528,8 @@ namespace Tango.PPC.MachineSettings.ViewModels LockScreenTimeoutMinutes = (int)Settings.LockScreenTimeout.TotalMinutes; LockScreenPassword = Settings.LockScreenPassword; + FineTuningLength = Settings.FineTuningTrialLengthMeters; + SelectedJobTypes = new SelectedObjectCollection<JobTypes>(Enum.GetValues(typeof(JobTypes)).Cast<JobTypes>().ToObservableCollection(), Settings.SupportedJobTypes.ToObservableCollection()); SelectedColorSpaces = new SelectedObjectCollection<ColorSpaces>(Enum.GetValues(typeof(ColorSpaces)).Cast<ColorSpaces>().Where(x => x.IsUserSpace()).ToObservableCollection(), Settings.SupportedColorSpaces.ToObservableCollection()); 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 bf8777200..74b0ce7e1 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 @@ -160,6 +160,9 @@ <TextBlock VerticalAlignment="Bottom">Default Segment Length</TextBlock> <touch:TouchNumericTextBox HorizontalAlignment="Right" VerticalAlignment="Bottom" Width="200" Minimum="1" Maximum="1000" Value="{Binding Settings.DefaultSegmentLength}" HasDecimalPoint="True" KeyboardContainer="{Binding ElementName=Container}"></touch:TouchNumericTextBox> + <TextBlock VerticalAlignment="Bottom">Vector Fine Tuning Job Length</TextBlock> + <touch:TouchNumericTextBox HorizontalAlignment="Right" VerticalAlignment="Bottom" Width="200" Minimum="100" Maximum="500" Value="{Binding FineTuningLength}" HasDecimalPoint="False" KeyboardContainer="{Binding ElementName=Container}"></touch:TouchNumericTextBox> + <TextBlock VerticalAlignment="Bottom">Use Light Inks When Possible</TextBlock> <touch:TouchToggleSlider Style="{StaticResource TangoToggleButtonGrayAccent}" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="90" IsChecked="{Binding UseLightInks}"></touch:TouchToggleSlider> </controls:TableGrid> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/MachineStatusControl.xaml b/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/MachineStatusControl.xaml new file mode 100644 index 000000000..b2bb998f7 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/MachineStatusControl.xaml @@ -0,0 +1,49 @@ +<UserControl x:Class="Tango.PPC.Common.Controls.MachineStatusControl" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" + xmlns:operations="clr-namespace:Tango.Integration.Operation;assembly=Tango.Integration" + xmlns:local="clr-namespace:Tango.PPC.Common.Controls" + mc:Ignorable="d" + Width="36" Height="Auto"> + <Grid> + <touch:TouchGifAnimation Width="36" HorizontalAlignment="Center" EnableAnimation="True"> + <touch:TouchGifAnimation.Style> + <Style TargetType="touch:TouchGifAnimation"> + <Setter Property="Source" Value="/Images/GlobalStatus/standby.png"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding Status}" Value="{x:Static operations:MachineStatuses.Disconnected}"> + <Setter Property="Source" Value="/Images/GlobalStatus/machine_off_Anim.gif"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Status}" Value="{x:Static operations:MachineStatuses.PowerUp}"> + <Setter Property="Source" Value="/Images/GlobalStatus/getting_ready_Anim.gif"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Status}" Value="{x:Static operations:MachineStatuses.Standby}"> + <Setter Property="Source" Value="/Images/GlobalStatus/standby_Anim.gif"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Status}" Value="{x:Static operations:MachineStatuses.ReadyToDye}"> + <Setter Property="Source" Value="/Images/GlobalStatus/Ready_Anim.gif"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Status}" Value="{x:Static operations:MachineStatuses.GettingReady}"> + <Setter Property="Source" Value="/Images/GlobalStatus/getting_ready_Anim.gif"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Status}" Value="{x:Static operations:MachineStatuses.Printing}"> + <Setter Property="Source" Value="/Images/GlobalStatus/dyeing_Anim.gif"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Status}" Value="{x:Static operations:MachineStatuses.ShuttingDown}"> + <Setter Property="Source" Value="/Images/GlobalStatus/shutdown_icon_Anim.gif"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Status}" Value="{x:Static operations:MachineStatuses.Error}"> + <Setter Property="Source" Value="/Images/GlobalStatus/error_Anim.gif"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Status}" Value="{x:Static operations:MachineStatuses.Service}"> + <Setter Property="Source" Value="/Images/GlobalStatus/service_Anim.gif"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </touch:TouchGifAnimation.Style> + </touch:TouchGifAnimation> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/MachineStatusControl.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/MachineStatusControl.xaml.cs new file mode 100644 index 000000000..55f1294f2 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/MachineStatusControl.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.PPC.Common.Controls +{ + /// <summary> + /// Interaction logic for MachineStatusControl.xaml + /// </summary> + public partial class MachineStatusControl : UserControl + { + public MachineStatusControl() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogRenderer.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogRenderer.cs index 3af921f7d..8d57cbfd0 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogRenderer.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogRenderer.cs @@ -372,7 +372,8 @@ namespace Tango.PPC.Common.Controls { if(collectionFilter.Filter(item.Item)) { - _scrollViewer.ScrollToPosition(item.PositionY - _scrollViewer.ActualHeight / 2); + if (_scrollViewer != null) + _scrollViewer.ScrollToPosition(item.PositionY - _scrollViewer.ActualHeight / 2); break; } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Images/GlobalStatus/Ready_Anim.gif b/Software/Visual_Studio/PPC/Tango.PPC.Common/Images/GlobalStatus/Ready_Anim.gif Binary files differnew file mode 100644 index 000000000..11cef3b10 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Images/GlobalStatus/Ready_Anim.gif diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Images/GlobalStatus/dyeing.png b/Software/Visual_Studio/PPC/Tango.PPC.Common/Images/GlobalStatus/dyeing.png Binary files differnew file mode 100644 index 000000000..fbace4fa5 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Images/GlobalStatus/dyeing.png diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Images/GlobalStatus/dyeing_Anim.gif b/Software/Visual_Studio/PPC/Tango.PPC.Common/Images/GlobalStatus/dyeing_Anim.gif Binary files differnew file mode 100644 index 000000000..058d9a34d --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Images/GlobalStatus/dyeing_Anim.gif diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Images/GlobalStatus/error.png b/Software/Visual_Studio/PPC/Tango.PPC.Common/Images/GlobalStatus/error.png Binary files differnew file mode 100644 index 000000000..b4b50e4ac --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Images/GlobalStatus/error.png diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Images/GlobalStatus/error_Anim.gif b/Software/Visual_Studio/PPC/Tango.PPC.Common/Images/GlobalStatus/error_Anim.gif Binary files differnew file mode 100644 index 000000000..9bf0d84f3 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Images/GlobalStatus/error_Anim.gif diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Images/GlobalStatus/getting-ready.png b/Software/Visual_Studio/PPC/Tango.PPC.Common/Images/GlobalStatus/getting-ready.png Binary files differnew file mode 100644 index 000000000..a0dc77f92 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Images/GlobalStatus/getting-ready.png diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Images/GlobalStatus/getting_ready_Anim.gif b/Software/Visual_Studio/PPC/Tango.PPC.Common/Images/GlobalStatus/getting_ready_Anim.gif Binary files differnew file mode 100644 index 000000000..79256816a --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Images/GlobalStatus/getting_ready_Anim.gif diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Images/GlobalStatus/machine-off.png b/Software/Visual_Studio/PPC/Tango.PPC.Common/Images/GlobalStatus/machine-off.png Binary files differnew file mode 100644 index 000000000..6dc569e35 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Images/GlobalStatus/machine-off.png diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Images/GlobalStatus/machine_off_Anim.gif b/Software/Visual_Studio/PPC/Tango.PPC.Common/Images/GlobalStatus/machine_off_Anim.gif Binary files differnew file mode 100644 index 000000000..9ca81da39 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Images/GlobalStatus/machine_off_Anim.gif diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Images/GlobalStatus/ready-to-dye.png b/Software/Visual_Studio/PPC/Tango.PPC.Common/Images/GlobalStatus/ready-to-dye.png Binary files differnew file mode 100644 index 000000000..7edf624be --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Images/GlobalStatus/ready-to-dye.png diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Images/GlobalStatus/service.png b/Software/Visual_Studio/PPC/Tango.PPC.Common/Images/GlobalStatus/service.png Binary files differnew file mode 100644 index 000000000..ba351ee66 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Images/GlobalStatus/service.png diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Images/GlobalStatus/service_Anim.gif b/Software/Visual_Studio/PPC/Tango.PPC.Common/Images/GlobalStatus/service_Anim.gif Binary files differnew file mode 100644 index 000000000..f5962c36c --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Images/GlobalStatus/service_Anim.gif diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Images/GlobalStatus/shutdown_icon_Anim.gif b/Software/Visual_Studio/PPC/Tango.PPC.Common/Images/GlobalStatus/shutdown_icon_Anim.gif Binary files differnew file mode 100644 index 000000000..d936476b6 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Images/GlobalStatus/shutdown_icon_Anim.gif diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Images/GlobalStatus/shutting-down.png b/Software/Visual_Studio/PPC/Tango.PPC.Common/Images/GlobalStatus/shutting-down.png Binary files differnew file mode 100644 index 000000000..9aa8e2db6 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Images/GlobalStatus/shutting-down.png diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Images/GlobalStatus/standby.png b/Software/Visual_Studio/PPC/Tango.PPC.Common/Images/GlobalStatus/standby.png Binary files differnew file mode 100644 index 000000000..6b46c22c0 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Images/GlobalStatus/standby.png diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Images/GlobalStatus/standby_Anim.gif b/Software/Visual_Studio/PPC/Tango.PPC.Common/Images/GlobalStatus/standby_Anim.gif Binary files differnew file mode 100644 index 000000000..89491179d --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Images/GlobalStatus/standby_Anim.gif diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs index ff6dbce08..ee353917d 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs @@ -309,6 +309,11 @@ namespace Tango.PPC.Common public bool UseJobsModuleV2 { get; set; } /// <summary> + /// Gets or sets the fine tuning trial length in meters. + /// </summary> + public int FineTuningTrialLengthMeters { get; set; } + + /// <summary> /// Gets the machine service address. /// </summary> /// <returns></returns> @@ -324,6 +329,7 @@ namespace Tango.PPC.Common { LubricationLevels = new List<RmlLubricationLevel>(); JobUploadStrategy = JobUploadStrategy.JobDescriptionFile; + FineTuningTrialLengthMeters = 200; EnableGradientGeneration = true; GradientGenerationResolution = 20; MachineScanningTimeoutSeconds = 20; diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj index af3531817..80fce2052 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj @@ -148,6 +148,9 @@ <Compile Include="Console\IConsoleEngineService.cs" /> <Compile Include="Controls\AsyncAdornerControl.cs" /> <Compile Include="Controls\ImageGalleryControl.cs" /> + <Compile Include="Controls\MachineStatusControl.xaml.cs"> + <DependentUpon>MachineStatusControl.xaml</DependentUpon> + </Compile> <Compile Include="Controls\TwineCatalogControl.xaml.cs"> <DependentUpon>TwineCatalogControl.xaml</DependentUpon> </Compile> @@ -292,6 +295,10 @@ <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> + <Page Include="Controls\MachineStatusControl.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> <Page Include="Controls\MultiPieChart.xaml"> <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> @@ -517,6 +524,54 @@ <Resource Include="Images\cl-full.png" /> <Resource Include="Images\lubricant2.png" /> </ItemGroup> + <ItemGroup> + <Resource Include="Images\GlobalStatus\dyeing.png" /> + </ItemGroup> + <ItemGroup> + <Resource Include="Images\GlobalStatus\dyeing_Anim.gif" /> + </ItemGroup> + <ItemGroup> + <Resource Include="Images\GlobalStatus\error.png" /> + </ItemGroup> + <ItemGroup> + <Resource Include="Images\GlobalStatus\error_Anim.gif" /> + </ItemGroup> + <ItemGroup> + <Resource Include="Images\GlobalStatus\getting-ready.png" /> + </ItemGroup> + <ItemGroup> + <Resource Include="Images\GlobalStatus\getting_ready_Anim.gif" /> + </ItemGroup> + <ItemGroup> + <Resource Include="Images\GlobalStatus\machine-off.png" /> + </ItemGroup> + <ItemGroup> + <Resource Include="Images\GlobalStatus\machine_off_Anim.gif" /> + </ItemGroup> + <ItemGroup> + <Resource Include="Images\GlobalStatus\ready-to-dye.png" /> + </ItemGroup> + <ItemGroup> + <Resource Include="Images\GlobalStatus\Ready_Anim.gif" /> + </ItemGroup> + <ItemGroup> + <Resource Include="Images\GlobalStatus\service.png" /> + </ItemGroup> + <ItemGroup> + <Resource Include="Images\GlobalStatus\service_Anim.gif" /> + </ItemGroup> + <ItemGroup> + <Resource Include="Images\GlobalStatus\shutdown_icon_Anim.gif" /> + </ItemGroup> + <ItemGroup> + <Resource Include="Images\GlobalStatus\shutting-down.png" /> + </ItemGroup> + <ItemGroup> + <Resource Include="Images\GlobalStatus\standby.png" /> + </ItemGroup> + <ItemGroup> + <Resource Include="Images\GlobalStatus\standby_Anim.gif" /> + </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="..\..\packages\System.Data.SQLite.Core.1.0.108.0\build\net46\System.Data.SQLite.Core.targets" Condition="Exists('..\..\packages\System.Data.SQLite.Core.1.0.108.0\build\net46\System.Data.SQLite.Core.targets')" /> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Printing/DefaultPrintingManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Printing/DefaultPrintingManager.cs index c23455fbd..9856faf3d 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Printing/DefaultPrintingManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Printing/DefaultPrintingManager.cs @@ -64,7 +64,7 @@ namespace Tango.PPC.UI.Printing #else try { - if (_settings.EnableSpoolReplacementDialog && !_machineProvider.MachineOperator.IsSpoolReplaced) + if (job.Designation == JobDesignations.Default && _settings.EnableSpoolReplacementDialog && !_machineProvider.MachineOperator.IsSpoolReplaced) { if (!(await _notificationProvider.ShowDialog(new SpoolReplaceViewVM())).DialogResult) { @@ -146,6 +146,7 @@ namespace Tango.PPC.UI.Printing if (!context.IsDisposed) { await context.SaveChangesAsync(); + RaiseJobSaved(job); } else { @@ -156,11 +157,10 @@ namespace Tango.PPC.UI.Printing { newJob.JobStatus = JobStatuses.Completed; await newContext.SaveChangesAsync(); + RaiseJobSaved(job); } } } - - RaiseJobSaved(job); } catch (Exception ex) { diff --git a/Software/Visual_Studio/Tango.BL/Entities/BrushStop.cs b/Software/Visual_Studio/Tango.BL/Entities/BrushStop.cs index 89ce78b16..1e13cda6d 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/BrushStop.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/BrushStop.cs @@ -183,7 +183,7 @@ namespace Tango.BL.Entities if (Segment != null && Segment.Job != null) { - if (Segment.Job.Version < 2) + if (Segment.Job.Version < 2 || (BestMatchR == null || BestMatchG == null || BestMatchB == null)) { r = (byte)Red; g = (byte)Green; diff --git a/Software/Visual_Studio/Tango.BL/Entities/Job.cs b/Software/Visual_Studio/Tango.BL/Entities/Job.cs index 04451da31..91f13bab0 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/Job.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/Job.cs @@ -807,6 +807,7 @@ namespace Tango.BL.Entities jobFile.Type = job.Type; jobFile.WindingMethodGuid = job.WindingMethodGuid; jobFile.ColorCatalogGuid = job.ColorCatalogGuid.ToStringOrEmpty(); + jobFile.Version = job.Version; foreach (var segm in job.OrderedSegmentsWithGroups) { @@ -921,6 +922,7 @@ namespace Tango.BL.Entities job.LengthPercentageFactor = jobFile.LengthPercentageFactor; job.Name = jobFile.Name.ToNullIfEmpty(); job.NumberOfUnits = jobFile.NumberOfUnits; + job.Version = jobFile.Version; var job_rml = db.Rmls.SingleOrDefault(x => x.Guid == jobFile.RmlGuid); diff --git a/Software/Visual_Studio/Tango.Explorer/ExplorerFileDefinition.cs b/Software/Visual_Studio/Tango.Explorer/ExplorerFileDefinition.cs index a1c4a05ae..fbbf2ef63 100644 --- a/Software/Visual_Studio/Tango.Explorer/ExplorerFileDefinition.cs +++ b/Software/Visual_Studio/Tango.Explorer/ExplorerFileDefinition.cs @@ -77,6 +77,13 @@ namespace Tango.Explorer Extension = ".csv", }; + public static ExplorerFileDefinition PDFFile => new ExplorerFileDefinition() + { + Icon = ResourceHelper.GetImageFromResources("/Images/file.png"), + Description = "PDF File", + Extension = ".pdf", + }; + static ExplorerFileDefinition() { _definitions = typeof(ExplorerFileDefinition).GetProperties(BindingFlags.Public | BindingFlags.Static).Where(x => x.PropertyType == typeof(ExplorerFileDefinition)).ToList().Select(x => x.GetValue(null, null) as ExplorerFileDefinition).ToList(); diff --git a/Software/Visual_Studio/Tango.Integration/JobRuns/BasicJobRunsLogger.cs b/Software/Visual_Studio/Tango.Integration/JobRuns/BasicJobRunsLogger.cs index 2b7c931f0..8c3822278 100644 --- a/Software/Visual_Studio/Tango.Integration/JobRuns/BasicJobRunsLogger.cs +++ b/Software/Visual_Studio/Tango.Integration/JobRuns/BasicJobRunsLogger.cs @@ -332,6 +332,8 @@ namespace Tango.Integration.JobRuns { _job = e.Job; + if (_job.Designation == JobDesignations.FineTuning) return; + if (e.IsResumed) { try diff --git a/Software/Visual_Studio/Tango.PDF/PdfWpfWriter.cs b/Software/Visual_Studio/Tango.PDF/PdfWpfWriter.cs new file mode 100644 index 000000000..179b3ada0 --- /dev/null +++ b/Software/Visual_Studio/Tango.PDF/PdfWpfWriter.cs @@ -0,0 +1,118 @@ +using PdfSharp; +using PdfSharp.Drawing; +using System; +using System.Collections.Generic; +using System.IO; +using System.IO.Packaging; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using System.Windows.Threading; +using System.Windows.Xps; +using System.Windows.Xps.Packaging; + +namespace Tango.PDF +{ + public class PdfWpfWriter + { + private List<FrameworkElement> _elements; + + public PdfWpfWriter() + { + _elements = new List<FrameworkElement>(); + } + + public void AddElement(FrameworkElement element) + { + _elements.Add(element); + } + + public void RemoveElement(FrameworkElement element) + { + _elements.Remove(element); + } + + public Size GetA4Size() + { + XSize a4Size = PageSizeConverter.ToSize(PageSize.A4); + return new Size(a4Size.Width, a4Size.Height); + } + + public void Save(String filePath) + { + using (MemoryStream lMemoryStream = new MemoryStream()) + { + Package package = Package.Open(lMemoryStream, FileMode.Create); + XpsDocument doc = new XpsDocument(package); + XpsDocumentWriter writer = XpsDocument.CreateXpsDocumentWriter(doc); + + List<StackPanel> stacks = new List<StackPanel>(); + + StackPanel currentStack = new StackPanel(); + stacks.Add(currentStack); + + XSize a4Size = PageSizeConverter.ToSize(PageSize.A4); + + foreach (var element in _elements.ToList()) + { + //element.Width = a4Size.Width * 0.80; + currentStack.Children.Add(element); + + currentStack.Measure(new Size(Double.MaxValue, Double.MaxValue)); + Size visualSize = currentStack.DesiredSize; + currentStack.Arrange(new Rect(new Point(0, 0), visualSize)); + currentStack.UpdateLayout(); + + if (visualSize.Height > a4Size.Height) + { + currentStack.Children.Remove(element); + currentStack.UpdateLayout(); + currentStack.InvalidateVisual(); + + currentStack = new StackPanel(); + currentStack.Children.Add(element); + stacks.Add(currentStack); + } + } + + Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, new Action(() => { })).Wait(); + Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Render, new Action(() => { })).Wait(); + + FixedDocument fixedDoc = new FixedDocument(); + + foreach (var stack in stacks) + { + PageContent pageContent = new PageContent(); + FixedPage fixedPage = new FixedPage(); + fixedPage.Height = a4Size.Height; + fixedPage.Width = a4Size.Width; + + fixedPage.Children.Add(stack); + ((System.Windows.Markup.IAddChild)pageContent).AddChild(fixedPage); + fixedDoc.Pages.Add(pageContent); + } + + writer.Write(fixedDoc); + doc.Close(); + package.Close(); + + MemoryStream outStream = new MemoryStream(); + PdfSharp.Xps.XpsConverter.Convert(lMemoryStream, outStream, true); + + File.WriteAllBytes(filePath, outStream.ToArray()); + + lMemoryStream.Dispose(); + outStream.Dispose(); + } + } + } +} diff --git a/Software/Visual_Studio/Tango.PDF/Properties/AssemblyInfo.cs b/Software/Visual_Studio/Tango.PDF/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..941147f2e --- /dev/null +++ b/Software/Visual_Studio/Tango.PDF/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Tango.PDF")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Tango.PDF")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("84fb2b51-213e-4602-a5db-fa97d8ae907a")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Software/Visual_Studio/Tango.PDF/Tango.PDF.csproj b/Software/Visual_Studio/Tango.PDF/Tango.PDF.csproj new file mode 100644 index 000000000..47ddba495 --- /dev/null +++ b/Software/Visual_Studio/Tango.PDF/Tango.PDF.csproj @@ -0,0 +1,67 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProjectGuid>{84FB2B51-213E-4602-A5DB-FA97D8AE907A}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>Tango.PDF</RootNamespace> + <AssemblyName>Tango.PDF</AssemblyName> + <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + <Deterministic>true</Deterministic> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup> + <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> + </PropertyGroup> + <ItemGroup> + <Reference Include="HiraokaHyperTools.PdfSharp-WPF, Version=1.31.6209.0, Culture=neutral, PublicKeyToken=f94615aa0424f9eb, processorArchitecture=MSIL"> + <HintPath>..\packages\kenjiuno.PdfSharp-WPF.1.31.6209\lib\net40\HiraokaHyperTools.PdfSharp-WPF.dll</HintPath> + </Reference> + <Reference Include="HiraokaHyperTools.PdfSharp.Xps, Version=1.1.10.0, Culture=neutral, PublicKeyToken=f94615aa0424f9eb, processorArchitecture=MSIL"> + <HintPath>..\packages\kenjiuno.PdfSharp.Xps.1.1.10\lib\net40\HiraokaHyperTools.PdfSharp.Xps.dll</HintPath> + </Reference> + <Reference Include="PresentationCore" /> + <Reference Include="PresentationFramework" /> + <Reference Include="ReachFramework" /> + <Reference Include="System" /> + <Reference Include="System.Core" /> + <Reference Include="System.Drawing" /> + <Reference Include="System.Printing" /> + <Reference Include="System.Xaml" /> + <Reference Include="System.Xml.Linq" /> + <Reference Include="System.Data.DataSetExtensions" /> + <Reference Include="Microsoft.CSharp" /> + <Reference Include="System.Data" /> + <Reference Include="System.Net.Http" /> + <Reference Include="System.Xml" /> + <Reference Include="WindowsBase" /> + </ItemGroup> + <ItemGroup> + <Compile Include="PdfWpfWriter.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="packages.config" /> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> +</Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/Tango.PDF/packages.config b/Software/Visual_Studio/Tango.PDF/packages.config new file mode 100644 index 000000000..77755e1a5 --- /dev/null +++ b/Software/Visual_Studio/Tango.PDF/packages.config @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<packages> + <package id="kenjiuno.PdfSharp.Xps" version="1.1.10" targetFramework="net461" /> + <package id="kenjiuno.PdfSharp-WPF" version="1.31.6209" targetFramework="net461" /> +</packages>
\ No newline at end of file diff --git a/Software/Visual_Studio/Tango.PMR/Exports/JobFile.cs b/Software/Visual_Studio/Tango.PMR/Exports/JobFile.cs index 7aa03c4cb..dda4e2441 100644 --- a/Software/Visual_Studio/Tango.PMR/Exports/JobFile.cs +++ b/Software/Visual_Studio/Tango.PMR/Exports/JobFile.cs @@ -23,7 +23,7 @@ namespace Tango.PMR.Exports { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( "Cg1Kb2JGaWxlLnByb3RvEhFUYW5nby5QTVIuRXhwb3J0cxoUSm9iRmlsZVNl", - "Z21lbnQucHJvdG8iuwQKB0pvYkZpbGUSDAoETmFtZRgBIAEoCRITCgtEZXNj", + "Z21lbnQucHJvdG8izAQKB0pvYkZpbGUSDAoETmFtZRgBIAEoCRITCgtEZXNj", "cmlwdGlvbhgCIAEoCRIaChJFbmFibGVJbnRlclNlZ21lbnQYAyABKAgSGgoS", "SW50ZXJTZWdtZW50TGVuZ3RoGAQgASgBEg8KB1JtbEd1aWQYBSABKAkSGQoR", "V2luZGluZ01ldGhvZEd1aWQYBiABKAkSFQoNU3Bvb2xUeXBlR3VpZBgHIAEo", @@ -36,11 +36,12 @@ namespace Tango.PMR.Exports { "YW1wbGVVbml0c09yTWV0ZXJzGBMgASgFEh4KFkxlbmd0aFBlcmNlbnRhZ2VG", "YWN0b3IYFCABKAESMwoIU2VnbWVudHMYFSADKAsyIS5UYW5nby5QTVIuRXhw", "b3J0cy5Kb2JGaWxlU2VnbWVudBIYChBDb2xvckNhdGFsb2dHdWlkGBYgASgJ", - "Qh0KG2NvbS50d2luZS50YW5nby5wbXIuZXhwb3J0c2IGcHJvdG8z")); + "Eg8KB1ZlcnNpb24YFyABKAVCHQobY29tLnR3aW5lLnRhbmdvLnBtci5leHBv", + "cnRzYgZwcm90bzM=")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { global::Tango.PMR.Exports.JobFileSegmentReflection.Descriptor, }, new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Exports.JobFile), global::Tango.PMR.Exports.JobFile.Parser, new[]{ "Name", "Description", "EnableInterSegment", "InterSegmentLength", "RmlGuid", "WindingMethodGuid", "SpoolTypeGuid", "EnableLubrication", "HasEmbroideryFile", "EmbroideryFileData", "EmbroideryFileName", "EmbroideryJpeg", "ColorSpaceGuid", "NumberOfUnits", "Type", "Customer", "SpoolsDistribution", "NumberOfHeads", "SampleUnitsOrMeters", "LengthPercentageFactor", "Segments", "ColorCatalogGuid" }, null, null, null) + new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Exports.JobFile), global::Tango.PMR.Exports.JobFile.Parser, new[]{ "Name", "Description", "EnableInterSegment", "InterSegmentLength", "RmlGuid", "WindingMethodGuid", "SpoolTypeGuid", "EnableLubrication", "HasEmbroideryFile", "EmbroideryFileData", "EmbroideryFileName", "EmbroideryJpeg", "ColorSpaceGuid", "NumberOfUnits", "Type", "Customer", "SpoolsDistribution", "NumberOfHeads", "SampleUnitsOrMeters", "LengthPercentageFactor", "Segments", "ColorCatalogGuid", "Version" }, null, null, null) })); } #endregion @@ -93,6 +94,7 @@ namespace Tango.PMR.Exports { lengthPercentageFactor_ = other.lengthPercentageFactor_; segments_ = other.segments_.Clone(); colorCatalogGuid_ = other.colorCatalogGuid_; + version_ = other.version_; } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -341,6 +343,17 @@ namespace Tango.PMR.Exports { } } + /// <summary>Field number for the "Version" field.</summary> + public const int VersionFieldNumber = 23; + private int version_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Version { + get { return version_; } + set { + version_ = value; + } + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as JobFile); @@ -376,6 +389,7 @@ namespace Tango.PMR.Exports { if (LengthPercentageFactor != other.LengthPercentageFactor) return false; if(!segments_.Equals(other.segments_)) return false; if (ColorCatalogGuid != other.ColorCatalogGuid) return false; + if (Version != other.Version) return false; return true; } @@ -404,6 +418,7 @@ namespace Tango.PMR.Exports { if (LengthPercentageFactor != 0D) hash ^= LengthPercentageFactor.GetHashCode(); hash ^= segments_.GetHashCode(); if (ColorCatalogGuid.Length != 0) hash ^= ColorCatalogGuid.GetHashCode(); + if (Version != 0) hash ^= Version.GetHashCode(); return hash; } @@ -499,6 +514,10 @@ namespace Tango.PMR.Exports { output.WriteRawTag(178, 1); output.WriteString(ColorCatalogGuid); } + if (Version != 0) { + output.WriteRawTag(184, 1); + output.WriteInt32(Version); + } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -568,6 +587,9 @@ namespace Tango.PMR.Exports { if (ColorCatalogGuid.Length != 0) { size += 2 + pb::CodedOutputStream.ComputeStringSize(ColorCatalogGuid); } + if (Version != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(Version); + } return size; } @@ -640,6 +662,9 @@ namespace Tango.PMR.Exports { if (other.ColorCatalogGuid.Length != 0) { ColorCatalogGuid = other.ColorCatalogGuid; } + if (other.Version != 0) { + Version = other.Version; + } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -738,6 +763,10 @@ namespace Tango.PMR.Exports { ColorCatalogGuid = input.ReadString(); break; } + case 184: { + Version = input.ReadInt32(); + break; + } } } } diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericUpDownConrol.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericUpDownConrol.cs index adb98d91d..2b85e8168 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericUpDownConrol.cs +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericUpDownConrol.cs @@ -59,7 +59,21 @@ namespace Tango.Touch.Controls /// </summary> public static readonly DependencyProperty MaxValueProperty = DependencyProperty.Register("MaxValue", typeof(double), typeof(TouchNumericUpDownConrol), new PropertyMetadata(100.0)); - + + + + public double NumericPartWidth + { + get { return (double)GetValue(NumericPartWidthProperty); } + set { SetValue(NumericPartWidthProperty, value); } + } + + // Using a DependencyProperty as the backing store for NumericPartWidth. This enables animation, styling, binding, etc... + public static readonly DependencyProperty NumericPartWidthProperty = + DependencyProperty.Register("NumericPartWidth", typeof(double), typeof(TouchNumericUpDownConrol), new PropertyMetadata(54.0)); + + + #endregion #region Commands diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericUpDownConrol.xaml b/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericUpDownConrol.xaml index 31c32be83..8eea1bfbe 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericUpDownConrol.xaml +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericUpDownConrol.xaml @@ -79,10 +79,10 @@ </Style.Triggers> </Style> </StackPanel.Resources> - <Border Background="Transparent" BorderBrush="{StaticResource TangoGrayBrush}" BorderThickness="0.8" CornerRadius="2" Width="54"> + <Border Background="Transparent" BorderBrush="{StaticResource TangoGrayBrush}" BorderThickness="0.8" CornerRadius="2" Width="{Binding NumericPartWidth,RelativeSource={RelativeSource AncestorType=local:TouchNumericUpDownConrol}}" > <local:TouchNumericTextBox x:Name="Number_PART" Margin="0 4 0 0" FontSize="20" HorizontalContentAlignment="Center" VerticalAlignment="Center" BorderBrush="{TemplateBinding BorderBrush}" VerticalContentAlignment="Center" UpdateBindingOnlyWhenFocused="True" - Value="{Binding Value,RelativeSource={RelativeSource AncestorType=local:TouchNumericUpDownConrol}}" Minimum="{Binding MinValue,RelativeSource={RelativeSource AncestorType=local:TouchNumericUpDownConrol}}" Maximum="{Binding MaxValue,RelativeSource={RelativeSource AncestorType=local:TouchNumericUpDownConrol}}" HasDecimalPoint="True" StringFormat="0.#"/> + Value="{Binding Value,RelativeSource={RelativeSource AncestorType=local:TouchNumericUpDownConrol}}" Minimum="{Binding MinValue,RelativeSource={RelativeSource AncestorType=local:TouchNumericUpDownConrol}}" Maximum="{Binding MaxValue,RelativeSource={RelativeSource AncestorType=local:TouchNumericUpDownConrol}}" HasDecimalPoint="True" StringFormat="0.##"/> </Border> <Border Margin="10 0 0 0" BorderBrush="{StaticResource TangoGrayBrush}" BorderThickness="0.8" Width="80"> @@ -91,7 +91,7 @@ Command="{Binding Path=DecrementCommand,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:TouchNumericUpDownConrol}, Mode=TwoWay}"> <local:TouchIcon Focusable="False" Icon="Minus" Width="16" Height="3"/> </RepeatButton> - <Rectangle Margin="1 0 0 0" Width="0.8" Fill="{StaticResource TangoGrayBrush}"></Rectangle> + <Rectangle Margin="1 0 1 0" Width="0.8" Fill="{StaticResource TangoGrayBrush}"></Rectangle> <RepeatButton Focusable="False" Background="Transparent" Margin="8 0 0 0" Padding="4" Style="{StaticResource emptyButton}" Command="{Binding Path=IncrementCommand,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:TouchNumericUpDownConrol}, Mode=TwoWay}"> <local:TouchIcon Focusable="False" Icon="Plus" Width="16"/> diff --git a/Software/Visual_Studio/Tango.sln b/Software/Visual_Studio/Tango.sln index 8415287b5..b305193f8 100644 --- a/Software/Visual_Studio/Tango.sln +++ b/Software/Visual_Studio/Tango.sln @@ -477,6 +477,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.PPC.JobsV2", "PPC\Mod EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Tango.ColorLib_v5", "ColorLib\Tango.ColorLib_v5\Tango.ColorLib_v5.vcxproj", "{0F87D32E-B65F-4AE8-862C-29F4CCC38240}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.PDF", "Tango.PDF\Tango.PDF.csproj", "{84FB2B51-213E-4602-A5DB-FA97D8AE907A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -4548,6 +4550,26 @@ Global {0F87D32E-B65F-4AE8-862C-29F4CCC38240}.Release|x64.Build.0 = Release|x64 {0F87D32E-B65F-4AE8-862C-29F4CCC38240}.Release|x86.ActiveCfg = Release|Win32 {0F87D32E-B65F-4AE8-862C-29F4CCC38240}.Release|x86.Build.0 = Release|Win32 + {84FB2B51-213E-4602-A5DB-FA97D8AE907A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {84FB2B51-213E-4602-A5DB-FA97D8AE907A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {84FB2B51-213E-4602-A5DB-FA97D8AE907A}.Debug|ARM.ActiveCfg = Debug|Any CPU + {84FB2B51-213E-4602-A5DB-FA97D8AE907A}.Debug|ARM.Build.0 = Debug|Any CPU + {84FB2B51-213E-4602-A5DB-FA97D8AE907A}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {84FB2B51-213E-4602-A5DB-FA97D8AE907A}.Debug|ARM64.Build.0 = Debug|Any CPU + {84FB2B51-213E-4602-A5DB-FA97D8AE907A}.Debug|x64.ActiveCfg = Debug|Any CPU + {84FB2B51-213E-4602-A5DB-FA97D8AE907A}.Debug|x64.Build.0 = Debug|Any CPU + {84FB2B51-213E-4602-A5DB-FA97D8AE907A}.Debug|x86.ActiveCfg = Debug|Any CPU + {84FB2B51-213E-4602-A5DB-FA97D8AE907A}.Debug|x86.Build.0 = Debug|Any CPU + {84FB2B51-213E-4602-A5DB-FA97D8AE907A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {84FB2B51-213E-4602-A5DB-FA97D8AE907A}.Release|Any CPU.Build.0 = Release|Any CPU + {84FB2B51-213E-4602-A5DB-FA97D8AE907A}.Release|ARM.ActiveCfg = Release|Any CPU + {84FB2B51-213E-4602-A5DB-FA97D8AE907A}.Release|ARM.Build.0 = Release|Any CPU + {84FB2B51-213E-4602-A5DB-FA97D8AE907A}.Release|ARM64.ActiveCfg = Release|Any CPU + {84FB2B51-213E-4602-A5DB-FA97D8AE907A}.Release|ARM64.Build.0 = Release|Any CPU + {84FB2B51-213E-4602-A5DB-FA97D8AE907A}.Release|x64.ActiveCfg = Release|Any CPU + {84FB2B51-213E-4602-A5DB-FA97D8AE907A}.Release|x64.Build.0 = Release|Any CPU + {84FB2B51-213E-4602-A5DB-FA97D8AE907A}.Release|x86.ActiveCfg = Release|Any CPU + {84FB2B51-213E-4602-A5DB-FA97D8AE907A}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -4720,12 +4742,12 @@ Global {0F87D32E-B65F-4AE8-862C-29F4CCC38240} = {7181F9DE-0760-46B7-AD8F-BDBCAEDEF1B7} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {7986F7F4-A86A-4994-B1B6-0988D7F057B6} - BuildVersion_BuildVersioningStyle = None.None.Increment.DeltaBaseYearDayOfYear - BuildVersion_UpdateAssemblyVersion = True - BuildVersion_UpdateFileVersion = False - BuildVersion_StartDate = 2000/1/1 - BuildVersion_AssemblyInfoFilename = Properties\AssemblyInfo.cs BuildVersion_UseGlobalSettings = False + BuildVersion_AssemblyInfoFilename = Properties\AssemblyInfo.cs + BuildVersion_StartDate = 2000/1/1 + BuildVersion_UpdateFileVersion = False + BuildVersion_UpdateAssemblyVersion = True + BuildVersion_BuildVersioningStyle = None.None.Increment.DeltaBaseYearDayOfYear + SolutionGuid = {7986F7F4-A86A-4994-B1B6-0988D7F057B6} EndGlobalSection EndGlobal |
