diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-12-23 00:24:11 +0200 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-12-23 00:24:11 +0200 |
| commit | 518c9192e4445d82f192edcccb2ffb64ffc88a65 (patch) | |
| tree | bbf30297b0e452066801aefd9c9f2916020e57a6 /Software | |
| parent | 7b6ec0a4e66a4402d5ee0beb4b34b18604e28cd8 (diff) | |
| download | Tango-518c9192e4445d82f192edcccb2ffb64ffc88a65.tar.gz Tango-518c9192e4445d82f192edcccb2ffb64ffc88a65.zip | |
ColorSpace per stop implemented on PPC.
Synchronization only when values change.
Volume open for all.
RGB to closest catalog item...
Diffstat (limited to 'Software')
14 files changed, 383 insertions, 250 deletions
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs index 5e90d3b5b..e8af7c957 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs @@ -37,6 +37,7 @@ using Tango.PPC.Storage; using System.IO; using Tango.ColorConversion; using Tango.Integration.Operation; +using Tango.BL.Enumerations; namespace Tango.PPC.Jobs.ViewModels { @@ -188,39 +189,16 @@ namespace Tango.PPC.Jobs.ViewModels set { _isJobDetailsExpanded = value; RaisePropertyChangedAuto(); } } - private List<ColorCatalogsItem> _catalogItems; - /// <summary> - /// Gets or sets the twine catalog items. - /// </summary> - public List<ColorCatalogsItem> CatalogItems - { - get { return _catalogItems; } - set { _catalogItems = value; RaisePropertyChangedAuto(); } - } - - private ColorCatalogsItem _selectedCatalogItem; - /// <summary> - /// Gets or sets the selected catalog item. - /// </summary> - public ColorCatalogsItem SelectedCatalogItem - { - get { return _selectedCatalogItem; } - set { _selectedCatalogItem = value; RaisePropertyChangedAuto(); } - } - /// <summary> /// Gets or sets the twine catalog automatic complete provider. /// </summary> public IAutoCompleteProvider CatalogAutoCompleteProvider { get; set; } - private ColorCatalog _selectedCatalog; - /// <summary> - /// Gets or sets the selected catalog. - /// </summary> - public ColorCatalog SelectedCatalog + private List<ColorCatalog> _availableCatalogs; + public List<ColorCatalog> AvailableCatalogs { - get { return _selectedCatalog; } - set { _selectedCatalog = value; RaisePropertyChangedAuto(); } + get { return _availableCatalogs; } + set { _availableCatalogs = value; RaisePropertyChangedAuto(); } } #endregion @@ -362,7 +340,6 @@ namespace Tango.PPC.Jobs.ViewModels FineTuneItems = new ObservableCollection<FineTuneItem>(); ApprovalFineTuneItems = new ObservableCollection<FineTuneItem>(); - CatalogItems = new List<ColorCatalogsItem>(); CustomersAutoCompleteProvider = new AutoCompleteProvider<Customer>((customer, filter) => { @@ -471,33 +448,17 @@ namespace Tango.PPC.Jobs.ViewModels LogManager.Log("Loading RMLS..."); Rmls = (await new RmlsCollectionBuilder(_db).SetAll().WithActiveParametersGroup().WithCAT(Job.MachineGuid).WithCCT().WithLiquidFactors().WithSpools().ForHeadType(MachineProvider.Machine.MachineHeadType).ForSite(MachineProvider.Machine.SiteGuid).BuildAsync()).ToList(); LogManager.Log("Loading Color Spaces..."); - ColorSpaces = await _db.ColorSpaces.ToListAsync(); + ColorSpaces = await _db.ColorSpaces.Where(x => x.Code != (int)BL.Enumerations.ColorSpaces.CMYK).ToListAsync(); LogManager.Log("Loading Spool Types..."); SpoolTypes = await _db.SpoolTypes.ToListAsync(); LogManager.Log("Loading Customers..."); Customers = await _db.Customers.Where(x => x.OrganizationGuid == MachineProvider.Machine.OrganizationGuid).ToListAsync(); - if (Job.ColorSpace.Space == BL.Enumerations.ColorSpaces.Catalog) - { - SelectedCatalog = await new CatalogBuilder(_db).Set(Job.ColorCatalogGuid).WithGroups().WithItems().BuildAsync(); - - if (SelectedCatalog != null) - { - CatalogItems = SelectedCatalog.ColorCatalogsGroups.SelectMany(x => x.ColorCatalogsItems).OrderBy(x => x.ItemIndex).ToList(); - } - else - { - await NotificationProvider.ShowError("The selected color catalog for this job could not be found.\nCannot load job."); - Job = null; - _can_navigate_back = true; - await NavigationManager.NavigateBack(); - return; - } - } + AvailableCatalogs = await new CatalogsCollectionBuilder(_db).SetAll().WithGroups().WithItems().ForSite(MachineProvider.Machine.SiteGuid).BuildListAsync(); foreach (var segment in Job.Segments) { - SetSegmentLiquidVolumesIfVolume(segment); + SetSegmentLiquidVolumes(segment); } if (!_check_gamut_thread.IsAlive) @@ -540,6 +501,8 @@ namespace Tango.PPC.Jobs.ViewModels ValidateBrushStops(); + CoerceBrushStopsColorSpaceChange(); + DyeCommand.RaiseCanExecuteChanged(); StartSampleDyeCommand.RaiseCanExecuteChanged(); StartFineTuningCommand.RaiseCanExecuteChanged(); @@ -718,7 +681,8 @@ namespace Tango.PPC.Jobs.ViewModels { LogManager.Log("Adding new solid segment..."); var s = Job.AddSolidSegment(Settings.DefaultSegmentLength > 0 ? Settings.DefaultSegmentLength : 10); - SetSegmentLiquidVolumesIfVolume(s); + SetSegmentLiquidVolumes(s); + CoerceBrushStopsColorSpaceChange(); return s; } catch (Exception ex) @@ -738,7 +702,8 @@ namespace Tango.PPC.Jobs.ViewModels { LogManager.Log("Adding new gradient segment..."); var s = Job.AddGradientSegment(Settings.DefaultSegmentLength > 0 ? Settings.DefaultSegmentLength : 10); - SetSegmentLiquidVolumesIfVolume(s); + SetSegmentLiquidVolumes(s); + CoerceBrushStopsColorSpaceChange(); return s; } catch (Exception ex) @@ -811,19 +776,16 @@ namespace Tango.PPC.Jobs.ViewModels /// Sets the segment liquid volumes. /// </summary> /// <param name="segment">The segment.</param> - private void SetSegmentLiquidVolumesIfVolume(Segment segment) + private void SetSegmentLiquidVolumes(Segment segment) { - if (Job.ColorSpace.Code == BL.Enumerations.ColorSpaces.Volume.ToInt32()) + foreach (var stop in segment.BrushStops) { - foreach (var stop in segment.BrushStops) - { - stop.SetLiquidVolumes(Job.Machine.Configuration, Job.Rml, Job.Rml.GetActiveProcessGroup().ProcessParametersTables.FirstOrDefault()); + stop.SetLiquidVolumes(Job.Machine.Configuration, Job.Rml, Job.Rml.GetActiveProcessGroup().ProcessParametersTables.FirstOrDefault()); - var lub = stop.LiquidVolumes.FirstOrDefault(x => x.IdsPack.LiquidType.Code == (int)BL.Enumerations.LiquidTypes.Lubricant); - if (lub != null) - { - lub.Volume = 100; - } + var lub = stop.LiquidVolumes.FirstOrDefault(x => x.IdsPack.LiquidType.Code == (int)BL.Enumerations.LiquidTypes.Lubricant); + if (lub != null) + { + lub.Volume = 100; } } } @@ -844,6 +806,24 @@ namespace Tango.PPC.Jobs.ViewModels #region Brush Stops Management + private void CoerceBrushStopsColorSpaceChange() + { + if (Job != null) + { + foreach (var stop in Job.Segments.SelectMany(x => x.BrushStops).ToList()) + { + stop.ColorSpaceChanged -= Stop_ColorSpaceChanged; + stop.ColorSpaceChanged += Stop_ColorSpaceChanged; + } + } + } + + private void Stop_ColorSpaceChanged(object sender, ColorSpace e) + { + BrushStop stop = sender as BrushStop; + stop.Segment.BrushStops.Where(x => x != stop).ToList().ForEach(x => x.ColorSpace = stop.ColorSpace); + } + /// <summary> /// Adds a new brush stop to the specified segment. /// </summary> @@ -852,7 +832,8 @@ namespace Tango.PPC.Jobs.ViewModels { LogManager.Log($"Adding new brush stop to segment {segment.SegmentIndex}."); segment.AddBrushStop(); - SetSegmentLiquidVolumesIfVolume(segment); + SetSegmentLiquidVolumes(segment); + CoerceBrushStopsColorSpaceChange(); } /// <summary> @@ -987,34 +968,56 @@ namespace Tango.PPC.Jobs.ViewModels { if (stop != null && stop.ColorSpace != null) { - stop.Corrected = false; - stop.OutOfGamutChecked = false; + if (stop.BrushColorSpace == BL.Enumerations.ColorSpaces.Catalog) return; - if (stop.BrushColorSpace == BL.Enumerations.ColorSpaces.Volume) + _volumeConversionTimer.ResetReplace(() => { - _volumeConversionTimer.ResetReplace(() => + + try { - try - { - var output = _converter.Convert(stop, false); + var output = _converter.Convert(stop, false); + if (stop.BrushColorSpace == BL.Enumerations.ColorSpaces.Volume) + { stop.Red = output.SingleCoordinates.Red; stop.Green = output.SingleCoordinates.Green; stop.Blue = output.SingleCoordinates.Blue; + stop.L = output.SingleCoordinates.L; + stop.A = output.SingleCoordinates.A; + stop.B = output.SingleCoordinates.B; stop.Corrected = true; stop.IsOutOfGamut = false; - - InvokeUI(() => - { - DyeCommand.RaiseCanExecuteChanged(); - }); } - catch (Exception ex) + else if (stop.BrushColorSpace == BL.Enumerations.ColorSpaces.LAB) { - LogManager.Log(ex, "An error occurred while trying to get volume => RGB from conversion engine."); + output.ApplyOnBrushStopVolumesOnly(stop); + stop.Corrected = false; + stop.OutOfGamutChecked = false; } - }); - } + else if (stop.BrushColorSpace == BL.Enumerations.ColorSpaces.RGB) + { + output.ApplyOnBrushStopVolumesOnly(stop); + stop.Corrected = false; + stop.OutOfGamutChecked = false; + } + + try + { + var closestItem = AvailableCatalogs.SelectMany(x => x.AllItemsOrdered).GetClosestItem(stop.Color); + stop.ColorCatalog = closestItem.ColorCatalogsGroup.ColorCatalog; + stop.ColorCatalogsItem = closestItem; + } + catch { } + + InvokeUI(() => DyeCommand.RaiseCanExecuteChanged()); + } + catch (Exception ex) + { + LogManager.Log(ex, "An error occurred while trying to get volume => RGB from conversion engine."); + } + + }); + } } @@ -1027,7 +1030,7 @@ namespace Tango.PPC.Jobs.ViewModels var catalogItem = await NavigationManager.NavigateForResult<JobsModule, TwineCatalogView, ColorCatalogsItem, TwineCatalogNavigationObject>(new TwineCatalogNavigationObject() { SelectedItem = stop.ColorCatalogsItem, - Catalog = SelectedCatalog + Catalog = stop.ColorCatalog }, true); if (catalogItem != null) @@ -1298,9 +1301,9 @@ namespace Tango.PPC.Jobs.ViewModels { Thread.Sleep(500); - if (Job != null && Job.Rml.Cct != null && IsVisible && (Job.ColorSpace != null && (Job.ColorSpace.Code == BL.Enumerations.ColorSpaces.RGB.ToInt32() || Job.ColorSpace.Code == BL.Enumerations.ColorSpaces.LAB.ToInt32()))) + if (Job != null && Job.Rml.Cct != null && IsVisible) { - var brushStops = Job.Segments.SelectMany(x => x.BrushStops).Where(x => !x.Corrected && !x.OutOfGamutChecked).ToList(); + var brushStops = Job.Segments.SelectMany(x => x.BrushStops).Where(x => (x.BrushColorSpace == BL.Enumerations.ColorSpaces.LAB || x.BrushColorSpace == BL.Enumerations.ColorSpaces.RGB) && !x.Corrected && !x.OutOfGamutChecked).ToList(); foreach (var stop in brushStops) { diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs index 64931cbe3..23e381206 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs @@ -314,11 +314,11 @@ namespace Tango.PPC.Jobs.ViewModels /// <param name="job">The job.</param> public async void SelectJob(Job job, bool directlyToEdit = false) { - if (!ApplicationManager.IsInTechnicianMode && job.ColorSpace != null && job.ColorSpace.Code == ColorSpaces.Volume.ToInt32()) - { - await NotificationProvider.ShowError("The selected job is supported only in technician mode."); - return; - } + //if (!ApplicationManager.IsInTechnicianMode && job.ColorSpace != null && job.ColorSpace.Code == ColorSpaces.Volume.ToInt32()) + //{ + // await NotificationProvider.ShowError("The selected job is supported only in technician mode."); + // return; + //} LogManager.Log($"Job '{job.Name}' selected."); diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml index 6a94034db..467c3f72b 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml @@ -65,33 +65,34 @@ <DataTemplate x:Key="RGB_Template" DataType="{x:Type entities:BrushStop}"> <UniformGrid Rows="1" Columns="3"> - <touch:TouchNumericTextBox Margin="2 0" ValueChanged="OnBrushStopFieldValueChanged" HorizontalContentAlignment="Center" Value="{Binding Red}" keyboard:KeyboardView.Container="{Binding ElementName=Container}" Maximum="255" /> - <touch:TouchNumericTextBox Margin="2 0" ValueChanged="OnBrushStopFieldValueChanged" HorizontalContentAlignment="Center" Value="{Binding Green}" keyboard:KeyboardView.Container="{Binding ElementName=Container}" Maximum="255" /> - <touch:TouchNumericTextBox Margin="2 0" ValueChanged="OnBrushStopFieldValueChanged" HorizontalContentAlignment="Center" Value="{Binding Blue}" keyboard:KeyboardView.Container="{Binding ElementName=Container}" Maximum="255" /> + <touch:TouchNumericTextBox UpdateBindingOnlyWhenFocused="True" Margin="2 0" ValueChanged="OnBrushStopFieldValueChanged" HorizontalContentAlignment="Center" Value="{Binding Red}" keyboard:KeyboardView.Container="{Binding ElementName=Container}" Maximum="255" /> + <touch:TouchNumericTextBox UpdateBindingOnlyWhenFocused="True" Margin="2 0" ValueChanged="OnBrushStopFieldValueChanged" HorizontalContentAlignment="Center" Value="{Binding Green}" keyboard:KeyboardView.Container="{Binding ElementName=Container}" Maximum="255" /> + <touch:TouchNumericTextBox UpdateBindingOnlyWhenFocused="True" Margin="2 0" ValueChanged="OnBrushStopFieldValueChanged" HorizontalContentAlignment="Center" Value="{Binding Blue}" keyboard:KeyboardView.Container="{Binding ElementName=Container}" Maximum="255" /> </UniformGrid> </DataTemplate> <DataTemplate x:Key="CMYK_Template" DataType="{x:Type entities:BrushStop}"> <UniformGrid Rows="1" Columns="4"> - <touch:TouchNumericTextBox Margin="2 0" ValueChanged="OnBrushStopFieldValueChanged" HorizontalContentAlignment="Center" Value="{Binding Cyan,Converter={StaticResource OneToPercentConverter}}" keyboard:KeyboardView.Container="{Binding ElementName=Container}" HasDecimalPoint="True" Maximum="100" StringFormat="0" /> - <touch:TouchNumericTextBox Margin="2 0" ValueChanged="OnBrushStopFieldValueChanged" HorizontalContentAlignment="Center" Value="{Binding Magenta,Converter={StaticResource OneToPercentConverter}}" keyboard:KeyboardView.Container="{Binding ElementName=Container}" HasDecimalPoint="True" Maximum="100" StringFormat="0" /> - <touch:TouchNumericTextBox Margin="2 0" ValueChanged="OnBrushStopFieldValueChanged" HorizontalContentAlignment="Center" Value="{Binding Yellow,Converter={StaticResource OneToPercentConverter}}" keyboard:KeyboardView.Container="{Binding ElementName=Container}" HasDecimalPoint="True" Maximum="100" StringFormat="0" /> - <touch:TouchNumericTextBox Margin="2 0" ValueChanged="OnBrushStopFieldValueChanged" HorizontalContentAlignment="Center" Value="{Binding Black,Converter={StaticResource OneToPercentConverter}}" keyboard:KeyboardView.Container="{Binding ElementName=Container}" HasDecimalPoint="True" Maximum="100" StringFormat="0" /> + <touch:TouchNumericTextBox UpdateBindingOnlyWhenFocused="True" Margin="2 0" ValueChanged="OnBrushStopFieldValueChanged" HorizontalContentAlignment="Center" Value="{Binding Cyan,Converter={StaticResource OneToPercentConverter}}" keyboard:KeyboardView.Container="{Binding ElementName=Container}" HasDecimalPoint="True" Maximum="100" StringFormat="0" /> + <touch:TouchNumericTextBox UpdateBindingOnlyWhenFocused="True" Margin="2 0" ValueChanged="OnBrushStopFieldValueChanged" HorizontalContentAlignment="Center" Value="{Binding Magenta,Converter={StaticResource OneToPercentConverter}}" keyboard:KeyboardView.Container="{Binding ElementName=Container}" HasDecimalPoint="True" Maximum="100" StringFormat="0" /> + <touch:TouchNumericTextBox UpdateBindingOnlyWhenFocused="True" Margin="2 0" ValueChanged="OnBrushStopFieldValueChanged" HorizontalContentAlignment="Center" Value="{Binding Yellow,Converter={StaticResource OneToPercentConverter}}" keyboard:KeyboardView.Container="{Binding ElementName=Container}" HasDecimalPoint="True" Maximum="100" StringFormat="0" /> + <touch:TouchNumericTextBox UpdateBindingOnlyWhenFocused="True" Margin="2 0" ValueChanged="OnBrushStopFieldValueChanged" HorizontalContentAlignment="Center" Value="{Binding Black,Converter={StaticResource OneToPercentConverter}}" keyboard:KeyboardView.Container="{Binding ElementName=Container}" HasDecimalPoint="True" Maximum="100" StringFormat="0" /> </UniformGrid> </DataTemplate> <DataTemplate x:Key="LAB_Template" DataType="{x:Type entities:BrushStop}"> <UniformGrid Rows="1" Columns="3"> - <touch:TouchNumericTextBox Margin="2 0" ValueChanged="OnBrushStopFieldValueChanged" HorizontalContentAlignment="Center" Value="{Binding L}" keyboard:KeyboardView.Container="{Binding ElementName=Container}" HasDecimalPoint="True" Minimum="0" Maximum="100" StringFormat="0.00" /> - <touch:TouchNumericTextBox Margin="2 0" ValueChanged="OnBrushStopFieldValueChanged" HorizontalContentAlignment="Center" Value="{Binding A}" keyboard:KeyboardView.Container="{Binding ElementName=Container}" HasDecimalPoint="True" Minimum="-128" Maximum="128" StringFormat="0.00" /> - <touch:TouchNumericTextBox Margin="2 0" ValueChanged="OnBrushStopFieldValueChanged" HorizontalContentAlignment="Center" Value="{Binding B}" keyboard:KeyboardView.Container="{Binding ElementName=Container}" HasDecimalPoint="True" Minimum="-128" Maximum="128" StringFormat="0.00" /> + <touch:TouchNumericTextBox UpdateBindingOnlyWhenFocused="True" Margin="2 0" ValueChanged="OnBrushStopFieldValueChanged" HorizontalContentAlignment="Center" Value="{Binding L}" keyboard:KeyboardView.Container="{Binding ElementName=Container}" HasDecimalPoint="True" Minimum="0" Maximum="100" StringFormat="0.00" /> + <touch:TouchNumericTextBox UpdateBindingOnlyWhenFocused="True" Margin="2 0" ValueChanged="OnBrushStopFieldValueChanged" HorizontalContentAlignment="Center" Value="{Binding A}" keyboard:KeyboardView.Container="{Binding ElementName=Container}" HasDecimalPoint="True" Minimum="-128" Maximum="128" StringFormat="0.00" /> + <touch:TouchNumericTextBox UpdateBindingOnlyWhenFocused="True" Margin="2 0" ValueChanged="OnBrushStopFieldValueChanged" HorizontalContentAlignment="Center" Value="{Binding B}" keyboard:KeyboardView.Container="{Binding ElementName=Container}" HasDecimalPoint="True" Minimum="-128" Maximum="128" StringFormat="0.00" /> </UniformGrid> </DataTemplate> <DataTemplate x:Key="CATALOG_Template" DataType="{x:Type entities:BrushStop}"> - <DockPanel> + <DockPanel Margin="0 0 -90 0"> + <touch:TouchComboBox DockPanel.Dock="Left" ItemsSource="{Binding ElementName=view,Path=DataContext.AvailableCatalogs}" SelectedItem="{Binding ColorCatalog}" DisplayMemberPath="Name" Title="Select Catalog" Width="130" Margin="0 0 10 0" /> <touch:TouchIconButton Margin="0 0 -50 -10" CornerRadius="50" Width="50" Height="50" Padding="13" RippleBrush="{StaticResource TangoRippleDarkBrush}" DockPanel.Dock="Right" Icon="Palette" Foreground="{StaticResource TangoPrimaryAccentBrush}" Command="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.OpenCatalogCommand}" CommandParameter="{Binding}"></touch:TouchIconButton> - <touch:TouchAutoComplete Margin="2 0" ItemsSource="{Binding ElementName=view,Path=DataContext.CatalogItems}" Watermark="Color Code" PopupHeight="250" DisplayMemberPath="Name" AutoCompleteProvider="{Binding ElementName=view,Path=DataContext.CatalogAutoCompleteProvider}" SelectedItem="{Binding ColorCatalogsItem,Mode=TwoWay,ValidatesOnDataErrors=True,ValidatesOnNotifyDataErrors=True}" keyboard:KeyboardView.Container="{Binding ElementName=Container}"> + <touch:TouchAutoComplete Margin="2 0" ItemsSource="{Binding ColorCatalog.AllItemsOrdered}" Watermark="Color Code" PopupHeight="250" DisplayMemberPath="Name" AutoCompleteProvider="{Binding ElementName=view,Path=DataContext.CatalogAutoCompleteProvider}" SelectedItem="{Binding ColorCatalogsItem,Mode=TwoWay,ValidatesOnDataErrors=True,ValidatesOnNotifyDataErrors=True}" keyboard:KeyboardView.Container="{Binding ElementName=Container}"> <touch:TouchAutoComplete.ItemTemplate> <DataTemplate> <DockPanel Margin="2"> @@ -149,32 +150,21 @@ </Setter.Value> </Setter> <Style.Triggers> - <DataTrigger Binding="{Binding ElementName=view,Path=DataContext.Job.ColorSpace.Name,IsAsync=True}" Value="RGB"> + <DataTrigger Binding="{Binding ColorSpace.Name,IsAsync=True}" Value="RGB"> <Setter Property="ContentTemplate" Value="{StaticResource RGB_Template}" /> </DataTrigger> - <DataTrigger Binding="{Binding ElementName=view,Path=DataContext.Job.ColorSpace.Name,IsAsync=True}" Value="CMYK"> + <DataTrigger Binding="{Binding ColorSpace.Name,IsAsync=True}" Value="CMYK"> <Setter Property="ContentTemplate" Value="{StaticResource CMYK_Template}" /> </DataTrigger> - <DataTrigger Binding="{Binding ElementName=view,Path=DataContext.Job.ColorSpace.Name,IsAsync=True}" Value="LAB"> + <DataTrigger Binding="{Binding ColorSpace.Name,IsAsync=True}" Value="LAB"> <Setter Property="ContentTemplate" Value="{StaticResource LAB_Template}" /> </DataTrigger> - <DataTrigger Binding="{Binding ElementName=view,Path=DataContext.Job.ColorSpace.Name,IsAsync=True}" Value="Catalog"> + <DataTrigger Binding="{Binding ColorSpace.Name,IsAsync=True}" Value="Catalog"> <Setter Property="ContentTemplate" Value="{StaticResource CATALOG_Template}" /> </DataTrigger> - <DataTrigger Binding="{Binding ElementName=view,Path=DataContext.Job.ColorSpace.Name,IsAsync=True}" Value="Volume"> + <DataTrigger Binding="{Binding ColorSpace.Name,IsAsync=True}" Value="Volume"> <Setter Property="ContentTemplate" Value="{StaticResource Volume_Template}" /> </DataTrigger> - <DataTrigger Binding="{Binding IsTransparent,IsAsync=True}" Value="True"> - <Setter Property="ContentTemplate"> - <Setter.Value> - <DataTemplate> - <Grid Height="40"> - <TextBlock VerticalAlignment="Bottom" Foreground="{StaticResource TangoGrayBrush}">Transparent</TextBlock> - </Grid> - </DataTemplate> - </Setter.Value> - </Setter> - </DataTrigger> </Style.Triggers> </Style> </ContentControl.Style> @@ -215,9 +205,6 @@ <Border.CacheMode> <BitmapCache RenderAtScale="1" SnapsToDevicePixels="True" /> </Border.CacheMode> - <!--<Border.Effect> - <DropShadowEffect Opacity="0.5" Color="{StaticResource TangoDropShadowColor}" BlurRadius="10" ShadowDepth="15" /> - </Border.Effect>--> <Grid> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> @@ -303,8 +290,12 @@ </StackPanel> <Grid> - <StackPanel Margin="0 30 0 0" VerticalAlignment="Bottom" HorizontalAlignment="Left" Width="300" Visibility="{Binding ElementName=toggle_large_list,Path=IsChecked,Converter={StaticResource BooleanToVisibilityConverter},IsAsync=True}"> - <DockPanel LastChildFill="False"> + <StackPanel Margin="0 5 0 0" HorizontalAlignment="Left" Width="300" Visibility="{Binding ElementName=toggle_large_list,Path=IsChecked,Converter={StaticResource BooleanToVisibilityConverter},IsAsync=True}"> + <DockPanel LastChildFill="False" Margin="0 0 0 0"> + <TextBlock Text="Color space:" VerticalAlignment="Bottom"></TextBlock> + <touch:TouchComboBox DockPanel.Dock="Right" ItemsSource="{Binding ElementName=view,Path=DataContext.ColorSpaces}" SelectedItem="{Binding BrushStops[0].ColorSpace}" DisplayMemberPath="Name" Title="Select Color Space" Width="179" HorizontalAlignment="Right" /> + </DockPanel> + <DockPanel LastChildFill="False" Margin="0 5 0 0"> <DockPanel.Style> <Style TargetType="DockPanel"> <Setter Property="Visibility" Value="Visible"></Setter> @@ -330,32 +321,21 @@ </Setter.Value> </Setter> <Style.Triggers> - <DataTrigger Binding="{Binding ElementName=view,Path=DataContext.Job.ColorSpace.Name,IsAsync=True}" Value="RGB"> + <DataTrigger Binding="{Binding ColorSpace.Name,IsAsync=True}" Value="RGB"> <Setter Property="ContentTemplate" Value="{StaticResource RGB_Template}" /> </DataTrigger> - <DataTrigger Binding="{Binding ElementName=view,Path=DataContext.Job.ColorSpace.Name,IsAsync=True}" Value="CMYK"> + <DataTrigger Binding="{Binding ColorSpace.Name,IsAsync=True}" Value="CMYK"> <Setter Property="ContentTemplate" Value="{StaticResource CMYK_Template}" /> </DataTrigger> - <DataTrigger Binding="{Binding ElementName=view,Path=DataContext.Job.ColorSpace.Name,IsAsync=True}" Value="LAB"> + <DataTrigger Binding="{Binding ColorSpace.Name,IsAsync=True}" Value="LAB"> <Setter Property="ContentTemplate" Value="{StaticResource LAB_Template}" /> </DataTrigger> - <DataTrigger Binding="{Binding ElementName=view,Path=DataContext.Job.ColorSpace.Name,IsAsync=True}" Value="Catalog"> + <DataTrigger Binding="{Binding ColorSpace.Name,IsAsync=True}" Value="Catalog"> <Setter Property="ContentTemplate" Value="{StaticResource CATALOG_Template}" /> </DataTrigger> - <DataTrigger Binding="{Binding ElementName=view,Path=DataContext.Job.ColorSpace.Name,IsAsync=True}" Value="Volume"> + <DataTrigger Binding="{Binding ColorSpace.Name,IsAsync=True}" Value="Volume"> <Setter Property="ContentTemplate" Value="{StaticResource Volume_Template}" /> </DataTrigger> - <DataTrigger Binding="{Binding IsTransparent,IsAsync=True}" Value="True"> - <Setter Property="ContentTemplate"> - <Setter.Value> - <DataTemplate> - <Grid Height="40"> - <TextBlock VerticalAlignment="Bottom" Foreground="{StaticResource TangoGrayBrush}">Transparent</TextBlock> - </Grid> - </DataTemplate> - </Setter.Value> - </Setter> - </DataTrigger> </Style.Triggers> </Style> </ContentControl.Style> @@ -380,7 +360,7 @@ </Canvas.Style> <TextBlock Canvas.Top="2" Foreground="{StaticResource TangoErrorBrush}" FontSize="{StaticResource TangoSmallFontSize}" Text="Color is out of gamut. Modify color or select an alternative."></TextBlock> </Canvas> - <DockPanel LastChildFill="False" Margin="0 20 0 0"> + <DockPanel LastChildFill="False" Margin="0 0 0 0"> <TextBlock VerticalAlignment="Bottom" DockPanel.Dock="Left" Text="Length (m):"></TextBlock> <touch:TouchNumericTextBox Width="180" DockPanel.Dock="Right" Value="{Binding Length}" StringFormat="0.0" AutoCalculateJogStep="False" HasDecimalPoint="True" Minimum="1" Maximum="100000" KeyboardContainer="{Binding ElementName=Container}" /> </DockPanel> @@ -507,8 +487,7 @@ <TextBlock FontWeight="Medium" Margin="20 0 0 0" VerticalAlignment="Center" FontSize="{StaticResource TangoExpanderHeaderFontSize}">Job Details</TextBlock> <TextBlock FontWeight="Medium" Margin="50 0 0 0" VerticalAlignment="Center"> - <Run Text="{Binding Job.Rml.Name}"></Run><Run>,</Run> - <Run Text="{Binding Job.ColorSpace.Name}"></Run> + <Run Text="{Binding Job.Rml.Name}"></Run> </TextBlock> </StackPanel> </touch:TouchExpander.Header> 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 1f2895f26..b3fcd1208 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Printing/DefaultPrintingManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Printing/DefaultPrintingManager.cs @@ -58,14 +58,23 @@ namespace Tango.PPC.UI.Printing #else try { + _notificationProvider.SetGlobalBusyMessage("Processing job..."); handler = await _machineProvider.MachineOperator.Print(job); + _notificationProvider.ReleaseGlobalBusyMessage(); } catch (InsufficientLiquidQuantityException ex) { + _notificationProvider.ReleaseGlobalBusyMessage(); LogManager.Log(ex); await _notificationProvider.ShowDialog(new InsufficientLiquidQuantityViewVM(ex)); throw ex; } + catch (Exception ex) + { + _notificationProvider.ReleaseGlobalBusyMessage(); + LogManager.Log(ex); + throw ex; + } #endif handler.Completed += async (x, e) => diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest b/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest index d72e75011..efc5f8179 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest @@ -16,7 +16,7 @@ Remove this element if your application requires this virtualization for backwards compatibility. --> - <requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> + <!--<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />--> </requestedPrivileges> </security> </trustInfo> diff --git a/Software/Visual_Studio/Tango.BL/Builders/CatalogsCollectionBuilder.cs b/Software/Visual_Studio/Tango.BL/Builders/CatalogsCollectionBuilder.cs index fb690eb99..dd9e9a54c 100644 --- a/Software/Visual_Studio/Tango.BL/Builders/CatalogsCollectionBuilder.cs +++ b/Software/Visual_Studio/Tango.BL/Builders/CatalogsCollectionBuilder.cs @@ -37,5 +37,36 @@ namespace Tango.BL.Builders } }); } + + public virtual CatalogsCollectionBuilder WithGroups() + { + return AddQueryStep(2, (query) => + { + return query.Include(x => x.ColorCatalogsGroups); + }); + } + + public virtual CatalogsCollectionBuilder WithItems() + { + return AddQueryStep(3, (query) => + { + return query.Include(x => x.ColorCatalogsGroups.Select(y => y.ColorCatalogsItems)); + }); + } + + public virtual CatalogsCollectionBuilder WithRecipes(Rml rml = null) + { + return AddQueryStep(4, (query) => + { + if (rml != null) + { + return query.Include(x => x.ColorCatalogsGroups.Select(y => y.ColorCatalogsItems.Select(z => z.ColorCatalogsItemsRecipes.Where(r => r.RmlGuid == rml.Guid)))); + } + else + { + return query.Include(x => x.ColorCatalogsGroups.Select(y => y.ColorCatalogsItems.Select(z => z.ColorCatalogsItemsRecipes))); + } + }); + } } } diff --git a/Software/Visual_Studio/Tango.BL/Entities/BrushStop.cs b/Software/Visual_Studio/Tango.BL/Entities/BrushStop.cs index 4ad21d4cd..9f47aca05 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/BrushStop.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/BrushStop.cs @@ -164,7 +164,24 @@ namespace Tango.BL.Entities [JsonIgnore] public Color Color { - get { return Color.FromRgb((byte)_red, (byte)_green, (byte)_blue); } + get + { + if (ColorSpace != null && BrushColorSpace == ColorSpaces.Catalog) + { + if (ColorCatalogsItem != null) + { + return Color.FromRgb((byte)ColorCatalogsItem.Red, (byte)ColorCatalogsItem.Green, (byte)ColorCatalogsItem.Blue); + } + else + { + return Colors.White; + } + } + else + { + return Color.FromRgb((byte)_red, (byte)_green, (byte)_blue); + } + } set { Rgb rgb = new Rgb(value.R, value.G, value.B); @@ -555,12 +572,6 @@ namespace Tango.BL.Entities Rgb rgb = new Rgb(Red, Green, Blue); Cmyk cmyk = new Cmyk(Cyan, Magenta, Yellow, Black); Lab lab = new Lab(L, A, B); - Rgb rgb_catalog = new Rgb(255, 255, 255); - - if (ColorCatalogsItem != null) - { - rgb_catalog = new Rgb(ColorCatalogsItem.Red, ColorCatalogsItem.Green, ColorCatalogsItem.Blue); - } switch ((ColorSpaces)ColorSpace.Code) { @@ -577,9 +588,35 @@ namespace Tango.BL.Entities cmyk = lab.To<Cmyk>(); break; case ColorSpaces.Catalog: - cmyk = rgb_catalog.To<Cmyk>(); - lab = rgb_catalog.To<Lab>(); - rgb = rgb_catalog; + + if (ColorCatalogsItem != null) + { + rgb = new Rgb(ColorCatalogsItem.Red, ColorCatalogsItem.Green, ColorCatalogsItem.Blue); + lab = new Lab(ColorCatalogsItem.L, ColorCatalogsItem.A, ColorCatalogsItem.B); + cmyk = new Cmyk(ColorCatalogsItem.Cyan, ColorCatalogsItem.Magenta, ColorCatalogsItem.Yellow, ColorCatalogsItem.Black); + + try + { + if (LiquidVolumes != null) + { + var cyan = LiquidVolumes.FirstOrDefault(x => x.LiquidType == LiquidTypes.Cyan); + if (cyan != null) cyan.Volume = ColorCatalogsItem.Cyan; + + var magenta = LiquidVolumes.FirstOrDefault(x => x.LiquidType == LiquidTypes.Magenta); + if (magenta != null) magenta.Volume = ColorCatalogsItem.Magenta; + + var yellow = LiquidVolumes.FirstOrDefault(x => x.LiquidType == LiquidTypes.Yellow); + if (yellow != null) yellow.Volume = ColorCatalogsItem.Yellow; + + var black = LiquidVolumes.FirstOrDefault(x => x.LiquidType == LiquidTypes.Black); + if (black != null) black.Volume = ColorCatalogsItem.Black; + } + } + catch (Exception ex) + { + Debug.WriteLine(ex); + } + } Validate(null); break; } @@ -722,6 +759,12 @@ namespace Tango.BL.Entities Corrected = false; IsOutOfGamut = false; } + + _ignorePropChanged = true; + RaisePropertyChanged(nameof(Color)); + RaisePropertyChanged(nameof(Brush)); + Segment?.RaiseSegmentBrushChanged(); + _ignorePropChanged = false; } #endregion @@ -770,10 +813,10 @@ namespace Tango.BL.Entities { base.OnValidating(context); - if (BrushColorSpace == ColorSpaces.Catalog && ColorCatalogsItem == null) - { - InsertError(nameof(ColorCatalogsItem), "Please specify a color code."); - } + //if (BrushColorSpace == ColorSpaces.Catalog && ColorCatalogsItem == null) + //{ + // InsertError(nameof(ColorCatalogsItem), "Please specify a color code."); + //} } #endregion diff --git a/Software/Visual_Studio/Tango.BL/Entities/ColorCatalog.cs b/Software/Visual_Studio/Tango.BL/Entities/ColorCatalog.cs index 82b88f156..9972a0c2d 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/ColorCatalog.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/ColorCatalog.cs @@ -34,5 +34,25 @@ namespace Tango.BL.Entities { get { return ColorCatalogsGroups.OrderBy(x => x.GroupIndex).ToObservableCollection(); } } + + [JsonIgnore] + [NotMapped] + public List<ColorCatalogsItem> AllItemsOrdered + { + get { return ColorCatalogsGroupsOrdered.SelectMany(x => x.ColorCatalogsItemsOrdered).ToList(); } + } + + public ColorCatalogsItem GetClosestItem(Color color) + { + var minDiff = AllItemsOrdered.Select(x => x.Color).Select(n => ColorDiff(n, color)).Min(n => n); + return AllItemsOrdered.FirstOrDefault(n => ColorDiff(n.Color, color) == minDiff); + } + + private int ColorDiff(Color c1, Color c2) + { + return (int)Math.Sqrt((c1.R - c2.R) * (c1.R - c2.R) + + (c1.G - c2.G) * (c1.G - c2.G) + + (c1.B - c2.B) * (c1.B - c2.B)); + } } } diff --git a/Software/Visual_Studio/Tango.BL/Entities/ColorCatalogsGroup.cs b/Software/Visual_Studio/Tango.BL/Entities/ColorCatalogsGroup.cs index 17f6115d1..86d82c634 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/ColorCatalogsGroup.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/ColorCatalogsGroup.cs @@ -1,6 +1,7 @@ using Newtonsoft.Json; using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.ComponentModel.DataAnnotations.Schema; using System.Linq; using System.Text; @@ -31,6 +32,13 @@ namespace Tango.BL.Entities } } + [JsonIgnore] + [NotMapped] + public ObservableCollection<ColorCatalogsItem> ColorCatalogsItemsOrdered + { + get { return ColorCatalogsItems.OrderBy(x => x.ItemIndex).ToObservableCollection(); } + } + public override void Delete(ObservablesContext context) { base.Delete(context); diff --git a/Software/Visual_Studio/Tango.BL/ExtensionMethods/ColorCatalogItemsExtensions.cs b/Software/Visual_Studio/Tango.BL/ExtensionMethods/ColorCatalogItemsExtensions.cs new file mode 100644 index 000000000..2a548371e --- /dev/null +++ b/Software/Visual_Studio/Tango.BL/ExtensionMethods/ColorCatalogItemsExtensions.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Media; +using Tango.BL.Entities; + +public static class ColorCatalogItemsExtensions +{ + public static ColorCatalogsItem GetClosestItem(this IEnumerable<ColorCatalogsItem> items, Color color) + { + var minDiff = items.Select(x => x.Color).Select(n => ColorDiff(n, color)).Min(n => n); + return items.FirstOrDefault(n => ColorDiff(n.Color, color) == minDiff); + } + + private static int ColorDiff(Color c1, Color c2) + { + return (int)Math.Sqrt((c1.R - c2.R) * (c1.R - c2.R) + + (c1.G - c2.G) * (c1.G - c2.G) + + (c1.B - c2.B) * (c1.B - c2.B)); + } +} diff --git a/Software/Visual_Studio/Tango.BL/Tango.BL.csproj b/Software/Visual_Studio/Tango.BL/Tango.BL.csproj index dc817af6e..0fbf6c5ab 100644 --- a/Software/Visual_Studio/Tango.BL/Tango.BL.csproj +++ b/Software/Visual_Studio/Tango.BL/Tango.BL.csproj @@ -427,6 +427,7 @@ <Compile Include="Enumerations\PublishedProcedureProjectVisibilities.cs" /> <Compile Include="Enumerations\TangoUpdateStatuses.cs" /> <Compile Include="Enumerations\RmlQualifications.cs" /> + <Compile Include="ExtensionMethods\ColorCatalogItemsExtensions.cs" /> <Compile Include="IObservableEntityDTO.cs" /> <Compile Include="ObservableDTOPropertyAttribute.cs" /> <Compile Include="ObservableEntityDTO.cs" /> @@ -645,7 +646,7 @@ </Target> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" /> + <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" /> </VisualStudio> </ProjectExtensions> </Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs index bce386bfe..ada7a4b73 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs @@ -2408,150 +2408,153 @@ namespace Tango.Integration.Operation /// </summary> /// <param name="job">The job.</param> /// <returns></returns> - public Task<JobHandler> Print(Job job) + public async Task<JobHandler> Print(Job job) { - IColorConverter converter = new DefaultColorConverter(); - - var jobSegments = job.OrderedSegments; + ProcessParametersTable processParameters = null; - if (job.Rml == null) + await Task.Factory.StartNew(() => { - throw new NullReferenceException("Job RML is null"); - } + IColorConverter converter = new DefaultColorConverter(); - var processGroup = job.Rml.ProcessParametersTablesGroups.FirstOrDefault(x => x.Active); + var jobSegments = job.OrderedSegments; - if (processGroup == null) - { - throw new NullReferenceException("Could not locate an active process parameters tables group for RML " + job.Rml.Name); - } + if (job.Rml == null) + { + throw new NullReferenceException("Job RML is null"); + } - ProcessParametersTable processParameters = null; + var processGroup = job.Rml.ProcessParametersTablesGroups.FirstOrDefault(x => x.Active); - try - { - processParameters = converter.GetRecommendedProcessParameters(job); - } - catch (Exception ex) - { - throw LogManager.Log(new InvalidOperationException($"An error occurred while trying to resolve the recommended process parameters.\n{ex.Message}")); - } + if (processGroup == null) + { + throw new NullReferenceException("Could not locate an active process parameters tables group for RML " + job.Rml.Name); + } - if (processParameters == null) - { - throw new NullReferenceException("Could not locate any process parameters table in group " + processGroup.Name + " for RML " + job.Rml.Name); - } + try + { + processParameters = converter.GetRecommendedProcessParameters(job); + } + catch (Exception ex) + { + throw LogManager.Log(new InvalidOperationException($"An error occurred while trying to resolve the recommended process parameters.\n{ex.Message}")); + } - //Perform color correction - foreach (var stop in jobSegments.SelectMany(x => x.BrushStops)) - { - //if (stop.LiquidVolumes == null || stop.BrushColorSpace == ColorSpaces.Volume) - //{ - if (stop.BrushColorSpace == ColorSpaces.RGB || stop.BrushColorSpace == ColorSpaces.LAB) + if (processParameters == null) { - var output = converter.Convert(stop, false); + throw new NullReferenceException("Could not locate any process parameters table in group " + processGroup.Name + " for RML " + job.Rml.Name); + } - //TODO: Restore this when Mirta conversion is working as expected. - //if (suggestions.OutOfGamut) + //Perform color correction + foreach (var stop in jobSegments.SelectMany(x => x.BrushStops)) + { + //if (stop.LiquidVolumes == null || stop.BrushColorSpace == ColorSpaces.Volume) //{ - // throw new InvalidOperationException("Cannot print a brush stop which is out of gamut."); - //} - - stop.SetLiquidVolumes(job.Machine.Configuration, job.Rml, processParameters); - - foreach (var outputLiquid in output.SingleCoordinates.OutputLiquids) + if (stop.BrushColorSpace == ColorSpaces.RGB || stop.BrushColorSpace == ColorSpaces.LAB) { - var liquidVolume = stop.LiquidVolumes.SingleOrDefault(x => x.IdsPack.LiquidType.Code == outputLiquid.LiquidType.ToInt32()); + var output = converter.Convert(stop, false); - if (liquidVolume == null) - { - throw new NullReferenceException("Liquid volume not found for color conversion output liquid '" + outputLiquid.LiquidType + "'."); - } + //TODO: Restore this when Mirta conversion is working as expected. + //if (suggestions.OutOfGamut) + //{ + // throw new InvalidOperationException("Cannot print a brush stop which is out of gamut."); + //} - liquidVolume.Volume = outputLiquid.Volume; - } - } - else if (stop.BrushColorSpace == ColorSpaces.Catalog) - { - if (stop.ColorCatalogsItem != null) - { stop.SetLiquidVolumes(job.Machine.Configuration, job.Rml, processParameters); + foreach (var outputLiquid in output.SingleCoordinates.OutputLiquids) { - var liquidVolume = stop.LiquidVolumes.SingleOrDefault(x => x.LiquidType == LiquidTypes.Cyan); + var liquidVolume = stop.LiquidVolumes.SingleOrDefault(x => x.IdsPack.LiquidType.Code == outputLiquid.LiquidType.ToInt32()); if (liquidVolume == null) { - throw new NullReferenceException("Liquid volume not found for color conversion output liquid '" + LiquidTypes.Cyan + "'."); + throw new NullReferenceException("Liquid volume not found for color conversion output liquid '" + outputLiquid.LiquidType + "'."); } - liquidVolume.Volume = stop.ColorCatalogsItem.Cyan; + liquidVolume.Volume = outputLiquid.Volume; } - + } + else if (stop.BrushColorSpace == ColorSpaces.Catalog) + { + if (stop.ColorCatalogsItem != null) { - var liquidVolume = stop.LiquidVolumes.SingleOrDefault(x => x.LiquidType == LiquidTypes.Magenta); + stop.SetLiquidVolumes(job.Machine.Configuration, job.Rml, processParameters); - if (liquidVolume == null) { - throw new NullReferenceException("Liquid volume not found for color conversion output liquid '" + LiquidTypes.Magenta + "'."); - } + var liquidVolume = stop.LiquidVolumes.SingleOrDefault(x => x.LiquidType == LiquidTypes.Cyan); - liquidVolume.Volume = stop.ColorCatalogsItem.Magenta; - } + if (liquidVolume == null) + { + throw new NullReferenceException("Liquid volume not found for color conversion output liquid '" + LiquidTypes.Cyan + "'."); + } - { - var liquidVolume = stop.LiquidVolumes.SingleOrDefault(x => x.LiquidType == LiquidTypes.Yellow); + liquidVolume.Volume = stop.ColorCatalogsItem.Cyan; + } - if (liquidVolume == null) { - throw new NullReferenceException("Liquid volume not found for color conversion output liquid '" + LiquidTypes.Yellow + "'."); - } + var liquidVolume = stop.LiquidVolumes.SingleOrDefault(x => x.LiquidType == LiquidTypes.Magenta); - liquidVolume.Volume = stop.ColorCatalogsItem.Yellow; - } + if (liquidVolume == null) + { + throw new NullReferenceException("Liquid volume not found for color conversion output liquid '" + LiquidTypes.Magenta + "'."); + } - { - var liquidVolume = stop.LiquidVolumes.SingleOrDefault(x => x.LiquidType == LiquidTypes.Black); + liquidVolume.Volume = stop.ColorCatalogsItem.Magenta; + } - if (liquidVolume == null) { - throw new NullReferenceException("Liquid volume not found for color conversion output liquid '" + LiquidTypes.Black + "'."); + var liquidVolume = stop.LiquidVolumes.SingleOrDefault(x => x.LiquidType == LiquidTypes.Yellow); + + if (liquidVolume == null) + { + throw new NullReferenceException("Liquid volume not found for color conversion output liquid '" + LiquidTypes.Yellow + "'."); + } + + liquidVolume.Volume = stop.ColorCatalogsItem.Yellow; } - liquidVolume.Volume = stop.ColorCatalogsItem.Black; + { + var liquidVolume = stop.LiquidVolumes.SingleOrDefault(x => x.LiquidType == LiquidTypes.Black); + + if (liquidVolume == null) + { + throw new NullReferenceException("Liquid volume not found for color conversion output liquid '" + LiquidTypes.Black + "'."); + } + + liquidVolume.Volume = stop.ColorCatalogsItem.Black; + } + } + else if (!stop.IsTransparent) + { + throw new InvalidOperationException($"No catalog item specified for segment color."); + } + else + { + stop.SetLiquidVolumes(job.Machine.Configuration, job.Rml, processParameters); } } - else if (!stop.IsTransparent) + else if (stop.BrushColorSpace == ColorSpaces.Volume) { - throw new InvalidOperationException($"No catalog item specified for segment color."); + stop.SetLiquidVolumes(job.Machine.Configuration, job.Rml, processParameters); } else { - stop.SetLiquidVolumes(job.Machine.Configuration, job.Rml, processParameters); + throw new InvalidOperationException($"Unsupported color space {stop.BrushColorSpace}."); } - } - else if (stop.BrushColorSpace == ColorSpaces.Volume) - { - stop.SetLiquidVolumes(job.Machine.Configuration, job.Rml, processParameters); - } - else - { - throw new InvalidOperationException($"Unsupported color space {stop.BrushColorSpace}."); - } - //} - - if (job.EnableLubrication) - { - var lubricantVolume = stop.LiquidVolumes.SingleOrDefault(x => x.IdsPack != null && x.IdsPack.LiquidType != null && x.LiquidType == LiquidTypes.Lubricant); + //} - if (lubricantVolume != null) + if (job.EnableLubrication) { - lubricantVolume.Volume = 100; + var lubricantVolume = stop.LiquidVolumes.SingleOrDefault(x => x.IdsPack != null && x.IdsPack.LiquidType != null && x.LiquidType == LiquidTypes.Lubricant); + + if (lubricantVolume != null) + { + lubricantVolume.Volume = 100; + } } } - } + }); - return Print(job, processParameters); + return await Print(job, processParameters); } /// <summary> diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchAutoComplete.xaml b/Software/Visual_Studio/Tango.Touch/Controls/TouchAutoComplete.xaml index da8580488..b0b78c177 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchAutoComplete.xaml +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchAutoComplete.xaml @@ -138,7 +138,7 @@ </Style.Triggers> </Style> </Canvas.Style> - <TextBlock FontWeight="Bold" FontSize="11" Foreground="{StaticResource TangoPrimaryAccentBrush}" Canvas.Top="{Binding RelativeSource={RelativeSource Self},Path=ActualHeight,Converter={StaticResource MathOperatorConverter},ConverterParameter='*-1'}" Text="{Binding RelativeSource={RelativeSource AncestorType=local:TouchAutoComplete},Path=Watermark}"> + <TextBlock FontWeight="Bold" FontSize="11" Foreground="{StaticResource TangoPrimaryAccentBrush}" Canvas.Top="{Binding RelativeSource={RelativeSource Self},Path=ActualHeight,Converter={StaticResource MathOperatorConverter},ConverterParameter='*-1'}" Text=""> <TextBlock.Style> <Style TargetType="TextBlock"> <Setter Property="Opacity" Value="0"></Setter> diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs index 2a0caf13e..da5d5e34b 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs @@ -109,6 +109,16 @@ namespace Tango.Touch.Controls public static readonly DependencyProperty AutoCalculateJogStepProperty = DependencyProperty.Register("AutoCalculateJogStep", typeof(bool), typeof(TouchNumericTextBox), new PropertyMetadata(true)); + public bool UpdateBindingOnlyWhenFocused + { + get { return (bool)GetValue(UpdateBindingOnlyWhenFocusedProperty); } + set { SetValue(UpdateBindingOnlyWhenFocusedProperty, value); } + } + public static readonly DependencyProperty UpdateBindingOnlyWhenFocusedProperty = + DependencyProperty.Register("UpdateBindingOnlyWhenFocused", typeof(bool), typeof(TouchNumericTextBox), new PropertyMetadata(false)); + + + public override void OnApplyTemplate() { base.OnApplyTemplate(); @@ -222,8 +232,11 @@ namespace Tango.Touch.Controls _lastValue = Value; - DoubleValueChangedEventArgs args = new DoubleValueChangedEventArgs(ValueChangedEvent, this, Value); - RaiseEvent(args); + if (!UpdateBindingOnlyWhenFocused || (_text_box != null && _text_box.IsKeyboardFocused)) + { + DoubleValueChangedEventArgs args = new DoubleValueChangedEventArgs(ValueChangedEvent, this, Value); + RaiseEvent(args); + } } } |
