库里面自带了例程,可自行查看代码测试。本文中的例程代码仅供参考。



//项目风格——通过改变元素的hide属性实现多元素切换显示
import win.ui;
import fonts.fontAwesome
import godking.customPlus;
/*DSG{{*/
var winform = win.form(text="aardio form";right=591;bottom=479)
winform.add(
checkbox={cls="checkbox";text="深色风格";left=384;top=448;right=584;bottom=472;z=3};
plus={cls="plus";left=8;top=8;right=560;bottom=440;bgcolor=0xC0DCC0;db=1;dl=1;dr=1;dt=1;notify=1;z=1};
scrollbar={cls="scrollbar";left=560;top=8;right=584;bottom=440;db=1;dr=1;dt=1;edge=1;z=2}
)
/*}}*/
var itemModel = {
// 1. 卡片背景(最底层)
{
type="rect";
rectf={x=3; y=3; width=-3; height=-3};
round=8;
width=1;
color=0xFFE8E8E8;
fillcolor=0xFFFFF8EC;
itemhoveredfillcolor=0xFFFFEBCD;
};
// 2. 类型大图标(左侧 FontAwesome)
{
name="typeIcon";
type="text";
rectf={x=12; y=10; width=40; height=42};
font={name='FontAwesome'; h=22; color=0xFF3A3A3A};
align=1;
valign=1;
smooth=true;
text='\uF085';
};
// 3. 服务名称
{
name="svcName";
type="text";
rectf={x=56; y=10; width=-8; height=24};
font={name='Tahoma'; h=14; weight=600; color=0xFF111111};
align=0;
valign=1;
smooth=true;
};
// 4. 状态图标(FontAwesome,底部左侧)
{
name="statusIcon";
type="text";
rectf={x=56; y=36; width=20; height=24};
font={name='FontAwesome'; h=14; color=0xFF107C10};
align=1;
valign=1;
smooth=true;
text='\uF111';
};
// 5. 状态文字标签(底部)
{
name="statusLabel";
type="text";
rectf={x=76; y=36; width=-136; height=24};
font={name='Tahoma'; h=12; color=0xFF107C10};
align=0;
valign=1;
};
// 6. 停止按钮背景
{
name="btnStopBg";
type="rect";
rectf={x=-128; y=36; width=-68; height=24};
round=4;
//width=0;
//color=0xAAC42B1A;
fillcolor=0xFFFF4500;
hoveredfillcolor=0xFFFF0000;
hover=true;
cursor=32649/*_IDC_HAND*/;
click=true;
};
// 7. 停止按钮文字
{
name="btnStopText";
type="text";
rectf={x=-128; y=36; width=-68; height=24};
font={name='FontAwesome'; h=12; color=0xFFFFFFFF};
align=1;
valign=1;
text='\uF28D 停止';
};
// 8. 重启按钮背景
{
name="btnRestartBg";
type="rect";
rectf={x=-64; y=36; width=-8; height=24};
round=4;
//width=0;
//color=0xAA876400;
fillcolor=0xFF4169E1;
hoveredfillcolor=0xFF0047AB;
hover=true;
cursor=32649;
click=true;
};
// 9. 重启按钮文字
{
name="btnRestartText";
type="text";
rectf={x=-64; y=36; width=-8; height=24};
font={name='FontAwesome'; h=12; color=0xFFFFFFFF};
align=1;
valign=1;
text='\uF1DA 重启';
};
// 10. 启动/操作按钮背景
{
name="btnStartBg";
type="rect";
rectf={x=-128; y=36; width=-8; height=24};
round=4;
width=1;
color=0xAA107C10;
fillcolor=0xFF90EE90;
hoveredfillcolor=0xFF7CFC00;
hover=true;
cursor=32649;
click=true;
};
// 11. 启动/操作按钮文字
{
name="btnStartText";
type="text";
rectf={x=-128; y=36; width=-8; height=24};
font={name='FontAwesome'; h=12; color=0xFF000000};
align=1;
valign=1;
text='\uF061 启动';
};
};
var itemModel_dark = ..table.clone(itemModel);
itemModel_dark[1].fillcolor=0xFF003153;
itemModel_dark[1].itemhoveredfillcolor=0xFF0047AB;
itemModel_dark[2].font.color = 0xFFFFFACD;
itemModel_dark[3].font.color = 0xFFFFFFFF;
itemModel_dark[4].font.color = 0xFF107C10;
itemModel_dark[5].font.color = 0xFFFFC0CB;
itemModel_dark[9].font.color = 0xFFE0FFFF;
itemList = {
{typeIcon='\uF085'; statusLabel=string.random("运行中","已停止"); svcName="Print Spooler";};
{typeIcon='\uF084'; statusLabel=string.random("运行中","已停止"); svcName="Windows Firewall";};
{typeIcon='\uF075'; statusLabel=string.random("运行中","已停止"); svcName="DNS Client";};
{typeIcon='\uF074'; statusLabel=string.random("运行中","已停止"); svcName="Windows Update";};
{typeIcon='\uF073'; statusLabel=string.random("运行中","已停止"); svcName="hosts 文件";};
{typeIcon='\uF072'; statusLabel=string.random("运行中","已停止"); svcName="DNS Client";};
{typeIcon='\uF071'; statusLabel=string.random("运行中","已停止"); svcName="calc.exe";}
}
var p = godking.customPlus(winform.plus/*plus*/,itemModel,itemList,{
itemWidth=260, /*项目宽度*/
itemHeight=70, /*项目高度*/
autoSizeWidth=true, /*自动根据项目列数及plus宽度调整项目宽度*/
autoSizeHeight=false, /*自动根据项目行数及plus高度调整项目高度*/
colnum=0, /*项目列数,为0则根据项目宽度和plus宽度自动计算*/
rownum=0, /*项目行数,为0则根据项目高度和plus高度自动计算*/
padLeft=5, /*plus左边空白距离*/
padTop=5, /*plus顶边空白距离*/
padRight=5, /*plus右边空白距离*/
padBottom=5 /*plus底边空白距离*/
})
p.onClick = function(itemIndex/*项目索引*/,elemIndex/*元素索引*/,elemID/*元素id*/,elemName/*元素name*/,pageIndex/*当前页项目索引*/,x/*鼠标X坐标*/,y/*鼠标Y坐标*/,disabled/*项目是否禁用*/,itemRect/*项目区域*/,elemRect/*元素区域*/){
/*鼠标左键单击非隐藏项目时触发该事件。当项目禁用或没有可点击元素时,默认不触发该事件。可设 allClickEvent=true 启用触发。*/
if elemName=="btnStartBg" {
p.itemList[itemIndex].statusLabel="运行中";
}
if elemName=="btnStopBg" {
p.itemList[itemIndex].statusLabel="停止";
}
if elemName=="btnRestartBg" {
win.msgbox("重启完毕");
}
p.update(itemIndex);
}
//预设红色字体
var redFont = {name='Tahoma'; h=14; weight=600; color=0xFFFF0000};
p.onDrawElement = function(itemIndex/*项目索引*/,elemIndex/*元素索引*/,elemName/*元素name*/,eleValue/*元素值*/){
//设置各按钮的隐藏状态
if elemName=="btnRestartBg" or elemName=="btnRestartText" or elemName=="btnStopBg" or elemName=="btnStopText" {
return { hide = p.itemList[itemIndex].statusLabel!="运行中" },true;
}
if elemName=="btnStartBg" or elemName=="btnStartText" {
return { hide = p.itemList[itemIndex].statusLabel=="运行中" },true;
}
//设置运行时显示图标
if elemName=="statusIcon" {
return p.itemList[itemIndex].statusLabel=="运行中"?'\uF01D':'\uF04C';
}
//运行中的svcName设置为红色
if elemName=="svcName" and p.itemList[itemIndex].statusLabel=="运行中" {
return { text=eleValue; font=redFont };
}
}
winform.checkbox.oncommand = function(id,event){
if owner.checked {
p.init( itemModel_dark/*项目模板*/,0xFF778899/*背景颜色*/,/*背景图像*/,/*竖向排列*/)
} else {
p.init( itemModel/*项目模板*/,0xFFFFFFFF/*背景颜色*/,/*背景图像*/,/*竖向排列*/)
}
}
p.bindScrollbar(winform.scrollbar);
winform.show();
win.loopMessage();
//项目风格——通过paint类型绘制元素不同状态
import win.ui;
import fonts.fontAwesome
import godking.customPlus;
/*DSG{{*/
var winform = win.form(text="aardio form";right=591;bottom=447)
winform.add(
plus={cls="plus";left=8;top=8;right=560;bottom=440;bgcolor=0xC0DCC0;db=1;dl=1;dr=1;dt=1;notify=1;z=1};
scrollbar={cls="scrollbar";left=560;top=8;right=584;bottom=440;db=1;dr=1;dt=1;edge=1;z=2}
)
/*}}*/
var itemModel = {
// 1. 卡片背景(最底层)
{
type="rect";
rectf={x=3; y=3; width=-3; height=-3};
round=8;
width=1;
color=0xFFE8E8E8;
fillcolor=0xFFFFF8EC;
itemhoveredfillcolor=0xFFFFEBCD;
};
// 2. 类型大图标(左侧 FontAwesome)
{
name="typeIcon";
type="text";
rectf={x=12; y=10; width=40; height=42};
font={name='FontAwesome'; h=22; color=0xFF3A3A3A};
align=1;
valign=1;
smooth=true;
text='\uF085';
};
// 3. 服务名称
{
name="svcName";
type="text";
rectf={x=56; y=10; width=-8; height=24};
font={name='Tahoma'; h=14; weight=600; color=0xFF111111};
align=0;
valign=1;
smooth=true;
};
// 4. 状态图标(FontAwesome,底部左侧)
{
name="statusIcon";
type="text";
rectf={x=56; y=36; width=20; height=24};
font={name='FontAwesome'; h=14; color=0xFF107C10};
align=1;
valign=1;
smooth=true;
text='\uF111';
};
// 5. 状态文字标签(底部)
{
name="statusLabel";
type="text";
rectf={x=76; y=36; width=-136; height=24};
font={name='Tahoma'; h=12; color=0xFF107C10};
align=0;
valign=1;
};
// 6. 启动
{
name="start";
type="paint", /* 使用proc()函数进行绘制。proc函数的第1个参数为 godking.paint 对象 */
rectf={x=-100;y=-40;width=-10;height=-10}, /* 鼠标定位区域,并传递给proc函数的rectf参数,不用于限制元素绘制区域。负数表示距离项目右边或底边的距离 */
proc=function(paint,itemIndex,eleIndex,rectf,disabled,checked,hovered,itemSelected,itemHovered,eleValue){
/* 参数:godking.paint对象、当前项目索引、当前元素索引、当前绘制区域、项目是否禁用、元素是否选中、元素是否鼠标划过、项目是否选中、项目是否鼠标划过、项目列表中指定的该元素的值
本函数的 owner 对象为customPlus对象。*/
paint = toPaint(paint); /* 用于绑定godking.paint智能提示 */
if owner.itemList[itemIndex].statusLabel=="运行中" {
paint.fillRoundRectF(rectf/*绘制范围RECT*/,25/*圆角半径*/,0xFF008000)
var f = ::RECTF(rectf.x+rectf.width-rectf.height+2,rectf.y+2,rectf.height-4,rectf.height-4);
paint.fillEllipseF(f /*绘制范围RECTF*/,0xFFFFFFFF);
paint.drawTextF(f.offset(2,1) /*文本范围RECTF*/,'\uF04B',::LOGFONT(name="FontAwesome";h=16;color=0xFF008000;),0/*格式*/,1/*水平*/,1/*垂直*/,false/*截短*/)
var f = ::RECTF(rectf.x,rectf.y+1*owner.dpi,rectf.width-rectf.height+4,rectf.height);
paint.drawTextF( f /*文本范围RECTF*/,"运行中",::LOGFONT(name="宋体";h=12*owner.dpi;color=0xFFFFFFFF;),0/*格式*/,1/*水平*/,1/*垂直*/,false/*截短*/)
} else {
paint.fillRoundRectF(rectf/*绘制范围RECT*/,25/*圆角半径*/,0xFF4169E1)
var f = ::RECTF(rectf.x+2,rectf.y+2,rectf.height-4,rectf.height-4);
paint.fillEllipseF(f /*绘制范围RECTF*/,0xFFFFFFFF);
paint.drawTextF(f.offset(0,1) /*文本范围RECTF*/,'\uF04C',::LOGFONT(name="FontAwesome";h=16;color=0xFF4169E1;),0/*格式*/,1/*水平*/,1/*垂直*/,false/*截短*/)
var f = ::RECTF(rectf.x+rectf.height-4,rectf.y+1*owner.dpi,rectf.width-rectf.height,rectf.height);
paint.drawTextF( f /*文本范围RECTF*/,"停止中",::LOGFONT(name="宋体";h=12*owner.dpi;color=0xFFFFFFFF;),0/*格式*/,1/*水平*/,1/*垂直*/,false/*截短*/)
}
};
/* 以下为可选项 */
click=true, /* 是否响应鼠标点击事件 */
hover=true, /* 是否启用鼠标滑过检测,启用后,cursor、hoveredcolor、hoveredfont等设置才生效 */
cursor=32649, /* 鼠标指针,_IDC_ 开头的常量。 */
}
};
itemList = {
{typeIcon='\uF085'; statusLabel=string.random("运行中","已停止"); svcName="Print Spooler";};
{typeIcon='\uF084'; statusLabel=string.random("运行中","已停止"); svcName="Windows Firewall";};
{typeIcon='\uF075'; statusLabel=string.random("运行中","已停止"); svcName="DNS Client";};
{typeIcon='\uF074'; statusLabel=string.random("运行中","已停止"); svcName="Windows Update";};
{typeIcon='\uF073'; statusLabel=string.random("运行中","已停止"); svcName="hosts 文件";};
{typeIcon='\uF072'; statusLabel=string.random("运行中","已停止"); svcName="DNS Client";};
{typeIcon='\uF071'; statusLabel=string.random("运行中","已停止"); svcName="calc.exe";}
}
var p = godking.customPlus(winform.plus/*plus*/,itemModel,itemList,{
itemWidth=260, /*项目宽度*/
itemHeight=70, /*项目高度*/
autoSizeWidth=true, /*自动根据项目列数及plus宽度调整项目宽度*/
autoSizeHeight=false, /*自动根据项目行数及plus高度调整项目高度*/
colnum=0, /*项目列数,为0则根据项目宽度和plus宽度自动计算*/
rownum=0, /*项目行数,为0则根据项目高度和plus高度自动计算*/
padLeft=5, /*plus左边空白距离*/
padTop=5, /*plus顶边空白距离*/
padRight=5, /*plus右边空白距离*/
padBottom=5 /*plus底边空白距离*/
})
p.onClick = function(itemIndex/*项目索引*/,elemIndex/*元素索引*/,elemID/*元素id*/,elemName/*元素name*/,pageIndex/*当前页项目索引*/,x/*鼠标X坐标*/,y/*鼠标Y坐标*/,disabled/*项目是否禁用*/,itemRect/*项目区域*/,elemRect/*元素区域*/){
/*鼠标左键单击非隐藏项目时触发该事件。当项目禁用或没有可点击元素时,默认不触发该事件。可设 allClickEvent=true 启用触发。*/
if elemName=="start" {
if p.itemList[itemIndex].statusLabel=="运行中" {
p.itemList[itemIndex].statusLabel="停止中";
} else {
p.itemList[itemIndex].statusLabel="运行中";
}
}
p.update(itemIndex);
}
//预设红色字体
var redFont = {name='Tahoma'; h=14; weight=600; color=0xFFFF0000};
p.onDrawElement = function(itemIndex/*项目索引*/,elemIndex/*元素索引*/,elemName/*元素name*/,eleValue/*元素值*/){
//设置状态文本颜色
if elemName=="statusLabel" {
return p.itemList[itemIndex].statusLabel=="运行中"?
{text=eleValue,font={name='Tahoma'; h=12; color=0xFF107C10}}
:{text=eleValue,font={name='Tahoma'; h=12; color=0xFF4169E1}}
}
//设置运行时显示图标
if elemName=="statusIcon" {
return p.itemList[itemIndex].statusLabel=="运行中"?
{text='\uF01D',font={name='FontAwesome'; h=14; color=0xFF107C10}}
:{text='\uF04C',font={name='FontAwesome'; h=14; color=0xFF4169E1}}
}
//运行中的svcName设置为红色
if elemName=="svcName" and p.itemList[itemIndex].statusLabel=="运行中" {
return { text=eleValue; font=redFont };
}
}
p.bindScrollbar(winform.scrollbar);
winform.show();
win.loopMessage();
//项目风格——全模块化风格
import win.ui;
import fonts.fontAwesome
import godking.customPlus;
/*DSG{{*/
var winform = win.form(text="aardio form";right=591;bottom=479)
winform.add(
combobox={cls="combobox";left=384;top=448;right=584;bottom=472;items={"浅色风格","深色风格","橙色风格"};mode="dropdownlist";z=3};
plus={cls="plus";left=8;top=8;right=560;bottom=440;bgcolor=0xC0DCC0;db=1;dl=1;dr=1;dt=1;notify=1;z=1};
scrollbar={cls="scrollbar";left=560;top=8;right=584;bottom=440;db=1;dr=1;dt=1;edge=1;z=2}
)
/*}}*/
// 定义浅色风格模版
var itemModel = {
bkcolor = 0xFFFFFFFF;
// 1、卡片背景(最底层)
{
type="rect";
rectf={x=3; y=3; width=-3; height=-3};
round=8;
width=1;
color=0xFFE8E8E8;
fillcolor=0xFFFFF8EC;
itemhoveredfillcolor=0xFFFFEBCD;
};
// 2、类型大图标(左侧 FontAwesome)
{
name="typeIcon";
type="text";
rectf={x=12; y=10; width=40; height=42};
font={name='FontAwesome'; h=22; color=0xFF3A3A3A};
align=1;
valign=1;
smooth=true;
text='\uF085';
};
// 3、服务名称
{
name="svcName";
type="text";
rectf={x=56; y=10; width=-8; height=24};
font={name='Tahoma'; h=14; weight=600; color=0xFFFF0000};
font_stop={name='Tahoma'; h=14; weight=600; color=0xFF111111};
align=0;
valign=1;
smooth=true;
};
// 4、状态图标(FontAwesome,底部左侧)
{
name="statusIcon";
type="text";
rectf={x=56; y=36; width=20; height=24};
font={name='FontAwesome'; h=14; color=0xFF107C10};
font_stop={name='FontAwesome'; h=14; color=0xFF4169E1};
align=1;
valign=1;
smooth=true;
text='\uF111';
};
// 5、状态文字标签(底部)
{
name="statusLabel";
type="text";
rectf={x=76; y=36; width=-136; height=24};
font={name='Tahoma'; h=12; color=0xFF107C10};
font_stop={name='Tahoma'; h=12; color=0xFF4169E1};
align=0;
valign=1;
};
// 6、启动
{
name="start";
type="paint", /* 使用proc()函数进行绘制。proc函数的第1个参数为 godking.paint 对象 */
rectf={x=-100;y=-40;width=-10;height=-10}, /* 鼠标定位区域,并传递给proc函数的rectf参数,不用于限制元素绘制区域。负数表示距离项目右边或底边的距离 */
runcolor = 0xFF008000;
stopcolor = 0xFF4169E1;
proc=function(paint,itemIndex,eleIndex,rectf,disabled,checked,hovered,itemSelected,itemHovered,eleValue){
/* 参数:godking.paint对象、当前项目索引、当前元素索引、当前绘制区域、项目是否禁用、元素是否选中、元素是否鼠标划过、项目是否选中、项目是否鼠标划过、项目列表中指定的该元素的值
本函数的 owner 对象为customPlus对象。*/
paint = toPaint(paint); /* 用于绑定godking.paint智能提示 */
paint.clip.set(rectf,0,0);
var runcolor = owner.itemModel[eleIndex].runcolor;
var stopcolor = owner.itemModel[eleIndex].stopcolor;
if owner.itemList[itemIndex].statusLabel=="运行中" {
if eleValue>0 {
// 按钮背景色渐变转换
paint.fillRoundRectF(rectf/*绘制范围RECT*/,25/*圆角半径*/,stopcolor);
var r,g,b,a = gdi.getRgba(runcolor);
var argb = gdi.ARGB(r,g,b,eleValue*255);
paint.fillRoundRectF(rectf/*绘制范围RECT*/,25/*圆角半径*/,argb);
// 绘制按钮内容
var offset = ((rectf.x+rectf.width-rectf.height+2) - (rectf.x+2))*eleValue;
var f = ::RECTF(rectf.x+2+offset,rectf.y+2,rectf.height-4,rectf.height-4);
paint.fillEllipseF(f /*绘制范围RECTF*/,0xFFFFFFFF);
paint.drawTextF(f.offset(0,1) /*文本范围RECTF*/,'\uF04C',::LOGFONT(name="FontAwesome";h=16;color=stopcolor;),0/*格式*/,1/*水平*/,1/*垂直*/,false/*截短*/)
var f = ::RECTF(rectf.x+rectf.height-4+offset,rectf.y+1*owner.dpi,rectf.width-rectf.height,rectf.height);
paint.drawTextF( f /*文本范围RECTF*/,"停止中",::LOGFONT(name="宋体";h=12*owner.dpi;color=0xFFFFFFFF;),0/*格式*/,1/*水平*/,1/*垂直*/,false/*截短*/)
} else {
paint.fillRoundRectF(rectf/*绘制范围RECT*/,25/*圆角半径*/,runcolor)
var f = ::RECTF(rectf.x+rectf.width-rectf.height+2,rectf.y+2,rectf.height-4,rectf.height-4);
paint.fillEllipseF(f /*绘制范围RECTF*/,0xFFFFFFFF);
paint.drawTextF(f.offset(2,1) /*文本范围RECTF*/,'\uF04B',::LOGFONT(name="FontAwesome";h=16;color=runcolor;),0/*格式*/,1/*水平*/,1/*垂直*/,false/*截短*/)
var f = ::RECTF(rectf.x,rectf.y+1*owner.dpi,rectf.width-rectf.height+4,rectf.height);
paint.drawTextF( f /*文本范围RECTF*/,"运行中",::LOGFONT(name="宋体";h=12*owner.dpi;color=0xFFFFFFFF;),0/*格式*/,1/*水平*/,1/*垂直*/,false/*截短*/)
}
} else {
if eleValue>0 {
// 按钮背景色渐变转换
paint.fillRoundRectF(rectf/*绘制范围RECT*/,25/*圆角半径*/,runcolor);
var r,g,b,a = gdi.getRgba(stopcolor);
var argb = gdi.ARGB(r,g,b,eleValue*255);
paint.fillRoundRectF(rectf/*绘制范围RECT*/,25/*圆角半径*/,argb);
// 绘制按钮内容
var offset = ((rectf.x+rectf.width-rectf.height+2) - (rectf.x+2))*eleValue;
var f = ::RECTF(rectf.x+rectf.width-rectf.height+2-offset,rectf.y+2,rectf.height-4,rectf.height-4);
paint.fillEllipseF(f /*绘制范围RECTF*/,0xFFFFFFFF);
paint.drawTextF(f.offset(2,1) /*文本范围RECTF*/,'\uF04B',::LOGFONT(name="FontAwesome";h=16;color=runcolor;),0/*格式*/,1/*水平*/,1/*垂直*/,false/*截短*/)
var f = ::RECTF(rectf.x-offset,rectf.y+1*owner.dpi,rectf.width-rectf.height+4,rectf.height);
paint.drawTextF( f /*文本范围RECTF*/,"运行中",::LOGFONT(name="宋体";h=12*owner.dpi;color=0xFFFFFFFF;),0/*格式*/,1/*水平*/,1/*垂直*/,false/*截短*/)
} else {
paint.fillRoundRectF(rectf/*绘制范围RECT*/,25/*圆角半径*/,stopcolor)
var f = ::RECTF(rectf.x+2,rectf.y+2,rectf.height-4,rectf.height-4);
paint.fillEllipseF(f /*绘制范围RECTF*/,0xFFFFFFFF);
paint.drawTextF(f.offset(0,1) /*文本范围RECTF*/,'\uF04C',::LOGFONT(name="FontAwesome";h=16;color=stopcolor;),0/*格式*/,1/*水平*/,1/*垂直*/,false/*截短*/)
var f = ::RECTF(rectf.x+rectf.height-4,rectf.y+1*owner.dpi,rectf.width-rectf.height,rectf.height);
paint.drawTextF( f /*文本范围RECTF*/,"停止中",::LOGFONT(name="宋体";h=12*owner.dpi;color=0xFFFFFFFF;),0/*格式*/,1/*水平*/,1/*垂直*/,false/*截短*/)
}
}
};
/* 以下为可选项 */
click=true, /* 是否响应鼠标点击事件 */
hover=true, /* 是否启用鼠标滑过检测,启用后,cursor、hoveredcolor、hoveredfont等设置才生效 */
cursor=32649, /* 鼠标指针,_IDC_ 开头的常量。 */
}
};
// 定义深色风格模版
var itemModel_dark = ..table.clone(itemModel);
itemModel_dark.bkcolor=0xFF778899;
itemModel_dark[1].fillcolor=0xFF003153;
itemModel_dark[1].itemhoveredfillcolor=0xFF0047AB;
itemModel_dark[2].font.color = 0xFFFFFACD;
itemModel_dark[3].font.color = 0xFFFF4500;
itemModel_dark[3].font_stop.color = 0xFFFFFFFF;
itemModel_dark[4].font.color = 0xFFADFF2F;
itemModel_dark[4].font_stop.color = 0xFF00FFFF;
itemModel_dark[5].font.color = 0xFFADFF2F;
itemModel_dark[5].font_stop.color = 0xFF00FFFF;
// 定义橙色风格模版
var itemModel_red = ..table.clone(itemModel);
itemModel_red.bkcolor=0xFFFF4500;
itemModel_red[1].fillcolor=0xFFFFE4E1;
itemModel_red[1].itemhoveredfillcolor=0xFFFFB6C1;
itemModel_red[2].font.color = 0xFFFF4500;
itemModel_red[3].font.color = 0xFFFF4500;
itemModel_red[3].font_stop.color = 0xFF000000;
itemModel_red[4].font.color = 0xFF228B22;
itemModel_red[4].font_stop.color = 0xFF8B4513;
itemModel_red[5].font.color = 0xFF228B22;
itemModel_red[5].font_stop.color = 0xFF8B4513;
itemModel_red[6].runcolor = 0xFFFF4500;
itemModel_red[6].stopcolor = 0xFF9400D3;
// 定义项目列表
itemList = {
{typeIcon='\uF085'; start=0; statusLabel=string.random("运行中","已停止"); svcName="Print Spooler";};
{typeIcon='\uF084'; start=0; statusLabel=string.random("运行中","已停止"); svcName="Windows Firewall";};
{typeIcon='\uF075'; start=0; statusLabel=string.random("运行中","已停止"); svcName="DNS Client";};
{typeIcon='\uF074'; start=0; statusLabel=string.random("运行中","已停止"); svcName="Windows Update";};
{typeIcon='\uF073'; start=0; statusLabel=string.random("运行中","已停止"); svcName="hosts 文件";};
{typeIcon='\uF072'; start=0; statusLabel=string.random("运行中","已停止"); svcName="DNS Client";};
{typeIcon='\uF071'; start=0; statusLabel=string.random("运行中","已停止"); svcName="calc.exe";}
}
// 定义customPlus组件对象
var p = godking.customPlus(winform.plus/*plus*/,itemModel,itemList,{
itemWidth=260, /*项目宽度*/
itemHeight=70, /*项目高度*/
autoSizeWidth=true, /*自动根据项目列数及plus宽度调整项目宽度*/
autoSizeHeight=false, /*自动根据项目行数及plus高度调整项目高度*/
colnum=0, /*项目列数,为0则根据项目宽度和plus宽度自动计算*/
rownum=0, /*项目行数,为0则根据项目高度和plus高度自动计算*/
padLeft=5, /*plus左边空白距离*/
padTop=5, /*plus顶边空白距离*/
padRight=5, /*plus右边空白距离*/
padBottom=5 /*plus底边空白距离*/
})
// customPlus组件点击按钮事件
p.onClick = function(itemIndex/*项目索引*/,eleIndex/*元素索引*/,eleID/*元素id*/,eleName/*元素name*/,pageIndex/*当前页项目索引*/,x/*鼠标X坐标*/,y/*鼠标Y坐标*/,disabled/*项目是否禁用*/,itemRect/*项目区域*/,eleRect/*元素区域*/){
/*鼠标左键单击非隐藏项目时触发该事件。当项目禁用或没有可点击元素时,默认不触发该事件。可设 allClickEvent=true 启用触发。*/
if eleName=="start" {
for(i=10,1,-1){
p.itemList[itemIndex].start = i/10;
p.update(itemIndex);
win.delay(10);
}
p.itemList[itemIndex].start = 0;
if p.itemList[itemIndex].statusLabel=="运行中" {
p.itemList[itemIndex].statusLabel="停止中";
} else {
p.itemList[itemIndex].statusLabel="运行中";
}
p.update(itemIndex);
}
}
// customPlus组件绘制元素事件
p.onDrawElement = function(itemIndex/*项目索引*/,eleIndex/*元素索引*/,eleName/*元素name*/,eleValue/*元素值*/){
//设置运行与停止状态时,不同的文本颜色
if eleName=="statusLabel" or eleName=="svcName" {
var font = p.itemList[itemIndex].statusLabel=="运行中"?p.itemModel[eleIndex].font:p.itemModel[eleIndex].font_stop;
return {text=eleValue,font=font} //文本不变,字体改变
}
//设置运行与停止状态时,不同的图标文本和颜色
if eleName=="statusIcon" {
var font = p.itemList[itemIndex].statusLabel=="运行中"?p.itemModel[eleIndex].font:p.itemModel[eleIndex].font_stop;
var text = p.itemList[itemIndex].statusLabel=="运行中"?'\uF01D':'\uF04C';
return {text=text,font=font} //文本和字体都改变
}
}
// 切换customPlus风格
winform.combobox.oncommand = function(id,event){
var model = ({itemModel,itemModel_dark,itemModel_red})[winform.combobox.selIndex];
p.init( model/*项目模板*/,model.bkcolor/*背景颜色*/,/*背景图像*/,/*竖向排列*/);
}
// customPlus组件绑定滚动条
p.bindScrollbar(winform.scrollbar);
winform.show();
win.loopMessage();