VisColorPalette
Namespace: PPJ.Runtime.Vis
Assembly: PPJ.Runtime.Vis.50 (5.0.0.0)
Exposes SAL color and command operations for a selectable color palette.
- C#
- VB.NET
public class VisColorPalette : VisColorPaletteBase
Public Class VisColorPalette
Inherits VisColorPaletteBase
Example:
using (var palette = new PPJ.Runtime.Vis.VisColorPalette())
{
int index = palette.Colors.Add(System.Drawing.Color.Red);
palette.SetFocus(index);
}
Constructors
VisColorPalette()
Initializes a new instance of VisColorPalette.
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 from a native window handle.
| Parameter | Type | Description |
|---|---|---|
| handle | SalWindowHandle | The native control handle. |
Returns: VisColorPalette. The VisColorPalette, or null if no managed control owns the handle.
A different managed control type causes InvalidCastException.
GetColor(nEntry)
Gets a palette color as a Win32 color value.
| Parameter | Type | Description |
|---|---|---|
| nEntry | SalNumber | The zero-based color index. |
Returns: SalNumber. The color value, or zero for an invalid index.
GetColors(nColors)
Copies all palette colors into a SAL array.
| Parameter | Type | Description |
|---|---|---|
| nColors | 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, sText, 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. |
| sText | 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(sText, nID)
Copies button captions and identifiers, skipping button zero.
| Parameter | Type | Description |
|---|---|---|
| sText | 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.
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(nColors)
Appends colors to the palette.
| Parameter | Type | Description |
|---|---|---|
| nColors | 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(sText, nID)
Appends command buttons from corresponding text and identifier arrays.
| Parameter | Type | Description |
|---|---|---|
| sText | 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 |
|---|---|
| ISalWindow |