Table of Contents

Class ColorPicker

Namespace
PluginUI
Assembly
PluginUI.dll

HSV color picker: saturation/value square, hue strip, optional alpha strip, hex field, old/new preview and recently used colors. Usually shown in a ColorPickerPopup by a ColorSwatch.

public class ColorPicker : Control
Inheritance
ColorPicker
Inherited Members

Constructors

ColorPicker()

Creates a picker.

public ColorPicker()

ColorPicker(Color)

Creates a picker showing color.

public ColorPicker(Color color)

Parameters

color Color

Properties

Color

Selected color.

public Color Color { get; set; }

Property Value

Color

DefaultSize

Natural size used when no explicit size is given.

protected override Size DefaultSize { get; }

Property Value

Size

OriginalColor

Color shown as "before" in the preview (set when the picker opens).

public Color OriginalColor { get; set; }

Property Value

Color

RecentColors

Recently committed colors (shared by all pickers, most recent first).

public static IReadOnlyList<Color> RecentColors { get; }

Property Value

IReadOnlyList<Color>

ShowAlpha

Shows and edits the alpha channel.

public bool ShowAlpha { get; set; }

Property Value

bool

VisualChildren

Child elements in drawing order (back to front).

public override IReadOnlyList<UIElement> VisualChildren { get; }

Property Value

IReadOnlyList<UIElement>

Methods

AddRecentColor(Color)

Adds a color to RecentColors.

public static void AddRecentColor(Color color)

Parameters

color Color

ArrangeOverride(Rect)

Arranges children inside the final bounds.

protected override void ArrangeOverride(Rect bounds)

Parameters

bounds Rect

LayoutParts(VectorStyle, out Rect, out Rect, out Rect)

Splits the bounds into label (top), widget and value (bottom) areas according to the style. Override to change the arrangement (e.g. label on the left for sliders).

protected override void LayoutParts(VectorStyle style, out Rect label, out Rect widget, out Rect value)

Parameters

style VectorStyle
label Rect
widget Rect
value Rect

MeasureOverride(Size)

Natural size of the content for the available size (margins excluded).

protected override Size MeasureOverride(Size available)

Parameters

available Size

Returns

Size

OnCaptureLost()

The mouse capture was lost without a button release.

protected override void OnCaptureLost()

OnKeyDown(KeyEventArgs)

Key pressed while focused (bubbles to parents).

protected override void OnKeyDown(KeyEventArgs e)

Parameters

e KeyEventArgs

OnMouseDown(MouseEventArgs)

Mouse button pressed over the element (or captured).

protected override void OnMouseDown(MouseEventArgs e)

Parameters

e MouseEventArgs

OnMouseMove(MouseEventArgs)

Mouse moved over the element (or captured).

protected override void OnMouseMove(MouseEventArgs e)

Parameters

e MouseEventArgs

OnMouseUp(MouseEventArgs)

Mouse button released.

protected override void OnMouseUp(MouseEventArgs e)

Parameters

e MouseEventArgs

RenderVector(DrawingContext, Rect, VectorStyle)

Vector rendering of the widget area.

protected override void RenderVector(DrawingContext dc, Rect widget, VectorStyle style)

Parameters

dc DrawingContext
widget Rect
style VectorStyle

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

Events

ColorChanged

Raised while the user changes the color.

public event Action<ColorPicker, Color>? ColorChanged

Event Type

Action<ColorPicker, Color>