ColorPicker 用于选择主题色、标记色、字体色等。它支持预设色、清除、格式模式与弹出位置设置。
import win.ui;
import dotNet.AntdUI;
/*DSG{{*/
var winform = win.form(text="AntdUI ColorPicker";right=446;bottom=160)
winform.add(
host={cls="custom";left=2;top=38;right=234;bottom=90;z=1}
)
/*}}*/
//这个控件的宽高设置变化有可能会导致排版混乱
var picker = AntdUI.ColorPicker(winform.host);
picker.Text = "选择"; //太多字符会显示不全
picker.Value = 0xFFFF0000;
picker.AllowClear = true;
picker.ShowText = true;
picker.ShowSymbol = true;
picker.ValueChanged = function(sender,e){
winform.text = "颜色已改变";
}
//增加预设颜色,0xAARRGGBB 格式数值会自动转换为 System.Drawing.Color
picker.Presets = [0xffffff00,0xffff00ff]
winform.show();
win.loopMessage();
Value:当前颜色;aardio 中读取为 0xAARRGGBB 数值,赋值也直接使用该格式。Text:显示文本。AllowClear:允许清除。ShowText:显示文本。ShowSymbol:显示颜色符号。Mode:颜色格式模式。Presets:预设颜色数组。Placement、Trigger:弹出位置与触发方式。ValueChanged、ValueFormatChanged:颜色/格式变化事件。System.Drawing.Color 在 aardio 中就是 0xAARRGGBB 数值,读取与赋值都直接使用该格式;不需要调用 System.Drawing.Color.FromArgb(...)。不要与普通 GDI COLORREF 的 0xBBGGRR 混用。