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.
- C#
- VB.NET
public class VisColorPaletteDropDown : VisDropDownBase
Public Class VisColorPaletteDropDown
Inherits VisDropDownBase
Example:
using (var palette = new PPJ.Runtime.Vis.VisColorPaletteDropDown())
{
palette.Colors.Add(System.Drawing.Color.Red);
palette.SelectedColor = System.Drawing.Color.Red;
}
Constructors
VisColorPaletteDropDown()
Creates and hosts the palette, attaches selection handlers, and enables owner drawing.
Properties
Colors
IList: Gets the mutable palette color collection.
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.
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.
Text
String: Gets an empty text value for the palette combo box.
Assignments are ignored; owner drawing displays the selected color.
Methods
AddMenu(szText, nID)
Appends a palette button and attempts to assign its caption and identifier.
| Parameter | Type | Description |
|---|---|---|
| szText | SalString | The requested caption. |
| nID | SalNumber | The 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.
ClearMenu()
Removes palette buttons after the first button.
Returns: SalBoolean. True.
The button at index zero is retained.
FromHandle(handle)
Resolves a palette drop-down from a native window handle.
| Parameter | Type | Description |
|---|---|---|
| handle | SalWindowHandle | The native control handle. |
Returns: VisColorPaletteDropDown. The VisColorPaletteDropDown, or null when no managed control owns the handle.
A different managed control type causes InvalidCastException.
GetColor(colors)
Gets a palette color as a Win32 color value.
| Parameter | Type | Description |
|---|---|---|
| colors | SalNumber | The zero-based color index. |
Returns: SalNumber. The color value, or zero for an invalid index.
GetColors(colors)
Copies all palette colors into a SAL array.
| Parameter | Type | Description |
|---|---|---|
| colors | SalArray<SalNumber> | The non-null array to make dynamic, reset, and fill from index zero with Win32 color values. |
Returns: SalNumber. The output array count.
GetFocus()
Gets the selected palette index.
Returns: SalNumber. The stored zero-based selection index.
GetMenu(nEntry, szText, nID)
Gets the caption and identifier of a palette button.
| Parameter | Type | Description |
|---|---|---|
| nEntry | SalNumber | The menu entry offset; the underlying button index is nEntry + 1. |
| szText | SalString | Receives the caption; unchanged if the computed index is invalid. |
| nID | SalNumber | Receives the identifier; unchanged if the computed index is invalid. |
Returns: SalNumber. One when found; otherwise, zero.
GetMenuAll(szText, nID)
Copies button captions and identifiers, skipping button zero.
| Parameter | Type | Description |
|---|---|---|
| szText | SalArray<SalString> | The non-null caption array to make dynamic and reset. |
| nID | SalArray<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.
InsertMenu(nEntry, szText, nID)
Inserts a palette command button.
| Parameter | Type | Description |
|---|---|---|
| nEntry | SalNumber | The menu entry offset; the underlying button index is nEntry + 1. |
| szText | SalString | The button caption. |
| nID | SalNumber | The button command identifier. |
Returns: SalBoolean. True when the computed index is valid; otherwise, false.
OnDrawItem(e)
Draws the selected color swatch, its name or RGB components, and focus indication.
| Parameter | Type | Description |
|---|---|---|
| e | DrawItemEventArgs | The item drawing surface and bounds. |
OnDropDown(e)
Sizes the drop-down to the palette preferred size before raising the base event.
| Parameter | Type | Description |
|---|---|---|
| e | EventArgs | The drop-down event data. |
OnFontChanged(e)
Copies the combo-box font to the palette and recalculates the drop-down size.
| Parameter | Type | Description |
|---|---|---|
| e | EventArgs | The font-change event data. |
RemoveMenu(nEntry)
Removes a palette command button.
| Parameter | Type | Description |
|---|---|---|
| nEntry | SalNumber | The menu entry offset; the underlying button index is nEntry + 1. |
Returns: SalBoolean. True when the computed index is valid; otherwise, false.
SetColor(nEntry, nColor)
Replaces an existing palette color.
| Parameter | Type | Description |
|---|---|---|
| nEntry | SalNumber | The zero-based color index. |
| nColor | SalNumber | The SAL color value. |
Returns: SalNumber. The previous SAL color, or zero when the index is invalid.
SetColors(colors)
Appends colors to the palette.
| Parameter | Type | Description |
|---|---|---|
| colors | SalArray<SalNumber> | The non-null array of SAL colors to append. |
Returns: SalNumber. The number of supplied colors.
Existing colors are retained.
SetFocus(nEntry)
Selects an existing color entry.
| Parameter | Type | Description |
|---|---|---|
| nEntry | SalNumber | The zero-based color index. |
Returns: SalBoolean. True for a valid index; otherwise, false.
SetMenu(nEntry, szText, nID)
Updates a palette command button.
| Parameter | Type | Description |
|---|---|---|
| nEntry | SalNumber | The menu entry offset; the underlying button index is nEntry + 1. |
| szText | SalString | The button caption. |
| nID | SalNumber | The button command identifier. |
Returns: SalBoolean. True when the computed index is valid; otherwise, false.
SetMenuAll(szText, nID)
Appends command buttons from corresponding text and identifier arrays.
| Parameter | Type | Description |
|---|---|---|
| szText | SalArray<SalString> | The zero-based caption array. |
| nID | SalArray<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
| Name | Description |
|---|---|
| ISalControl | |
| ISalEditControl | |
| ISalListControl | |
| ISalWindow |