Skip to main content

VisColorPaletteDropDown

Namespace: PPJ.Runtime.Vis

Assembly: PPJ.Runtime.Vis.50 (5.0.0.0)

Displays a color palette in a non-editable combo-box drop-down.

public class VisColorPaletteDropDown : VisDropDownBase

Example:

using (var palette = new PPJ.Runtime.Vis.VisColorPaletteDropDown())
{
palette.Colors.Add(System.Drawing.Color.Red);
palette.SelectedColor = System.Drawing.Color.Red;
}

Constructors

Instance member VisColorPaletteDropDown()

Creates and hosts the palette, attaches selection handlers, and enables owner drawing.

Properties

Instance member Colors

IList: Gets the mutable palette color collection.

Instance member SelectedColor

Color: Gets or selects a color from the palette.

The setter selects the first equal color. A color absent from Colors resolves to -1 and can cause the SelectedIndex setter to throw. The getter requires a valid selected index.

Instance member SelectedIndex

Int32: Gets or sets the selected color index.

Changing the index refreshes the control and raises SelectedIndexChanged. Negative values and values greater than Count are rejected; Count itself is accepted even though it is not a valid color index.

Instance member Text

String: Gets an empty text value for the palette combo box.

Assignments are ignored; owner drawing displays the selected color.

Methods

Instance member AddMenu(szText, nID)

Appends a palette button and attempts to assign its caption and identifier.

ParameterTypeDescription
szTextSalStringThe requested caption.
nIDSalNumberThe requested command identifier.

Returns: SalNumber. The value returned by Buttons.Add if the subsequent assignments succeed.

Buttons.Add returns the new count, which this method uses as an index. The current implementation therefore accesses past the end after appending the button.

Instance member ClearMenu()

Removes palette buttons after the first button.

Returns: SalBoolean. True.

The button at index zero is retained.

Static member FromHandle(handle)

Resolves a palette drop-down from a native window handle.

ParameterTypeDescription
handleSalWindowHandleThe native control handle.

Returns: VisColorPaletteDropDown. The VisColorPaletteDropDown, or null when no managed control owns the handle.

A different managed control type causes InvalidCastException.

Instance member GetColor(colors)

Gets a palette color as a Win32 color value.

ParameterTypeDescription
colorsSalNumberThe zero-based color index.

Returns: SalNumber. The color value, or zero for an invalid index.

Instance member GetColors(colors)

Copies all palette colors into a SAL array.

ParameterTypeDescription
colorsSalArray<SalNumber>The non-null array to make dynamic, reset, and fill from index zero with Win32 color values.

Returns: SalNumber. The output array count.

Instance member GetFocus()

Gets the selected palette index.

Returns: SalNumber. The stored zero-based selection index.

Instance member GetMenu(nEntry, szText, nID)

Gets the caption and identifier of a palette button.

ParameterTypeDescription
nEntrySalNumberThe menu entry offset; the underlying button index is nEntry + 1.
szText by referenceSalStringReceives the caption; unchanged if the computed index is invalid.
nID by referenceSalNumberReceives the identifier; unchanged if the computed index is invalid.

Returns: SalNumber. One when found; otherwise, zero.

Instance member GetMenuAll(szText, nID)

Copies button captions and identifiers, skipping button zero.

ParameterTypeDescription
szTextSalArray<SalString>The non-null caption array to make dynamic and reset.
nIDSalArray<SalNumber>The non-null identifier array to make dynamic and reset.

Returns: SalNumber. The identifier array count.

Values are written at their button indices starting at one; element zero remains the default value when the arrays grow.

Instance member InsertMenu(nEntry, szText, nID)

Inserts a palette command button.

ParameterTypeDescription
nEntrySalNumberThe menu entry offset; the underlying button index is nEntry + 1.
szTextSalStringThe button caption.
nIDSalNumberThe button command identifier.

Returns: SalBoolean. True when the computed index is valid; otherwise, false.

Protected member OnDrawItem(e)

Draws the selected color swatch, its name or RGB components, and focus indication.

ParameterTypeDescription
eDrawItemEventArgsThe item drawing surface and bounds.

Protected member OnDropDown(e)

Sizes the drop-down to the palette preferred size before raising the base event.

ParameterTypeDescription
eEventArgsThe drop-down event data.

Protected member OnFontChanged(e)

Copies the combo-box font to the palette and recalculates the drop-down size.

ParameterTypeDescription
eEventArgsThe font-change event data.

Instance member RemoveMenu(nEntry)

Removes a palette command button.

ParameterTypeDescription
nEntrySalNumberThe menu entry offset; the underlying button index is nEntry + 1.

Returns: SalBoolean. True when the computed index is valid; otherwise, false.

Instance member SetColor(nEntry, nColor)

Replaces an existing palette color.

ParameterTypeDescription
nEntrySalNumberThe zero-based color index.
nColorSalNumberThe SAL color value.

Returns: SalNumber. The previous SAL color, or zero when the index is invalid.

Instance member SetColors(colors)

Appends colors to the palette.

ParameterTypeDescription
colorsSalArray<SalNumber>The non-null array of SAL colors to append.

Returns: SalNumber. The number of supplied colors.

Existing colors are retained.

Instance member SetFocus(nEntry)

Selects an existing color entry.

ParameterTypeDescription
nEntrySalNumberThe zero-based color index.

Returns: SalBoolean. True for a valid index; otherwise, false.

Instance member SetMenu(nEntry, szText, nID)

Updates a palette command button.

ParameterTypeDescription
nEntrySalNumberThe menu entry offset; the underlying button index is nEntry + 1.
szTextSalStringThe button caption.
nIDSalNumberThe button command identifier.

Returns: SalBoolean. True when the computed index is valid; otherwise, false.

Instance member SetMenuAll(szText, nID)

Appends command buttons from corresponding text and identifier arrays.

ParameterTypeDescription
szTextSalArray<SalString>The zero-based caption array.
nIDSalArray<SalNumber>The zero-based identifier array with the same count.

Returns: SalNumber. Zero for differing counts; otherwise, the caption count if all AddMenu calls complete.

Uses AddMenu, including its current count-as-index behavior. Existing buttons are retained.

Implements

NameDescription
ISalControl
ISalEditControl
ISalListControl
ISalWindow