aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2021-01-06 14:38:28 +0200
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2021-01-06 14:38:28 +0200
commitc3e9cd203d6f656e213d9b6b384cd489f7c099cc (patch)
tree46e68ce01ab0d9f4f09597cd392de341f39e80f8 /Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels
parent5d002c0fbd43b45fd81e4c0785d5d582b1eda06e (diff)
downloadTango-c3e9cd203d6f656e213d9b6b384cd489f7c099cc.tar.gz
Tango-c3e9cd203d6f656e213d9b6b384cd489f7c099cc.zip
Fixed issue with reset of catalog color.
Diffstat (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels')
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs42
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>