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/EntitiesExtensions | |
| parent | 739fd56662cdee59f42ec8d80654babf158b9f51 (diff) | |
| download | Tango-a98e30ab93fd4717bbe49c0b2cb6dff4bc65a67c.tar.gz Tango-a98e30ab93fd4717bbe49c0b2cb6dff4bc65a67c.zip | |
Working on PPC color catalog.
Diffstat (limited to 'Software/Visual_Studio/Tango.BL/EntitiesExtensions')
| -rw-r--r-- | Software/Visual_Studio/Tango.BL/EntitiesExtensions/BrushStop.cs | 34 | ||||
| -rw-r--r-- | Software/Visual_Studio/Tango.BL/EntitiesExtensions/ColorCatalog.cs | 32 |
2 files changed, 59 insertions, 7 deletions
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); + } + } + } +} |
