Table of Contents

Class ColorSwatch

Namespace
PluginUI
Assembly
PluginUI.dll

Color well: shows a color (checkerboard behind translucent colors); clicking opens a ColorPickerPopup and updates the color live.

public class ColorSwatch : Control
Inheritance
ColorSwatch
Inherited Members

Constructors

ColorSwatch()

Creates a swatch.

public ColorSwatch()

ColorSwatch(Color)

Creates a swatch showing color.

public ColorSwatch(Color color)

Parameters

color Color

Properties

AllowAlpha

Lets the picker edit the alpha channel.

public bool AllowAlpha { get; set; }

Property Value

bool

Color

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

IsEditable

Opens the picker on click (otherwise the swatch is display-only).

public bool IsEditable { get; set; }

Property Value

bool

ValueText

Text drawn in the value area (null = no value area).

public override string? ValueText { get; }

Property Value

string

Methods

OnDetached()

Called when the element leaves its host (unsubscribe here).

protected override void OnDetached()

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

OpenPicker()

Opens the color picker popup below the swatch.

public void OpenPicker()

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

Events

ColorChanged

Raised when the color changes (live while picking).

public event Action<ColorSwatch, Color>? ColorChanged

Event Type

Action<ColorSwatch, Color>

ColorCommitted

Raised when a picking session ends with a new color.

public event Action<ColorSwatch, Color>? ColorCommitted

Event Type

Action<ColorSwatch, Color>