aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs
diff options
context:
space:
mode:
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.cs169
1 files changed, 90 insertions, 79 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..cfac759dd 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) =>
{
@@ -445,6 +422,14 @@ namespace Tango.PPC.Jobs.ViewModels
if (_db != null)
{
+ if (Job != null)
+ {
+ foreach (var stop in Job.Segments.SelectMany(x => x.BrushStops).ToList())
+ {
+ stop.ColorSpaceChanged -= Stop_ColorSpaceChanged;
+ }
+ }
+
Rmls.ForEach(x => x.Cct = null);
Rmls = null;
_db.Dispose();
@@ -471,33 +456,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 +509,8 @@ namespace Tango.PPC.Jobs.ViewModels
ValidateBrushStops();
+ CoerceBrushStopsColorSpaceChange();
+
DyeCommand.RaiseCanExecuteChanged();
StartSampleDyeCommand.RaiseCanExecuteChanged();
StartFineTuningCommand.RaiseCanExecuteChanged();
@@ -718,7 +689,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 +710,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 +784,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 +814,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 +840,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 +976,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 +1038,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 +1309,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)
{