diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-11-12 13:17:41 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-11-12 13:17:41 +0200 |
| commit | a98e30ab93fd4717bbe49c0b2cb6dff4bc65a67c (patch) | |
| tree | 5b50d3ff60da99eedc1aad14af8e526539ed2c15 /Software/Visual_Studio/Tango.BL | |
| parent | 739fd56662cdee59f42ec8d80654babf158b9f51 (diff) | |
| download | Tango-a98e30ab93fd4717bbe49c0b2cb6dff4bc65a67c.tar.gz Tango-a98e30ab93fd4717bbe49c0b2cb6dff4bc65a67c.zip | |
Working on PPC color catalog.
Diffstat (limited to 'Software/Visual_Studio/Tango.BL')
5 files changed, 68 insertions, 10 deletions
diff --git a/Software/Visual_Studio/Tango.BL/Builders/JobBuilder.cs b/Software/Visual_Studio/Tango.BL/Builders/JobBuilder.cs index c70688819..a0a88f4a7 100644 --- a/Software/Visual_Studio/Tango.BL/Builders/JobBuilder.cs +++ b/Software/Visual_Studio/Tango.BL/Builders/JobBuilder.cs @@ -40,7 +40,7 @@ namespace Tango.BL.Builders { foreach (var segment in Entity.Segments.ToList()) { - Context.BrushStops.Where(x => x.SegmentGuid == segment.Guid).Include(x => x.ColorSpace).OrderBy(x => x.StopIndex).ToList(); + Context.BrushStops.Where(x => x.SegmentGuid == segment.Guid).Include(x => x.ColorSpace).Include(x => x.ColorCatalog).OrderBy(x => x.StopIndex).ToList(); } }); } diff --git a/Software/Visual_Studio/Tango.BL/EntitiesExtensions/BrushStop.cs b/Software/Visual_Studio/Tango.BL/EntitiesExtensions/BrushStop.cs index 73d987468..82f9dc106 100644 --- a/Software/Visual_Studio/Tango.BL/EntitiesExtensions/BrushStop.cs +++ b/Software/Visual_Studio/Tango.BL/EntitiesExtensions/BrushStop.cs @@ -50,6 +50,7 @@ namespace Tango.BL.Entities _colorPropertyNames.Add(nameof(Black)); _colorPropertyNames.Add(nameof(Color)); + _colorPropertyNames.Add(nameof(ColorCatalog)); } #region Properties @@ -350,7 +351,7 @@ namespace Tango.BL.Entities /// Raises the property changed event. /// </summary> /// <param name="propName">Name of the property.</param> - protected override void RaisePropertyChanged(string propName) + protected override async void RaisePropertyChanged(string propName) { base.RaisePropertyChanged(propName); @@ -358,7 +359,7 @@ namespace Tango.BL.Entities { if (_colorPropertyNames.Contains(propName)) { - SynchronizeColorSpaces(); + await SynchronizeColorSpaces(); _ignorePropChanged = true; @@ -412,13 +413,19 @@ namespace Tango.BL.Entities /// <summary> /// Synchronizes between the different brush stop color spaces. /// </summary> - private void SynchronizeColorSpaces() + private Task SynchronizeColorSpaces() { - Task.Factory.StartNew(() => + return Task.Factory.StartNew(() => { Rgb rgb = new Rgb(Red, Green, Blue); Cmyk cmyk = new Cmyk(Cyan, Magenta, Yellow, Black); Lab lab = new Lab(L, A, B); + Rgb rgb_twine = new Rgb(0, 0, 0); + + if (ColorCatalog != null) + { + rgb_twine = new Rgb(ColorCatalog.Red, ColorCatalog.Green, ColorCatalog.Blue); + } switch ((ColorSpaces)ColorSpace.Code) { @@ -434,6 +441,12 @@ namespace Tango.BL.Entities rgb = lab.To<Rgb>(); cmyk = lab.To<Cmyk>(); break; + case ColorSpaces.Twine: + cmyk = rgb_twine.To<Cmyk>(); + lab = rgb_twine.To<Lab>(); + rgb = rgb_twine; + Validate(null); + break; } _red = (int)rgb.R; @@ -448,12 +461,19 @@ namespace Tango.BL.Entities _l = lab.L; _a = lab.A; _b = lab.B; - - //TODO: Remove this.. - //IsOutOfGamut = _red > 250; }); } + protected override void OnValidating(ObservablesContext context) + { + base.OnValidating(context); + + if (ColorSpace.Code == ColorSpaces.Twine.ToInt32() && ColorCatalog == null) + { + InsertError(nameof(ColorCatalog), "Please specify a color code."); + } + } + #endregion } } diff --git a/Software/Visual_Studio/Tango.BL/EntitiesExtensions/ColorCatalog.cs b/Software/Visual_Studio/Tango.BL/EntitiesExtensions/ColorCatalog.cs new file mode 100644 index 000000000..fe79c3362 --- /dev/null +++ b/Software/Visual_Studio/Tango.BL/EntitiesExtensions/ColorCatalog.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Media; + +namespace Tango.BL.Entities +{ + public partial class ColorCatalog + { + private Color _color; + /// <summary> + /// Gets the color. + /// </summary> + public Color Color + { + get { return _color; } + private set { _color = value; RaisePropertyChangedAuto(); } + } + + protected override void RaisePropertyChanged(string propName) + { + base.RaisePropertyChanged(propName); + + if (propName == nameof(Red) || propName == nameof(Green) || propName == nameof(Blue)) + { + Color = Color.FromRgb((byte)Red, (byte)Green, (byte)Blue); + } + } + } +} diff --git a/Software/Visual_Studio/Tango.BL/ObservablesStaticCollections.cs b/Software/Visual_Studio/Tango.BL/ObservablesStaticCollections.cs index 2847c508e..9ff695567 100644 --- a/Software/Visual_Studio/Tango.BL/ObservablesStaticCollections.cs +++ b/Software/Visual_Studio/Tango.BL/ObservablesStaticCollections.cs @@ -33,6 +33,11 @@ namespace Tango.BL } } + public ObservablesContext Context + { + get { return db; } + } + /// <summary> /// Initializes this instance. /// </summary> @@ -87,7 +92,6 @@ namespace Tango.BL MachineVersions = db.MachineVersions.ToObservableCollection(); - //Load later... Task.Factory.StartNew(() => { @@ -96,6 +100,7 @@ namespace Tango.BL MidTankTypes = db.MidTankTypes.ToObservableCollection(); CartridgeTypes = db.CartridgeTypes.ToObservableCollection(); IdsPackFormulas = db.IdsPackFormulas.ToObservableCollection(); + ColorCatalogs = db.ColorCatalogs.ToObservableCollection(); Rmls = db.Rmls.ToObservableCollection(); diff --git a/Software/Visual_Studio/Tango.BL/Tango.BL.csproj b/Software/Visual_Studio/Tango.BL/Tango.BL.csproj index 736a96e24..cf95ea9bc 100644 --- a/Software/Visual_Studio/Tango.BL/Tango.BL.csproj +++ b/Software/Visual_Studio/Tango.BL/Tango.BL.csproj @@ -110,6 +110,7 @@ <Compile Include="Dispensing\LubricantDispensingCalc.cs" /> <Compile Include="Dispensing\StandardColorDispensingCalc.cs" /> <Compile Include="Dispensing\TransparentLiquidDispensingCalc.cs" /> + <Compile Include="EntitiesExtensions\ColorCatalog.cs" /> <Compile Include="EntitiesExtensions\Contact.cs" /> <Compile Include="EntitiesExtensions\LiquidType.cs" /> <Compile Include="EntitiesExtensions\LiquidTypesRml.cs" /> @@ -344,7 +345,7 @@ </Target> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" /> + <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" /> </VisualStudio> </ProjectExtensions> </Project>
\ No newline at end of file |
