ColourPicker

References
public sealed class ColourPicker : IResponsive
Represents the core functionality of the Grasshopper colour picker.

Constructors

ColourPicker

#
Create a new colour picker, centered on a specific colour using the most recent model and palette constraints.
public ColourPicker(
layout,
Ui layout.
Color
colour
Initial colour.
)

ColourPicker

#
Create a new colour picker, centered on a specific colour.
public ColourPicker(
layout,
Ui layout.
colour,
Initial colour.
space,
Space override.
palette,
Palette override.
discrete
Discrete mode override.
)

ColourPicker

#
Create a new colour picker, centered on a specific colour using the most recent model and palette constraints.
public ColourPicker(
layout,
Ui layout.
colour
Initial colour.
)

Fields

ButtonSize

#
Specifies the height of the Accept/Revert buttons.
public const int ButtonSize = 32

ButtonSpacing

#
The spacing between the sliders and the buttons.
public const int ButtonSpacing = 5

DiagramSize

#
Specifies the ideal width and height of the colour space diagram.
public const int DiagramSize = 300

LabelSize

#
Specifies the height of a textual label.
public const int LabelSize = 20

SamplerSize

#
Specifies the radius of the sampler button.
public const int SamplerSize = 24

SliderSize

#
Specifies the height of channel sliders.
public const int SliderSize = 22

ToolbarSize

#
Specifies the height of toolbars and buttons.
public const int ToolbarSize = 24

Properties

AcceptButton

#
Gets the region for the Accept button.
public RectangleF AcceptButton { get; }

AcceptButtonInfo

#
Gets or set the text for the accept button tooltip.
public string AcceptButtonInfo { get; set; }

AcceptButtonText

#
Gets or sets the text on the accept button.
public string AcceptButtonText { get; set; }

AvailableSpaces

#
Enumerate over all colour spaces available in this picker.
public IEnumerable<Space> AvailableSpaces { get; }

Bounds

#
Gets the bounding rectangle for all UI elements in the picker.
public RectangleF Bounds { get; }

Channel1

#
Gets the bounding rectangle for the first channel slider.
public RectangleF Channel1 { get; }

Channel2

#
Gets the bounding rectangle for the second channel slider.
public RectangleF Channel2 { get; }

Channel3

#
Gets the bounding rectangle for the third channel slider.
public RectangleF Channel3 { get; }

ChannelA

#
Gets the bounding rectangle for the alpha channel slider.
public RectangleF ChannelA { get; }

ChildResponsives

#
Sliders this picker hosts as standalone responsive children. The hosting control should register each of these as an IResponsive so the FlexControl dispatcher routes slider drags through their own Responsive instances instead of going through the picker.
public IEnumerable<IResponsive> ChildResponsives { get; }

ColourInfo

#
Gets the bounding rectangle of the colour code label.
public RectangleF ColourInfo { get; }

CurrentColour

#
Gets the currently selected colour within the current colour model. This does not take discretisation into account. You *probably* want to use the ImpliedColour property.
public Colour CurrentColour { get; }

Diagram

#
Gets the bounding rectangle of the colour space diagram.
public RectangleF Diagram { get; }

DisplayDiscrete

#
Gets or sets whether to limit the colours in the model space to the currently loaded palette.
public bool DisplayDiscrete { get; set; }

Format

#
Gets or sets the textual format in which colours are displayed. Caller is responsible for triggering a redraw of the control.
public ColourPickerFormat Format { get; set; }

Height

#
Gets the ideal height of this colour picker in the UI.
public int Height { get; }

ImpliedColour

#
Gets the currently implied colour, taking into account discretisation.
public Color ImpliedColour { get; }

IncludeContextuals

#
Gets whether the layout specifies the inclusion of the contextual icon colour model.
public bool IncludeContextuals { get; }

InitialColour

#
Gets the initial (original) colour this colour picker was constructed with.
public Colour InitialColour { get; }

Layout

#
Gets whether this picker includes UI for transparency.
public PickerLayout Layout { get; }

ModelName

#
Gets the bounding rectangle of the colour space name label.
public RectangleF ModelName { get; }

ModelToolbar

#
Gets the bounding rectangle of the toolbar containing all colour spaces.
public RectangleF ModelToolbar { get; }

MostRecentDiscrete

#
Gets or sets the most recently used discrete mode. This will be the default for any new colour picker.
public static bool MostRecentDiscrete { get; set; }

MostRecentFormat

#
Gets or sets the most recently selected colour format. This will be the default for any new colour picker.
public static ColourPickerFormat MostRecentFormat { get; set; }

MostRecentPalette

#
Gets or sets the most recently selected colour space. This will be the default for any new colour picker.
public static string MostRecentPalette { get; set; }

MostRecentSpace

#
Gets or sets the most recently selected colour space. This will be the default for any new colour picker.
public static Space MostRecentSpace { get; set; }

Palette

#
Gets the palette indicated buy the PaletteName property.
public NamedPalette Palette { get; }

PaletteName

#
Gets the name of the palette currently loaded in the picker.
public string PaletteName { get; }

Responder

#
public Responses Responder { get; }
Responder

RevertButton

#
Gets the region for the Revert button.
public RectangleF RevertButton { get; }

SamplerButton

#
Gets the region for the Screen Sampler button.
public RectangleF SamplerButton { get; }

Space

#
Gets the colour space currently on display.
public Space Space { get; }

Width

#
Gets the ideal width of this colour picker in the UI.
public int Width { get; }

Methods

ComputeBounds

#
Compute the bounds based on a specific layout.
public static Size ComputeBounds(
layout
Layout.
)
Dimensions of resulting picker.

Draw

#
Draw this colour picker to a graphics context.
public void Draw(
context,
Graphics context.
PointF
anchor
Anchor point (upper left corner of colour picker)
)

ModelButton

#
Resolve the bounds for the specific space button on the space toolbar.
public RectangleF ModelButton(
space
)

PerformLayout

#
Perform layout of the picker. This happens automatically within each Draw iteration, but you can call it specifically if you need to examine the boundaries prior to a draw operation.
public void PerformLayout(
PointF
anchor
Layout anchor for top left corner.
)

SpaceInstance

#
Gets the instance of the given space. Do not modify these instances unless you understand what consequences that might have to the validity of the picker state.
public IColourSpace SpaceInstance(
space
Space to retrieve.
)
Instance of space or null.

Events

ColourAccepted

#
Raised when the current colour is accepted.
public event EventHandler<EventArgs> ColourAccepted

DisplayExpired

#
Raised whenever the picker needs to be redrawn.
public event EventHandler<EventArgs> DisplayExpired

ImpliedColourChanged

#
Raised when the implied colour is changed.
public event EventHandler<BeforeAfterEventArgs<ColourPicker, Color>> ImpliedColourChanged

SpaceChanged

#
Raised when a different model is selected.

SpatialColourChanged

#
Raised when a new colour is picked.
public event EventHandler<BeforeAfterEventArgs<ColourPicker, Colour>> SpatialColourChanged