
//调用自定义库示例
import win.ui;
import inet.http;
/*DSG{{*/
var winform = win.form(text="userList库- 示例";right=343;bottom=600)
winform.add(
plusUserList={cls="plus";left=8;top=8;right=336;bottom=592;db=1;dl=1;dr=1;dt=1;edge=1;notify=1;z=1}
)
/*}}*/
var code = inet.http.get("https://aar.chengxu.online/attach-download-478.htm");
var object = loadcodex(code);
var userList = object(winform, winform.plusUserList);
userList.itemHeight = 70;
userList.fontSizeName = 11;
userList.colorHover = 0xFFE3FCFF; // 悬停颜色
userList.colorSelect = 0xFFD3F2FF; // 选中颜色
userList.showTip = false
// 准备数据
var bmpA = ..gdip.bitmap("https://ts1.tc.mm.bing.net/th/id/OIP-C.plDYYfBYwZeyfKgMneNx3gHaHa");
var bmpB = ..gdip.bitmap("https://ts2.tc.mm.bing.net/th/id/OIP-C.g7dRyyddVYQRJcrQR1e6dwHaHa");
var mockData = {
{ name = "张三"; sign = "随风奔跑自由是方向,追逐雷和闪电的力量"; avatar = bmpA; status = "online"; unread = 3 };
{ name = "李四"; sign = "正在开会,请留言..."; avatar = bmpB; status = "offline"; unread = 0 };
{ name = "王五"; sign = "平凡的世界,不平凡的人生"; avatar = bmpA; status = "online"; unread = 1 };
{ name = "赵六"; sign = "这是一段非常非常长的签名,用来测试文本截断功能是否正常工作。"; avatar = bmpB; status = "offline"; unread = 0 };
{ name = "Jacen He"; sign = "aardio 作者"; avatar = bmpB; status = "online"; unread = 0 };
{ name = "程序员 A"; sign = "Hello World"; avatar = bmpA; status = "online"; unread = 99 };
{ name = "产品经理"; sign = "这个需求很简单,明天上线"; avatar =bmpB; status = "offline"; unread = 0 };
};
for(i=1;20;1){
table.push(mockData,{
name = "好友 " + i;
sign = "批量生成的签名内容..." + i;
avatar = math.random(1,10)%2==0 ? bmpA : bmpB;
status = math.random(1,10)%2==0 ? "online" : "offline";
})
}
// 加载数据
userList.setData(mockData);
userList.onSelected = function(item){
winform.text = "当前选中: " + item.name;
// 这里可以执行其他逻辑,比如打开聊天窗口
}
userList.onDoubleClick = function(index, item){
win.msgbox("你点击的是:联系人 - " ++ item.name)
item.unread = 0; //去掉红点
winform.plusUserList.redraw();
}
winform.show();
win.loopMessage();