From 54d607cb361d40eccf2d31da2305423360cc4b09 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Sun, 9 Feb 2025 17:07:17 +0200 Subject: Critical fix on job rgb/lab cmyk & MyColors. --- .../Dialogs/ColorSelectionView.xaml | 2 +- .../Dialogs/ColorSelectionViewVM.cs | 13 ++- .../Tango.PPC.JobsV2/Models/BrushStopModel.cs | 20 +++-- .../Tango.PPC.JobsV2/Models/FavoriteColor.cs | 97 ++++++++++++++++++++-- .../Models/FavoriteColorLiquidVolume.cs | 15 ++++ .../Tango.PPC.JobsV2/Tango.PPC.JobsV2.csproj | 3 +- 6 files changed, 132 insertions(+), 18 deletions(-) create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/FavoriteColorLiquidVolume.cs (limited to 'Software/Visual_Studio/PPC/Modules') 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 68b0a839c..85d35cf4f 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 @@ -617,7 +617,7 @@ - x.IdsPack.LiquidType.AvailableForStandardUser)) + { + newcolor.SetVolume(liquidVolume.IdsPack.LiquidType.Type, liquidVolume.Volume); + } + //newcolor.Cyan = SelectedBrushStop.LiquidVolumes.GetLiquidVolume(LiquidTypes.Cyan).Volume; + //newcolor.Magenta = SelectedBrushStop.LiquidVolumes.GetLiquidVolume(LiquidTypes.Magenta).Volume; + //newcolor.Yellow = SelectedBrushStop.LiquidVolumes.GetLiquidVolume(LiquidTypes.Yellow).Volume; + //newcolor.Black = SelectedBrushStop.LiquidVolumes.GetLiquidVolume(LiquidTypes.Black).Volume; newcolor.L = SelectedBrushStop.L; newcolor.A = SelectedBrushStop.A; newcolor.B = SelectedBrushStop.B; 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 12911a6e2..5634f783e 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 @@ -928,11 +928,19 @@ namespace Tango.PPC.Jobs.Models PreventPropertyUpdate = true; - LiquidVolumes.ResetVolume(); - LiquidVolumes.GetLiquidVolume(LiquidTypes.Cyan).Volume = favoriteColor.Cyan; - LiquidVolumes.GetLiquidVolume(LiquidTypes.Magenta).Volume = favoriteColor.Magenta; - LiquidVolumes.GetLiquidVolume(LiquidTypes.Yellow).Volume = favoriteColor.Yellow; - LiquidVolumes.GetLiquidVolume(LiquidTypes.Black).Volume = favoriteColor.Black; + //LiquidVolumes.ResetVolume(); + + foreach (var liquidVolume in LiquidVolumes.Where(x => x.IdsPack.LiquidType.AvailableForStandardUser)) + { + liquidVolume.Volume = favoriteColor.GetVolume(liquidVolume.IdsPack.LiquidType.Type); + } + + RaisePropertyChanged(nameof(LiquidVolumes)); + + //LiquidVolumes.GetLiquidVolume(LiquidTypes.Cyan).Volume = favoriteColor.Cyan; + //LiquidVolumes.GetLiquidVolume(LiquidTypes.Magenta).Volume = favoriteColor.Magenta; + //LiquidVolumes.GetLiquidVolume(LiquidTypes.Yellow).Volume = favoriteColor.Yellow; + //LiquidVolumes.GetLiquidVolume(LiquidTypes.Black).Volume = favoriteColor.Black; Red = favoriteColor.Red; @@ -1376,7 +1384,7 @@ namespace Tango.PPC.Jobs.Models foreach (var outputLiquid in output.SingleCoordinates.OutputLiquids) { - LiquidVolumes.GetLiquidVolume(outputLiquid.LiquidType).SetVolumeSilent(outputLiquid.Volume); + LiquidVolumes.GetLiquidVolume(outputLiquid.LiquidType)?.SetVolumeSilent(outputLiquid.Volume); } IsOutOfGamut = false; diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/FavoriteColor.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/FavoriteColor.cs index 1d7b7c7c2..c72e7c530 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/FavoriteColor.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/FavoriteColor.cs @@ -70,6 +70,8 @@ namespace Tango.PPC.Jobs.Models public int BestMatchB { get; set; } + public List LiquidVolumes { get; set; } + [BsonIgnore] public Color Color { @@ -102,8 +104,11 @@ namespace Tango.PPC.Jobs.Models public bool IsSelected { get { return _isSelected; } - set { _isSelected = value; - RaisePropertyChangedAuto();} + set + { + _isSelected = value; + RaisePropertyChangedAuto(); + } } @@ -111,6 +116,7 @@ namespace Tango.PPC.Jobs.Models public FavoriteColor() { + LiquidVolumes = new List(); Hue = Saturation = 0; Brightness = 100; L = 100; @@ -125,14 +131,93 @@ namespace Tango.PPC.Jobs.Models public bool Equals(FavoriteColor color) { - if(color == null) + if (color == null) return false; - return (ColorSpace == color.ColorSpace - && Cyan == color.Cyan && Magenta == color.Magenta && Yellow == color.Yellow && Black ==color.Black + var step1 = (ColorSpace == color.ColorSpace && Red == color.Red && Green == color.Green && Blue == color.Blue - && L == color.L && A == color.A && B == color.B + && L == color.L && A == color.A && B == color.B && Hue == color.Hue && Saturation == color.Saturation && Brightness == color.Brightness); + + foreach (var liquidType in Enum.GetValues(typeof(LiquidTypes)).Cast()) + { + if (GetVolume(liquidType) != color.GetVolume(liquidType)) + { + return false; + } + } + + if (step1) return true; + return false; + } + + public double GetVolume(LiquidTypes liquidType) + { + if (liquidType == LiquidTypes.Cyan) + { + var liquidVolume = LiquidVolumes.FirstOrDefault(x => x.LiquidType == liquidType); + if (liquidVolume == null) + { + var newColor = new FavoriteColorLiquidVolume() { LiquidType = liquidType, Volume = Cyan }; + LiquidVolumes.Add(newColor); + return newColor.Volume; + } + } + else if (liquidType == LiquidTypes.Magenta) + { + var liquidVolume = LiquidVolumes.FirstOrDefault(x => x.LiquidType == liquidType); + if (liquidVolume == null) + { + var newColor = new FavoriteColorLiquidVolume() { LiquidType = liquidType, Volume = Magenta }; + LiquidVolumes.Add(newColor); + return newColor.Volume; + } + } + else if (liquidType == LiquidTypes.Yellow) + { + var liquidVolume = LiquidVolumes.FirstOrDefault(x => x.LiquidType == liquidType); + if (liquidVolume == null) + { + var newColor = new FavoriteColorLiquidVolume() { LiquidType = liquidType, Volume = Yellow }; + LiquidVolumes.Add(newColor); + return newColor.Volume; + } + } + else if (liquidType == LiquidTypes.Black) + { + var liquidVolume = LiquidVolumes.FirstOrDefault(x => x.LiquidType == liquidType); + if (liquidVolume == null) + { + var newColor = new FavoriteColorLiquidVolume() { LiquidType = liquidType, Volume = Black }; + LiquidVolumes.Add(newColor); + return newColor.Volume; + } + } + + { + var liquidVolume = LiquidVolumes.FirstOrDefault(x => x.LiquidType == liquidType); + if (liquidVolume != null) + { + return liquidVolume.Volume; + } + else + { + return 0; + } + } + } + + public void SetVolume(LiquidTypes liquidType, double volume) + { + var liquidVolume = LiquidVolumes.FirstOrDefault(x => x.LiquidType == liquidType); + if (liquidVolume != null) + { + liquidVolume.Volume = volume; + } + else + { + LiquidVolumes.Add(new FavoriteColorLiquidVolume() { LiquidType = liquidType, Volume = volume }); + } } } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/FavoriteColorLiquidVolume.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/FavoriteColorLiquidVolume.cs new file mode 100644 index 000000000..a296bcfc4 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/FavoriteColorLiquidVolume.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Enumerations; + +namespace Tango.PPC.Jobs.Models +{ + public class FavoriteColorLiquidVolume + { + public LiquidTypes LiquidType { get; set; } + public double Volume { get; set; } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Tango.PPC.JobsV2.csproj b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Tango.PPC.JobsV2.csproj index ca80b27a0..91f5a854d 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 @@ -320,6 +320,7 @@ + @@ -764,7 +765,7 @@ - + \ No newline at end of file -- cgit v1.3.1