private void UpdateColorShadeSelectorPosition(Color?color) { if ((_spectrumSlider == null) || (_colorShadingCanvas == null) || (color == null) || !color.HasValue) { return; } _currentColorPosition = null; HsvColor hsv = HsvColor.RGBToHSV(color); // HsvColor hsv = ColorUtilities.ConvertRgbToHsv(color.Value.R, color.Value.G, color.Value.B); if (!(color.Value.R == color.Value.G && color.Value.R == color.Value.B)) { _spectrumSlider.Value = 359 - hsv.Hue; } Point p = new Point(hsv.Saturation, 1 - hsv.Value); _currentColorPosition = p; _colorShadeSelectorTransform.X = (p.X * _colorShadingCanvas.Width) - 5; _colorShadeSelectorTransform.Y = (p.Y * _colorShadingCanvas.Height) - 5; }
/// <summary> /// Updates all color channels in all spaces (Opacity, RGB, HSV) /// from the given color parameter, or does nothing if the given /// color parameter 'Has No Value' or is null. /// </summary> /// <param name="color"></param> private void UpdateRGBValues(Color?color) { if ((color == null) || !color.HasValue) { return; } _surpressPropertyChanged = true; A = color.Value.A; R = color.Value.R; G = color.Value.G; B = color.Value.B; HsvColor hsv = HsvColor.RGBToHSV(color); H = hsv.Hue; S = hsv.Saturation; V = hsv.Value; _surpressPropertyChanged = false; }