/// <summary> /// 当 <see cref="P:System.Windows.Controls.Primitives.RangeBase.Value" /> 属性更改时,更新 <see cref="T:System.Windows.Controls.Slider" /> 的当前位置。 /// </summary> /// <param name="oldValue"><see cref="T:System.Windows.Controls.Slider" /> 的旧 <see cref="P:System.Windows.Controls.Primitives.RangeBase.Value" />。</param> /// <param name="newValue"><see cref="T:System.Windows.Controls.Slider" /> 的新 <see cref="P:System.Windows.Controls.Primitives.RangeBase.Value" />。</param> protected override void OnValueChanged(double oldValue, double newValue) { base.OnValueChanged(oldValue, newValue); Color color = ColorUtilities.ConvertHsvToRgb(360 - newValue, 1, 1); SelectedColor = color; }
/// <summary> /// Generates a list of colors with hues ranging from 0 360 and a saturation and value of 1. /// </summary> /// <returns>List<Color>.</returns> public static List <Color> GenerateHsvSpectrum() { List <Color> colorsList = new List <Color>(8); for (int i = 0; i < 29; i++) { colorsList.Add(ColorUtilities.ConvertHsvToRgb(i * 12, 1, 1)); } colorsList.Add(ColorUtilities.ConvertHsvToRgb(0, 1, 1)); return(colorsList); }
/// <summary> /// Calculates the color. /// </summary> /// <param name="p">The p.</param> private void CalculateColor(Point p) { HsvColor hsv = new HsvColor(360 - _spectrumSlider.Value, 1, 1) { S = p.X, V = 1 - p.Y }; var currentColor = ColorUtilities.ConvertHsvToRgb(hsv.H, hsv.S, hsv.V); currentColor.A = A; SelectedColor = currentColor; SetHexadecimalStringProperty(GetFormatedColorString(SelectedColor), false); }