diff options
Diffstat (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs')
| -rw-r--r-- | Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs | 42 |
1 files changed, 37 insertions, 5 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 5cdf9d7a3..c61d52592 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 @@ -435,6 +435,7 @@ namespace Tango.PPC.Jobs.ViewModels foreach (var stop in Job.Segments.SelectMany(x => x.BrushStops).ToList()) { stop.ColorSpaceChanged -= Stop_ColorSpaceChanged; + stop.ColorCatalogChanged -= Stop_ColorCatalogChanged; } } @@ -519,7 +520,7 @@ namespace Tango.PPC.Jobs.ViewModels ValidateBrushStops(); - RegisterJobBrushStopsColorSpaceChange(); + RegisterJobBrushStopsEvents(); DyeCommand.RaiseCanExecuteChanged(); StartSampleDyeCommand.RaiseCanExecuteChanged(); @@ -709,7 +710,7 @@ namespace Tango.PPC.Jobs.ViewModels LogManager.Log("Adding new solid segment..."); var s = Job.AddSolidSegment(Settings.DefaultSegmentLength > 0 ? Settings.DefaultSegmentLength : 10); SetSegmentLiquidVolumes(s); - RegisterJobBrushStopsColorSpaceChange(); + RegisterJobBrushStopsEvents(); return s; } catch (Exception ex) @@ -730,7 +731,7 @@ namespace Tango.PPC.Jobs.ViewModels LogManager.Log("Adding new gradient segment..."); var s = Job.AddGradientSegment(Settings.DefaultSegmentLength > 0 ? Settings.DefaultSegmentLength : 10); SetSegmentLiquidVolumes(s); - RegisterJobBrushStopsColorSpaceChange(); + RegisterJobBrushStopsEvents(); return s; } catch (Exception ex) @@ -834,7 +835,7 @@ namespace Tango.PPC.Jobs.ViewModels #region Brush Stops Management - private void RegisterJobBrushStopsColorSpaceChange() + private void RegisterJobBrushStopsEvents() { if (Job != null) { @@ -842,6 +843,9 @@ namespace Tango.PPC.Jobs.ViewModels { stop.ColorSpaceChanged -= Stop_ColorSpaceChanged; stop.ColorSpaceChanged += Stop_ColorSpaceChanged; + + stop.ColorCatalogChanged -= Stop_ColorCatalogChanged; + stop.ColorCatalogChanged += Stop_ColorCatalogChanged; } } } @@ -854,6 +858,34 @@ namespace Tango.PPC.Jobs.ViewModels DyeCommand.RaiseCanExecuteChanged(); } + private void Stop_ColorCatalogChanged(object sender, ColorCatalog catalog) + { + BrushStop stop = sender as BrushStop; + + if (stop.ColorSpace != null && stop.BrushColorSpace == BL.Enumerations.ColorSpaces.Catalog) + { + if (stop.ColorCatalogsItem != null) + { + try + { + if (catalog != null && catalog.AllItemsOrdered.Count > 0) + { + stop.ColorCatalogsItem = catalog.GetClosestItem(stop.ColorCatalogsItem.Color); + } + else + { + stop.ColorCatalogsItem = null; + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error getting closest catalog color."); + stop.ColorCatalogsItem = null; + } + } + } + } + /// <summary> /// Adds a new brush stop to the specified segment. /// </summary> @@ -863,7 +895,7 @@ namespace Tango.PPC.Jobs.ViewModels LogManager.Log($"Adding new brush stop to segment {segment.SegmentIndex}."); segment.AddBrushStop(); SetSegmentLiquidVolumes(segment); - RegisterJobBrushStopsColorSpaceChange(); + RegisterJobBrushStopsEvents(); } /// <summary> |
