Class that represents a color chooser dialog.
// create a new color dialog that shows the extended
// color selector
var dlg = new ColorDialog;
dlg.showAllColors();
// add some custom colors to the dialog
dlg.setCustomColor(0, new Color(200, 0, 0)); // custom red
dlg.setCustomColor(1, 0, 0, 200); // custom blue
// show the dialog, and if the user selects a color,
// display a message that shows the RGB values of
// the selected color
if (dlg.showDialog() == DialogResult.Ok)
{
// the getColor() funtion returns a Color object,
// which has red, green, and blue members
var c = dlg.getColor();
// extract the red, green, and blue values
// from the color object and display them
// with an alert
var output = "";
output += "Red: " + c.red + "
";
output += "Green: " + c.green + "
";
output += "Blue: " + c.blue + "
";
alert(output);
}
Returns the caption of the color dialog.
Returns the caption of the color dialog.
Returns the color object that corresponds to the currently set color of the color dialog.
Returns the color object that corresponds to the currently set color of the color dialog.
Returns the custom color object for the specified index, where index is between 0 and 15.
Returns the custom color object for the specified index, where index is between 0 and 15.
Sets the caption of the color dialog to text.
Sets the color of the color dialog to the value specified by color or to the values specified by red, green, and blue.
Sets the custom color with the given index, where index is between 0 and 15, to the color specified by color or to the values specified by red, green, and blue.
Sets a flag to show either a full color dialog or a basic color dialog. If flag is true, a full color dialog will be shown. If flag is false, a basic color dialog will be shown.
Returns DialogResult.Ok when the dialog is closed by pressing "OK" or equivalent, and DialogResult.Cancel if the dialog is closed by pressing "Cancel" or equivalent.
Shows a color dialog and returns DialogResult.Ok if the user closes the color dialog by pressing "OK", or the equivalent, and DialogResult.Cancel if the user closes the color dialog by pressing "Cancel", or the equivalent.