/*************************************************************************/
//
//Direction
//createing arcGIS server solutions
//Developing application
//developing web application using the web adf
//web controls
//ColorPicker control
/*************************************************************************/
ColorPicker control 拾色器控件
The ColorPicker control provides a runtime dialog which can be used to select a color. Available(可利用的,可使用的) colors include all the named colors in the .NET System.Drawing.Color structure. Often a ColorPicker control is packaged in a composite(混合的、综合的) control, such as a task.
colorPicker控件提供来一个运行时候的对话框,我们可以使用这个对话框来选择一个颜色,可利用的颜色包括所有在.net system.Drawing.color下的命名过的颜色。通常一个拾色器被封装在一个混合的控件里面,比如:一个任务框。
Assembly: ESRI.ArcGIS.ADF.UI.WebControls.dll
Class: ESRI.ArcGIS.ADF.UI.WebControls.ColorPicker
Using the ColorPicker control
Add a ColorPicker control
The ColorPicker control does not require any other Web ADF controls in the page. Simply add the ColorPicker control to the page. Note that the design-time representation(描写、表现) of the control does not provide an interactive list of colors.
拾色器控件在页面中,并不需要其他的web ADF控件。 很简单的就可以将一个拾色器控件添加到当前的页面。 注意:在设计的时候,拾色器控件并不能提供一个可以交互的颜色列表。
Set ColorPicker control properties
设置拾色器控件的属性
In the ColorPicker property page, set the following:
在拾色器控件的属性页面,属性的设置如下所示:
Set the ChosenColor property to define a default display color at runtime. This property can also be used to get the current color at runtime.
Set the ShowColorNames property to False. This will display a grid(栅格) of colors at runtime. If True, a drop down list of each color and its name will be provided.
To capture the selected color on the client using JavaScript, set the OnColorPickedClient property to a JavaScript function name. For example, "colorChosen". In the aspx page, add a JavaScript function of the same name and include two parameters in the function call.
设置chosedColor 属性,来定义一个在运行的时候默认展示的颜色值。这个属性也可以用来获取在运行状态下当前的颜色值。
设置showColorNames属性为false。 这个属性将会在运行的状态下显示一个栅格状的颜色值。 如果为真,drop drown 控件就会显示一个颜色的列表并且颜色的名字也将会出现。为来在客户端使用JavaScript获取被选择的颜色的值,设置onColorPickedClient属性为一个JavaScript函数的名称。 比如:
“colorChoser”。 Zai aspx页面,添加一个同样名称的JavaScript函数并且在函数的调用里面包含两个参数。
[JavaScript]
function colorChosen(sender, color)
{
alert(color);
}
To capture the selected color on the server, handle the ColorPicked event. The selected color will be passed to the event method as an argument.
Runtime interaction(相互作用,相互影响)
为来在服务器端获取被选中的颜色的值,我们要处理colorPicked事件。 被选中的颜色将会作为一个变量传递到事件的方法。
At runtime, click on the active color box displayed by the ColorPicker. A drop down list containing colors will be displayed. Click on a color to select it. The JavaScript function defined in the previous step will be called and the name of the selected color will popup in an alert box. The active color box will now display the selected color.
在运行的时候,单击拾色器展示的的活动颜色框。 一个包含颜色值的下拉列表控件将会展现。单击一个颜色选择他。我们在上一步定义的JavaScript函数将会被调用,被选中的颜色的名称将会出现在一个弹出的对话框里面。活动的颜色框就会立即显示被选中的颜色。
Members
Properties
The following table provides a list of properties of interest. For complete reference information, see the ColorPicker control in the library reference section.
Property Name |
Type |
Description |
ChosenColor |
Color |
Gets or sets the current chosen color.(获取或者设置当前被选中的颜色) |
ShowColorNames |
boolean |
True will display a drop down list with one color and name on each line. False will display a grid of colors.(如果设置true,就会出现一个下拉列表框显示颜色以及颜色的名称,并且显示在同一行。 如果为false就会显示一个栅格状的颜色) |
DropDownHeight |
string |
The height in pixels of the drop down list(设置下俩列表的高度) |
DisplayText |
string |
The text displayed at runtime next to the color box.(在运行的状态下,一个文本将会显示在下拉框的一边) |
OnColorPickedClient |
string |
The name of a JavaScript function which will be called when a color is selected. Two parameters are passed to the function: sender and the color name. (一个JavaScript函数的名称,这个函数在一个颜色被选中后就被调用,两个参数将会被传递到这个函数里面,sendercolorName) |
Events
Event Type |
Description |
ColorPicked |
Occurs when a color is selected. (当一个颜色被选中的时候触发) |