import win.ui;
import godking.vlistEx;
/*DSG{{*/
var winform = win.form(text="aardio form";right=711;bottom=607;bgcolor=16777215)
winform.add(
menu={cls="vlistEx";left=8;top=8;right=136;bottom=600;bgcolor=16777215;db=1;dl=1;dr=1;dt=1;z=3};
static={cls="static";left=139;top=7;right=140;bottom=600;bgcolor=16752414;clip=1;db=1;dl=1;dt=1;z=1};
vlist={cls="vlistEx";left=144;top=8;right=698;bottom=599;bgcolor=16777215;db=1;dl=1;dr=1;dt=1;z=2}
)
/*}}*/
str = /*************
[杀毒软件]
软件名称1=驱动精灵BATW
软件图标=https://img.onlinedown.net/download/202401/135322-65b1f7529ae05.jpg
软件介绍=360出品的杀毒软件
软件大小=65.2 MB
软件链接=https://sfdl.360safe.com/360sd/360sd_x64_std_7.0.0.1060.exe
——————————————————————————————————————
软件名称2=360浏览器
软件图标=https://img.onlinedown.net/download/202408/184132-66b9e6dc71d00.png
软件介绍=360出品的网页浏览软件
软件大小=98 MB
软件链接=https://down.360safe.com/se/360se15.3.6272.64.exe
——————————————————————————————————————
软件名称3=WPS办公
软件图标=https://img3.downza.cn/download/202109/183238-6141cbc684960.jpg
软件介绍=金山公司出品的办公软件
软件大小=155 MB
软件链接=https://official-package.wpscdn.cn/wps/download/WPS_Setup_18912.exe
——————————————————————————————————————
软件名称4=永中文字
软件图标=https://img3.downza.cn/download/202206/103057-6296cf61b8670.jpg
软件介绍=永中公司出品的办公软件
软件大小=125 MB
软件链接=https://dl.yozosoft.com/yozo/project/file/20240812_094642_267975/9.0.5004.101ZH.S1.exe
——————————————————————————————————————
软件名称5=苗
软件图标=http://img3.downza.cn/download/201812/093213-5c184e1da25b6.jpg
软件介绍=360出品的杀毒软件
软件大小=65.2 MB
软件链接=https://sfdl.360safe.com/360sd/360sd_x64_std_7.0.0.1060.exe
——————————————————————————————————————
*************/
var pageitemlist,pagelist = {},{};
for(i=1;5;1){
var t = {fields={"序号","图标","软件名称","软件介绍","软件大小","下载"}};
var pattern = "软件名称"++i++"=(\C+)\r\n软件图标=(\C+)\r\n软件介绍=(\S+)\r\n软件大小=(\d+.?\d+\sMB)\r\n软件链接=(\S+.exe)\r\n"
for s1,s2,s3,s4,s5 in string.gmatch( str, pattern ){
var tt={};
tt["序号"]="[@rowindex]";
tt["图标"]="";
tt["软件名称"]=s1;
tt["软件介绍"]=s3;
tt["软件大小"]=s4;
tt["下载"]="";
tt["地址"]=s5;
tt["图标网址"]=s2;
..table.push(t,tt);
}
..table.push(pageitemlist,t);
..table.push(pagelist,{"[@ownerDraw]","E:\图片素材\png\png60_清新网页设计\ ("++i++").png","标题 "++i});
}
winform.menu.setTable(pagelist /*数据表*/," "/*列标题*/,/*列宽*/,/*0左1中2右*/,/*字典转为数组*/,/*字符串转为Utf8*/,/*是否克隆新表*/);
winform.menu.setHeaderHeight(0);
winform.menu.setRowHeight(40);
winform.menu.padding=0;
winform.menu.lineWidthV=0;
winform.menu.lineWidthH=0;
winform.menu.hideScroll(true/*隐藏横向滚动条*/,false/*隐藏纵向滚动条*/);
winform.menu.setColumnType(1/*列号*/,5/*_vlistEx_ColType_Button*/,1/*0居中1缩放2填满*/,/*正常图片*/,/*鼠标悬停图片*/ );
winform.menu.selectedBkColor=null;
winform.menu.ownerDraw = function (row,col,hdc,x,y,w,h,param,...){
//当列类型为 _vlistEx_ColType_Button 时,如果单元格内容为"[@ownerDraw]",使用该函数自绘按钮。
//此时 param 值为:true:鼠标在当前单元格内;false:鼠标未在当前单元格内;
import godking.paint;
var p = godking.paint.fromHdc(hdc);
var dpi = winform.menu.dpi;
//绘制大按钮
var round = 20*dpi;
var btnf = ::RECTF(x,y,w,h);
var rectf = ::RECTF(x+5*dpi,y+5*dpi,h-10*dpi,h-10*dpi);
var imgf = ::RECTF(x+10*dpi,y,h-20*dpi,h);
var textf = ::RECTF(x+h,y,w,h);
if param {
p.fillRoundRectF(btnf,round,0xFF1493FD);
p.fillEllipseF(rectf,0xFFFFFFFF)
p.drawImageF(imgf,winform.menu.getCellText(row,2),,true);
p.drawTextF(textf,winform.menu.getCellText(row,3),::LOGFONT(name="宋体";h=14*dpi;color=0xFFFFFFFF;brush=null),0/*格式*/,0/*水平*/,1/*垂直*/)
} elseif winform.menu.selIndex===row{
p.fillRoundRectF(btnf,round,0xFF50B82E);
p.fillEllipseF(rectf,0xFFFFFFFF)
p.drawImageF(imgf,winform.menu.getCellText(row,2),,true);
p.drawTextF(textf,winform.menu.getCellText(row,3),::LOGFONT(name="宋体";h=14*dpi;color=0xFFFFFFFF;brush=null),0/*格式*/,0/*水平*/,1/*垂直*/)
} else {
p.fillRoundRectF(btnf,round,0xB19EA7FD)
p.fillEllipseF(rectf,0x55FFFFFF)
p.drawImageF(imgf,winform.menu.getCellText(row,2),,true);
p.drawTextF(textf,winform.menu.getCellText(row,3),::LOGFONT(name="宋体";h=14*dpi;color=0xFF000000;brush=null),0/*格式*/,0/*水平*/,1/*垂直*/)
}
// 绘制小按钮
var btnw = 14*dpi;
var rect = ::RECT(x+w-btnw,y,x+w,y+btnw);
if rect.contains(winform.menu.mouseX,winform.menu.mouseY){
p.fillEllipse(rect ,0xFFFF0000);
} else {
p.fillEllipse(rect ,0xFF00AA00);
}
p.drawEllipse(rect /*绘制范围RECT*/,0xFFFFFFFF,/*线宽*/,/*线型*/)
p.textAntiAlias = true;
p.drawText(x+w-btnw+1,y,x+w,y+btnw+3,"×",::LOGFONT(name="Arial";h=20*dpi;color=0xFFFFFFFF;brush=null),0/*格式*/,1/*水平*/,1/*垂直*/);
p.close();
winform.menu.setButtonRects( row/*row*/, col/*col*/, {rect}/*按钮范围数组*/ );
}
winform.vlist.setHeaderHeight(50);
winform.vlist.headerAlign = {1,1,0,0,0,1};
winform.vlist.setRowHeight(45);
winform.vlist.textColor = 0x666666;
winform.vlist.selectedTextColor = 0xFF0000;
winform.vlist.lineColorH =0xCFCFCF;
winform.vlist.lineWidthV = null;
import inet.http
winform.vlist.addImg("正常按钮","https://d.xiazai8.com/pic/20240316/dfphijddtql.jpg");
winform.vlist.addImg("悬停按钮","https://d.xiazai8.com/pic/20240316/nmx5hgq2tap.png");
import godking.paint;
winform.vlist.ownerDraw = function (row,col,hdc,x,y,w,h,param,...){
var url = winform.vlist.getCellText(row,"图标网址");
var buf = winform.vlist.getImg(url);
if buf {
var p = godking.paint.fromHdc(hdc);
p.drawImageF(x,y,w,h,buf/*图片*/,/*透明度或图片属性*/,true/*保持比例*/)
p.close()
return ;
}
..gdi.fillRect(hdc,0xEEEEEE,::RECT(x,y,x+w,y+h)); //没有加载图片前,可以先画一个灰色方框占位。
thread.invoke(
function(winform,row,imgfile){
import inet.http;
var pic = inet.http.get(imgfile);
if type.isString(pic) {
thread.lock("临界区名称");
winform.vlist.addImg(imgfile/*图片名称*/,pic/*图片文件*/,false/*是否替换*/,100/*宽度*/,100/*高度*/);
winform.vlist.redrawRow(row);
thread.unlock("临界区名称");
}
}
,winform,row,url);
}
winform.vlist.onClick = function(row/*行*/,col/*列*/,x,y){
if col==6 {..win.msgbox(winform.vlist.getCellText(row,"地址"))}
}
winform.menu.onClick = function(row/*行*/,col/*列*/,x,y,buttonIndex/*按钮序号*/){
if row and col {
if !buttonIndex {
winform.vlist.setTable(pageitemlist[row] /*数据表*/,/*列标题*/,{scale=true,40,50,150,180,60,60}/*列宽*/,{1,1,0,0,0,1}/*0左1中2右*/,/*字典转为数组*/,/*字符串转为Utf8*/,true/*是否克隆新表*/)
winform.vlist.setColumnType(2,6/*_vlistEx_ColType_OwnerDraw*/ );
winform.vlist.setColumnType(6,5/*_vlistEx_ColType_Button*/,1/*0居中1缩放2填满*/,"正常按钮"/*正常图片*/,"悬停按钮"/*鼠标悬停图片*/ );
} else {
winform.menu.delRow(row);
table.remove(pageitemlist,row);
}
}
}
winform.adjust = function( cx,cy,wParam ) {
winform.vlist.setColumnWidth( /*列号*/, {scale=true,40,50,150,180,60,60}/*宽度*/);
};
winform.show();
winform.menu.onClick(1,1);
win.loopMessage();