/// <summary> /// Update the color hue and saturation from the position of the color picker. /// </summary> private void UpdateColorPicker() { colorHSB.Hue = ((Canvas.GetLeft(ColorPickPointer) - Canvas.GetLeft(ColorMapImage)) / 255) * 360; colorHSB.Saturation = 1 - ((Canvas.GetTop(ColorPickPointer) - Canvas.GetTop(ColorMapImage)) / 255); UpdateGradient(ColorHSB.HSBtoRGB(colorHSB.Hue, colorHSB.Saturation, 1)); }
/// <summary> /// Load the pre-selected color into all controls. /// </summary> /// <param name="color">The color to load.</param> private void LoadColor(Color color) { colorHSB = ColorHSB.RGBtoHSB(color); Canvas.SetLeft(ColorPickPointer, Canvas.GetLeft(ColorMapImage) + (colorHSB.Hue / 360) * 256); Canvas.SetTop(ColorPickPointer, Canvas.GetTop(ColorMapImage) + (256 - colorHSB.Saturation * 256)); Canvas.SetTop(GradientPointer, Canvas.GetTop(GradientRectangle) + (256 - colorHSB.Brightness * 256)); ConstraintColorPickPointer(); ConstraintGradientPointer(); UpdateGradient(color); UpdateColor(); UpdateInfo(); }
/// <summary> /// Update the selected color to the preview box. /// </summary> private void UpdateColor() { selectedColor = ColorHSB.HSBtoRGB(colorHSB.Hue, colorHSB.Saturation, colorHSB.Brightness); ColorPreviewBox.Background = GetBrush(); }