diff options
| author | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2018-03-31 12:25:56 +0200 |
|---|---|---|
| committer | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2018-03-31 12:25:56 +0200 |
| commit | 135ced0e0a94ae759fba5fec7c0f35ec9be28231 (patch) | |
| tree | bf7704783131ed55d89ab1dd8183458584c10f03 /src | |
| parent | d7457dc87ec4a282ac58a5617f149164a1421a64 (diff) | |
convert hsv to integer in color pickerIFaceByParenting
Diffstat (limited to 'src')
| -rw-r--r-- | src/GraphicObjects/ColorPicker.cs | 28 | ||||
| -rw-r--r-- | src/GraphicObjects/GraphicObject.cs | 2 | ||||
| -rw-r--r-- | src/GraphicObjects/HueSelector.cs | 10 | ||||
| -rw-r--r-- | src/GraphicObjects/NumericControl.cs | 3 | ||||
| -rw-r--r-- | src/GraphicObjects/SaturationValueSelector.cs | 22 |
5 files changed, 30 insertions, 35 deletions
diff --git a/src/GraphicObjects/ColorPicker.cs b/src/GraphicObjects/ColorPicker.cs index cc955191..dd65e986 100644 --- a/src/GraphicObjects/ColorPicker.cs +++ b/src/GraphicObjects/ColorPicker.cs @@ -46,7 +46,6 @@ namespace Crow Color curColor; double h,s,v; - [XmlAttributeAttribute()] public virtual double R { get { return Math.Round(curColor.R * div); } set { @@ -58,7 +57,6 @@ namespace Crow notifyCurColorHasChanged (); } } - [XmlAttributeAttribute()] public virtual double G { get { return Math.Round(curColor.G * div); } set { @@ -70,7 +68,6 @@ namespace Crow hsvFromRGB (); } } - [XmlAttributeAttribute()] public virtual double B { get { return Math.Round(curColor.B * div); } set { @@ -82,7 +79,6 @@ namespace Crow hsvFromRGB (); } } - [XmlAttributeAttribute()] public virtual double A { get { return Math.Round(curColor.A * div); } set { @@ -94,41 +90,36 @@ namespace Crow hsvFromRGB (); } } - [XmlAttributeAttribute()] public virtual double H { - get { return Math.Round (h, 3); } + get { return Math.Round(h * div); } set { if (H == value) return; - h = value; + h = value * colDiv; NotifyValueChanged ("H", H); rgbFromHSV (); } } - [XmlAttributeAttribute()] public virtual double S { - get { return Math.Round (s, 2); } + get { return Math.Round(s * div); } set { - if (s == value) + if (S == value) return; - s = value; + s = value * colDiv; NotifyValueChanged ("S", S); rgbFromHSV (); } } - [XmlAttributeAttribute()] public virtual double V { - get { return Math.Round (v, 2); } + get { return Math.Round(v * div); } set { - if (v == value) + if (V == value) return; - v = value; + v = value * colDiv; NotifyValueChanged ("V", V); rgbFromHSV (); } } - - [XmlAttributeAttribute] public virtual Fill SelectedColor { get { return new SolidColor(curColor); } set { @@ -145,7 +136,6 @@ namespace Crow hsvFromRGB (); } } - [XmlAttributeAttribute] public virtual Color SelectedRawColor { get { return curColor; } set { @@ -219,7 +209,7 @@ namespace Crow notifyHSVHasChanged (); } void rgbFromHSV(){ - curColor = Color.FromHSV (h, v, s, curColor.A); + curColor = Color.FromHSV (h , v, s, curColor.A); notifyCurColorHasChanged (); notifyRGBAHasChanged (); } diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index cbcbe7cc..504af1f5 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -518,7 +518,7 @@ namespace Crow [DesignCategory ("Divers")] public virtual string Name { get { - return string.IsNullOrEmpty(name) ? design_id : name; + return string.IsNullOrEmpty(name) ? this.GetType().Name + design_id : name; } set { if (Name == value) diff --git a/src/GraphicObjects/HueSelector.cs b/src/GraphicObjects/HueSelector.cs index 67f4ec6e..6c104d01 100644 --- a/src/GraphicObjects/HueSelector.cs +++ b/src/GraphicObjects/HueSelector.cs @@ -43,6 +43,8 @@ namespace Crow Orientation _orientation; double hue; + const double div = 255.0; + const double colDiv = 1.0 / div; [XmlAttributeAttribute][DefaultValue(Orientation.Horizontal)] public virtual Orientation Orientation @@ -58,11 +60,11 @@ namespace Crow } [XmlAttributeAttribute()] public virtual double Hue { - get { return hue; } + get { return Math.Round(hue * div); } set { - if (hue == value) + if (Hue == value) return; - hue = value; + hue = value * colDiv; notifyHueChanged (); updateMousePosFromHue (); RegisterForRedraw (); @@ -147,7 +149,7 @@ namespace Crow mousePos.Y = (int)Math.Floor(hue * (double)ClientRectangle.Height); } void notifyHueChanged(){ - NotifyValueChanged ("Hue", hue); + NotifyValueChanged ("Hue", Hue); NotifyValueChanged ("HueColor", new SolidColor (Color.FromHSV (hue))); } } diff --git a/src/GraphicObjects/NumericControl.cs b/src/GraphicObjects/NumericControl.cs index f0eda90f..0c513067 100644 --- a/src/GraphicObjects/NumericControl.cs +++ b/src/GraphicObjects/NumericControl.cs @@ -129,7 +129,8 @@ namespace Crow else _actualValue = value; - _actualValue = Math.Round (_actualValue, _decimals); + if (_decimals >= 0) + _actualValue = Math.Round (_actualValue, _decimals); NotifyValueChanged("Value", _actualValue); RegisterForGraphicUpdate(); diff --git a/src/GraphicObjects/SaturationValueSelector.cs b/src/GraphicObjects/SaturationValueSelector.cs index 485a33d2..42958b42 100644 --- a/src/GraphicObjects/SaturationValueSelector.cs +++ b/src/GraphicObjects/SaturationValueSelector.cs @@ -38,16 +38,18 @@ namespace Crow { } + const double div = 255.0; + const double colDiv = 1.0 / div; double v, s; [XmlAttributeAttribute()] public virtual double V { - get { return v; } + get { return Math.Round(v * div); } set { - if (v == value) + if (S == value) return; - v = value; - NotifyValueChanged ("V", v); + v = value * colDiv; + NotifyValueChanged ("V", V); mousePos.Y = (int)Math.Floor((1.0-v) * (double)ClientRectangle.Height); RegisterForRedraw (); @@ -55,12 +57,12 @@ namespace Crow } [XmlAttributeAttribute()] public virtual double S { - get { return s; } + get { return Math.Round(s * div); } set { - if (s == value) + if (S == value) return; - s = value; - NotifyValueChanged ("S", s); + s = value * colDiv; + NotifyValueChanged ("S", S); mousePos.X = (int)Math.Floor(s * (double)ClientRectangle.Width); RegisterForRedraw (); @@ -121,8 +123,8 @@ namespace Crow Rectangle cb = ClientRectangle; s = (double)mousePos.X / (double)cb.Width; v = 1.0 - (double)mousePos.Y / (double)cb.Height; - NotifyValueChanged ("S", s); - NotifyValueChanged ("V", v); + NotifyValueChanged ("S", S); + NotifyValueChanged ("V", V); RegisterForRedraw (); } |