[AntdUI] 02 Button按钮控件的创建

nanyi 11小时前 55 v 1.0.0.0 2026-06-05


一、缘起

之前开篇BaseForm没唠过为啥写aardio调用AntdUI 界面库,这篇来简单唠几句,加入AntdUI官方Q群已经是2024年底的事情了,当时被这个界面库的设计及丰富的控件类所吸引,但能力有限,一直没有完成aardio调用AntdUI界面库例子。后来在群里和公众号[Auto编程]看到过风行者封装的AntdUI的演示案例exe(但貌似没开源?不确定),还是不了了之。直到前几天 kio 同学发了一篇 简单调用AntdUI组件,演示了按钮、滚动警示、多选框等控件,感觉aardio调用AntdUI可以做到如此的优雅和简洁,瞬间原来的那种兴趣又回来了。更妙的是,后来发现原来在2026年年初,AntdUI已经加入了aardio扩展库这个大家庭,并且有了几个演示示例,那还有啥好说的,直接开动吧!

二、Button

Button是winform程序开发中最基础的交互控件之一,“确定”,“取消”,“下一步”,“提交”,在没有触屏交互前,基本上程序的交互逻辑都绕不开Button,但winform的按钮都是一个样式。你面前的两个按钮可能是反向逻辑,但他显示的样式就是一样的。AntdUI界面库基于Ant Design 的设计语言,让Button样式更丰富了,也更统一了,通过配置Button的Type属性,一句代码搞定Button样式的变换。

btnPrimary.Type = AntdUI.TTypeMini.Primary;

TTypeMini

类型

名称

描述

Default

默认

Primary

主要

Success

成功

Error

错误

Warn

警告

Info

信息

当然,Button最重要的是点击事件,那么如何在aardio中捕获AntdUI Button的点击事件呢,Button.Click,然后写点击事件的逻辑代码。也是如此的轻松和简单。

btnSuccess.Click = function(s,e){
   AntdUI.Message.success(baseForm, "This is a success message.");
};

一个aardio创建AntdUI Button和点击响应只需要5句代码就能搞定。

var btnSuccess = AntdUI.Button(winform.custom_btn_success);
btnSuccess.Text = "Success";
btnSuccess.Type = AntdUI.TTypeMini.Success;
btnSuccess.Click = function(s,e){
   AntdUI.Message.success(baseForm, "This is a success message.");
};

三、关于这个Button的演示案例

这个代码例子主要是演示了在aardio中AntdUI Button创建、不同Type样式按钮的展示,以及一些按钮扩展的属性,比如图标按钮、加载状态的按钮、组合按钮等,让大家可以基于自己的需求来创建更丰富的界面,抛弃自己重复去写繁杂的一些操作逻辑和显示。

当然除了按钮的样式外,我还为每组按钮增添了常用的与按钮交互配合的提示消息,并且反馈消息均采用AntdUI内置的匹配的消息样式,比如Modal对话框、Message 全局提示、Notification通知提醒框,不得不说,AntdUI真的很全面,AA+GPT5.5的组合让Code更快,更好。

import win.ui;
import dotNet.AntdUI;
import dotNet;

/*DSG{{*/
var winform = win.form(text="AntdUI Button";right=800;bottom=760;border="thin")
winform.add(
custom_base={cls="custom";left=1;top=2;right=801;bottom=761;ah=1;aw=1;db=1;disabled=1;dl=1;dr=1;dt=1;hide=1;z=1};
custom_btn_default={cls="custom";left=25;top=137;right=115;bottom=177;dl=1;dt=1;z=2};
custom_btn_disabled={cls="custom";left=640;top=137;right=730;bottom=177;dl=1;dt=1;z=8};
custom_btn_error={cls="custom";left=538;top=137;right=628;bottom=177;dl=1;dt=1;z=7};
custom_btn_info={cls="custom";left=333;top=137;right=423;bottom=177;dl=1;dt=1;z=5};
custom_btn_primary={cls="custom";left=128;top=137;right=218;bottom=177;dl=1;dt=1;z=3};
custom_btn_success={cls="custom";left=230;top=137;right=320;bottom=177;dl=1;dt=1;z=4};
custom_btn_warn={cls="custom";left=435;top=137;right=525;bottom=177;dl=1;dt=1;z=6};
custom_circle1={cls="custom";left=275;top=531;right=315;bottom=571;dl=1;dt=1;z=25};
custom_circle2={cls="custom";left=330;top=531;right=370;bottom=571;dl=1;dt=1;z=26};
custom_circle3={cls="custom";left=385;top=531;right=425;bottom=571;dl=1;dt=1;z=27};
custom_dashed_default={cls="custom";left=25;top=237;right=115;bottom=277;dl=1;dt=1;z=9};
custom_dashed_error={cls="custom";left=538;top=237;right=628;bottom=277;dl=1;dt=1;z=14};
custom_dashed_info={cls="custom";left=333;top=237;right=423;bottom=277;dl=1;dt=1;z=12};
custom_dashed_primary={cls="custom";left=128;top=237;right=218;bottom=277;dl=1;dt=1;z=10};
custom_dashed_success={cls="custom";left=230;top=237;right=320;bottom=277;dl=1;dt=1;z=11};
custom_dashed_warn={cls="custom";left=435;top=237;right=525;bottom=277;dl=1;dt=1;z=13};
custom_desc={cls="custom";left=25;top=51;right=785;bottom=92;dl=1;dt=1;z=46};
custom_ghost_default={cls="custom";left=25;top=337;right=115;bottom=377;dl=1;dt=1;z=15};
custom_ghost_error={cls="custom";left=538;top=337;right=628;bottom=377;dl=1;dt=1;z=20};
custom_ghost_info={cls="custom";left=333;top=337;right=423;bottom=377;dl=1;dt=1;z=18};
custom_ghost_primary={cls="custom";left=128;top=337;right=218;bottom=377;dl=1;dt=1;z=16};
custom_ghost_success={cls="custom";left=230;top=337;right=320;bottom=377;dl=1;dt=1;z=17};
custom_ghost_warn={cls="custom";left=435;top=337;right=525;bottom=377;dl=1;dt=1;z=19};
custom_gradient={cls="custom";left=400;top=431;right=540;bottom=471;dl=1;dt=1;z=45};
custom_group1={cls="custom";left=26;top=631;right=86;bottom=671;dl=1;dt=1;z=29};
custom_group2={cls="custom";left=86;top=631;right=146;bottom=671;dl=1;dt=1;z=30};
custom_group3={cls="custom";left=146;top=631;right=206;bottom=671;dl=1;dt=1;z=31};
custom_join_del={cls="custom";left=463;top=631;right=545;bottom=671;dl=1;dt=1;z=44};
custom_join_edit={cls="custom";left=421;top=631;right=463;bottom=671;dl=1;dt=1;z=43};
custom_join_left={cls="custom";left=227;top=631;right=287;bottom=671;dl=1;dt=1;z=39};
custom_join_mid={cls="custom";left=281;top=631;right=341;bottom=671;dl=1;dt=1;z=40};
custom_join_right={cls="custom";left=335;top=631;right=395;bottom=671;dl=1;dt=1;z=41};
custom_lbl_basic={cls="custom";left=25;top=107;right=205;bottom=132;dl=1;dt=1;z=32};
custom_lbl_dashed={cls="custom";left=25;top=207;right=355;bottom=232;dl=1;dt=1;z=38};
custom_lbl_ghost={cls="custom";left=25;top=307;right=205;bottom=332;dl=1;dt=1;z=37};
custom_lbl_group={cls="custom";left=25;top=601;right=205;bottom=626;dl=1;dt=1;z=36};
custom_lbl_icon={cls="custom";left=25;top=501;right=205;bottom=526;dl=1;dt=1;z=33};
custom_lbl_state={cls="custom";left=25;top=401;right=205;bottom=426;dl=1;dt=1;z=34};
custom_load_toggle={cls="custom";left=277;top=431;right=387;bottom=471;dl=1;dt=1;z=42};
custom_loading={cls="custom";left=25;top=431;right=135;bottom=471;dl=1;dt=1;z=21};
custom_round1={cls="custom";left=440;top=532;right=541;bottom=572;dl=1;dt=1;z=28};
custom_search={cls="custom";left=25;top=531;right=135;bottom=571;dl=1;dt=1;z=23};
custom_star={cls="custom";left=150;top=531;right=260;bottom=571;dl=1;dt=1;z=24};
custom_title={cls="custom";left=24;top=18;right=200;bottom=40;dl=1;dt=1;z=35};
custom_wave={cls="custom";left=150;top=431;right=260;bottom=471;dl=1;dt=1;z=22}
)
/*}}*/

// ---------- 1. Create embedded AntdUI container ----------
var baseForm = AntdUI.BaseForm();
baseForm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
baseForm.Dock = System.Windows.Forms.DockStyle.Fill;
dotNet.setParent(baseForm, winform.custom_base);

// ---------- 2. Labels (Title, Description, Group Headers) ----------
var lblTitle = AntdUI.Label(winform.custom_title);
lblTitle.Text = "Button";
lblTitle.Font = System.Drawing.Font("Microsoft YaHei", 18, System.Drawing.FontStyle.Bold);

var lblDesc = AntdUI.Label(winform.custom_desc);
lblDesc.Text = "Buttons are used for actions and links. There are multiple types of buttons including basic, dashed, ghost, loading, icon, shape, and groups.";
lblDesc.Font = System.Drawing.Font("Microsoft YaHei", 9);

var lblBasic = AntdUI.Label(winform.custom_lbl_basic);
lblBasic.Text = "Basic buttons";
lblBasic.Font = System.Drawing.Font("Microsoft YaHei", 11, System.Drawing.FontStyle.Bold);

var lblDashed = AntdUI.Label(winform.custom_lbl_dashed);
lblDashed.Text = "Ghost with border";
lblDashed.Font = System.Drawing.Font("Microsoft YaHei", 11, System.Drawing.FontStyle.Bold);

var lblGhost = AntdUI.Label(winform.custom_lbl_ghost);
lblGhost.Text = "Ghost buttons";
lblGhost.Font = System.Drawing.Font("Microsoft YaHei", 11, System.Drawing.FontStyle.Bold);

var lblState = AntdUI.Label(winform.custom_lbl_state);
lblState.Text = "Loading buttons";
lblState.Font =System.Drawing.Font("Microsoft YaHei", 11, System.Drawing.FontStyle.Bold);

var lblIcon = AntdUI.Label(winform.custom_lbl_icon);
lblIcon.Text = "Icon & Shape buttons";
lblIcon.Font =System.Drawing.Font("Microsoft YaHei", 11, System.Drawing.FontStyle.Bold);

var lblGroup = AntdUI.Label(winform.custom_lbl_group);
lblGroup.Text = "Button groups";
lblGroup.Font = System.Drawing.Font("Microsoft YaHei", 11, System.Drawing.FontStyle.Bold);

// ---------- 3. Basic Buttons (with click events) ----------
var btnDefault = AntdUI.Button(winform.custom_btn_default);
btnDefault.Text = "Default";
btnDefault.Type = AntdUI.TTypeMini.Default;
btnDefault.Font = System.Drawing.Font("Tahoma", 8);
btnDefault.Click = function(s,e){
    AntdUI.Modal.open(baseForm, "Info", "You clicked the Default button.", AntdUI.TType.Success);
};

var btnPrimary = AntdUI.Button(winform.custom_btn_primary);
btnPrimary.Text = "Primary";
btnPrimary.Type = AntdUI.TTypeMini.Primary;
btnPrimary.Click = function(s,e){
    var modalCfg = AntdUI.Modal.Config(baseForm, "Confirm Action", "Do you want to proceed?");
    modalCfg.Mask = false;
    modalCfg.OkText = "Confirm";
    modalCfg.Icon = AntdUI.TType.Info;
    modalCfg.OnOk = function(modalCfg) {
        AntdUI.Message.success(baseForm, "User confirmed the action.");
        return true;
    };
    AntdUI.Modal.open(modalCfg);
};

var btnSuccess = AntdUI.Button(winform.custom_btn_success);
btnSuccess.Text = "Success";
btnSuccess.Type = AntdUI.TTypeMini.Success;
btnSuccess.Click = function(s,e){
    AntdUI.Message.success(baseForm, "This is a success message.");
};

var btnInfo = AntdUI.Button(winform.custom_btn_info);
btnInfo.Text = "Info";
btnInfo.Type = AntdUI.TTypeMini.Info;
btnInfo.Click = function(s,e){
    AntdUI.Message.info(baseForm, "This is an info message.");
};

var btnWarn = AntdUI.Button(winform.custom_btn_warn);
btnWarn.Text = "Warn";
btnWarn.Type = AntdUI.TTypeMini.Warn;
btnWarn.Click = function(s,e){
    AntdUI.Message.warn(baseForm, "This is a warning message.");
};

var btnError = AntdUI.Button(winform.custom_btn_error);
btnError.Text = "Error";
btnError.Type = AntdUI.TTypeMini.Error;
btnError.Click = function(s,e){
    AntdUI.Message.error(baseForm, "This is an error message.");
};

var btnDisabled = AntdUI.Button(winform.custom_btn_disabled);
btnDisabled.Text = "Disabled";
btnDisabled.Type = AntdUI.TTypeMini.Default;
btnDisabled.Enabled = false;

// ---------- 4. Ghost with Border Buttons (Notification examples) ----------
var dashedDefault = AntdUI.Button(winform.custom_dashed_default);
dashedDefault.Text = "Default";
dashedDefault.Type = AntdUI.TTypeMini.Default;
dashedDefault.WaveSize = 4;
dashedDefault.Ghost = true;
dashedDefault.BorderWidth = 2;
dashedDefault.Click = function(s,e){
    AntdUI.Notification.info(baseForm, "Notification Title", "This is the content of the notification. It can be multi-line.", AntdUI.TAlignFrom.Top);
};

var dashedPrimary = AntdUI.Button(winform.custom_dashed_primary);
dashedPrimary.Text = "Primary";
dashedPrimary.Type = AntdUI.TTypeMini.Primary;
dashedPrimary.WaveSize = 4;
dashedPrimary.Ghost = true;
dashedPrimary.BorderWidth = 2;
dashedPrimary.Click = function(s,e){
    var notificationCfg = AntdUI.Notification.Config(baseForm,"AntdUI","A Winforms UI library based on Ant Design.", AntdUI.TType.Info, AntdUI.TAlignFrom.BR);
    notificationCfg.SetLink("Visit AntdUI", function(){
        raw.execute("https://gitee.com/AntdUI");
        return true;
    });
    AntdUI.Notification.open(notificationCfg);
};

var dashedSuccess = AntdUI.Button(winform.custom_dashed_success);
dashedSuccess.Text = "Success";
dashedSuccess.Type = AntdUI.TTypeMini.Success;
dashedSuccess.WaveSize = 4;
dashedSuccess.Ghost = true;
dashedSuccess.BorderWidth = 2;
dashedSuccess.Click = function(s,e){
    AntdUI.Notification.success(baseForm, "Success", "Operation completed successfully.", AntdUI.TAlignFrom.TR);
};

var dashedInfo = AntdUI.Button(winform.custom_dashed_info);
dashedInfo.Text = "Info";
dashedInfo.Type = AntdUI.TTypeMini.Info;
dashedInfo.WaveSize = 4;
dashedInfo.Ghost = true;
dashedInfo.BorderWidth = 2;
dashedInfo.Click = function(s,e){
    AntdUI.Notification.info(baseForm, "Information", "Additional information here.", AntdUI.TAlignFrom.TR);
};

var dashedWarn = AntdUI.Button(winform.custom_dashed_warn);
dashedWarn.Text = "Warn";
dashedWarn.Type = AntdUI.TTypeMini.Warn;
dashedWarn.WaveSize = 4;
dashedWarn.Ghost = true;
dashedWarn.BorderWidth = 2;
dashedWarn.Click = function(s,e){
    AntdUI.Notification.warn(baseForm, "Warning", "Please check your input.", AntdUI.TAlignFrom.TR);
};

var dashedError = AntdUI.Button(winform.custom_dashed_error);
dashedError.Text = "Error";
dashedError.Type = AntdUI.TTypeMini.Error;
dashedError.WaveSize = 4;
dashedError.Ghost = true;
dashedError.BorderWidth = 2;
dashedError.Click = function(s,e){
    AntdUI.Notification.error(baseForm, "Error", "Something went wrong.", AntdUI.TAlignFrom.TR);
};

// ---------- 5. Ghost Buttons (with tooltips, no default click) ----------
var tipComp = AntdUI.TooltipComponent();
tipComp.Delay = 300;
tipComp.ArrowAlign = AntdUI.TAlign.Top;

var ghostDefault = AntdUI.Button(winform.custom_ghost_default);
ghostDefault.Text = "Default";
ghostDefault.Type = AntdUI.TTypeMini.Default;
ghostDefault.Ghost = true;
tipComp.SetTip(ghostDefault, "Default ghost button");

var ghostPrimary = AntdUI.Button(winform.custom_ghost_primary);
ghostPrimary.Text = "Primary";
ghostPrimary.Type = AntdUI.TTypeMini.Primary;
ghostPrimary.Ghost = true;
tipComp.SetTip(ghostPrimary, "Primary ghost button");

var ghostSuccess = AntdUI.Button(winform.custom_ghost_success);
ghostSuccess.Text = "Success";
ghostSuccess.Type = AntdUI.TTypeMini.Success;
ghostSuccess.Ghost = true;
tipComp.SetTip(ghostSuccess, "Success ghost button");

var ghostInfo = AntdUI.Button(winform.custom_ghost_info);
ghostInfo.Text = "Info";
ghostInfo.Type = AntdUI.TTypeMini.Info;
ghostInfo.Ghost = true;
tipComp.SetTip(ghostInfo, "Info ghost button");

var ghostWarn = AntdUI.Button(winform.custom_ghost_warn);
ghostWarn.Text = "Warn";
ghostWarn.Type = AntdUI.TTypeMini.Warn;
ghostWarn.Ghost = true;
tipComp.SetTip(ghostWarn, "Warning ghost button");

var ghostError = AntdUI.Button(winform.custom_ghost_error);
ghostError.Text = "Error";
ghostError.Type = AntdUI.TTypeMini.Error;
ghostError.Ghost = true;
tipComp.SetTip(ghostError, "Error ghost button");

// ---------- 6. Loading Animation Buttons ----------
var btnLoading = AntdUI.Button(winform.custom_loading);
btnLoading.Text = "Loading";
btnLoading.Type = AntdUI.TTypeMini.Primary;
btnLoading.Loading = true;

var btnWave = AntdUI.Button(winform.custom_wave);
btnWave.Text = "Progress";
btnWave.Type = AntdUI.TTypeMini.Primary;
btnWave.Loading = true;
btnWave.LoadingWaveValue = 0.2;
btnWave.LoadingWaveColor = System.Drawing.Color.FromArgb(255, 250, 140, 22);
btnWave.LoadingWaveSize = 4;
btnWave.LoadingWaveCount = 1;
btnWave.LoadingWaveVertical = false;
btnWave.LoadingRespondClick = false;

// Timer for progress wave animation
var waveTimer = winform.setInterval(
    function() {
        if (btnWave.LoadingWaveValue >= 0.85) {
            winform.clearInterval(waveTimer);
            return;
        }
        btnWave.LoadingWaveValue = btnWave.LoadingWaveValue + 0.01;
    }, 60
);

// Toggle loading button
var btnLoadToggle = AntdUI.Button(winform.custom_load_toggle);
btnLoadToggle.Text = "Click Me";
btnLoadToggle.Type = AntdUI.TTypeMini.Primary;
btnLoadToggle.Click = function(s, e){
    s.Loading = true;
    s.Text = "Loading...";
    winform.setTimeout(function(){
        s.Loading = false;
        s.Text = "Done!";
        AntdUI.Message.success(baseForm, "Loading finished.");
    }, 3000);
};

// Gradient button
var btnGradient = AntdUI.Button(winform.custom_gradient);
btnGradient.Text = "Gradient";
btnGradient.Type = AntdUI.TTypeMini.Primary;
btnGradient.Font = System.Drawing.Font("Tahoma", 9, System.Drawing.FontStyle.Bold);
btnGradient.ForeColor = System.Drawing.Color.White;
btnGradient.WaveSize = 4;

// BackExtend 渐变色:角度,颜色1,颜色2,颜色3...
btnGradient.BackExtend = "90deg,#1677FF,#722ED1";

// 悬停/按下时用半透明叠加色,否则默认 hover 颜色可能覆盖渐变效果。
btnGradient.BackHover = System.Drawing.Color.FromArgb(45,255,255,255);
btnGradient.BackActive = System.Drawing.Color.FromArgb(70,0,0,0);

btnGradient.Click = function(s,e){
    AntdUI.Message.success(baseForm, "Gradient button clicked.");
    s.Loading = true;
};


// ---------- 7. Icon and Shape Buttons ----------
var btnSearch = AntdUI.Button(winform.custom_search);
btnSearch.Text = "🔍 Search";
btnSearch.Type = AntdUI.TTypeMini.Default;

var btnStar = AntdUI.Button(winform.custom_star);
btnStar.Text = "⭐ Star";
btnStar.Type = AntdUI.TTypeMini.Primary;

// Shape: Circle with toggle SVG
var starSvg='<svg t="1780011187808" class="icon" viewBox="0 0 1058 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6196" width="32" height="32"><path d="M242.036364 1014.690909c-6.206061 0-12.412121 0-18.618182-3.10303-15.515152-6.206061-27.927273-15.515152-37.236364-31.030303-6.206061-12.412121-9.309091-24.824242-6.20606-40.339394L229.624242 651.636364 21.721212 446.836364c-24.824242-24.824242-24.824242-62.060606 0-86.884849 9.309091-9.309091 21.721212-15.515152 34.133333-18.618182l288.581819-43.442424 130.327272-260.654545c6.206061-15.515152 18.618182-24.824242 37.236364-31.030303 15.515152-6.206061 31.030303-3.10303 46.545455 3.10303 12.412121 6.206061 21.721212 15.515152 27.927272 27.927273l130.327273 260.654545 288.581818 43.442424c34.133333 6.206061 55.854545 37.236364 52.751515 71.369697-3.10303 12.412121-9.309091 24.824242-18.618181 34.133334L831.612121 651.636364l49.648485 288.581818c3.10303 15.515152 0 34.133333-9.309091 46.545454s-24.824242 21.721212-40.339394 24.824243c-12.412121 3.10303-27.927273 0-40.339394-6.206061L527.515152 871.951515l-257.551516 136.533333c-9.309091 6.206061-18.618182 6.206061-27.927272 6.206061zM527.515152 71.369697l-142.739394 291.684848L62.060606 406.49697l232.727273 226.521212-55.854546 319.612121 288.581819-152.048485 288.581818 152.048485-55.854546-319.612121 232.727273-226.521212-319.612121-46.545455L527.515152 71.369697z" fill="#FFFFFF" p-id="6197"></path></svg>'
var starToggleSvg='<svg t="1780011216049" class="icon" viewBox="0 0 1025 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6361" width="32" height="32"><path d="M778.479 1002.496c-12.288 0-24.576-3.071-37.888-10.239L533.742 883.713c-5.12-3.072-12.288-5.12-20.479-5.12-7.168 0-15.36 2.048-20.48 4.096L286.959 992.257c-12.288 7.168-24.576 10.239-38.912 10.239-24.576 0-48.128-11.264-64.513-29.695-16.384-18.433-22.527-43.008-18.432-67.584l39.937-229.376c2.048-14.336-3.072-28.672-13.313-38.912L25.839 476.16C2.287 453.633-5.905 420.864 4.335 390.144c10.239-30.721 35.84-52.225 67.584-57.345l229.376-33.792c14.336-2.048 27.647-11.264 33.791-23.552l102.4-208.896c14.336-28.672 43.008-46.08 74.752-46.08s60.416 17.408 74.752 46.08l102.4 208.896c7.168 13.313 19.456 21.504 33.792 23.552L952.559 332.8c31.744 5.12 57.344 26.624 67.584 56.32 10.24 30.72 2.048 63.488-20.48 86.017L834.799 636.928c-11.265 10.24-15.36 24.576-13.313 38.912l38.912 228.352c4.096 24.576-2.048 49.152-18.432 67.584C826.607 991.232 803.055 1002.496 778.479 1002.496z" fill="#FFFFFF" p-id="6362"></path></svg>'
var circle1 = AntdUI.Button(winform.custom_circle1);
circle1.Text = "";
circle1.Type = AntdUI.TTypeMini.Primary;
circle1.Shape = AntdUI.TShape.Circle;
circle1.IconSvg = starSvg;
circle1.AutoToggle = true;
circle1.ToggleIconSvg = starToggleSvg;
circle1.Click = function(s,e){
    AntdUI.Message.success(baseForm, "Favorited!");
};

var circle2 = AntdUI.Button(winform.custom_circle2);
circle2.Text = "🔍";
circle2.Type = AntdUI.TTypeMini.Default;
circle2.Shape = AntdUI.TShape.Circle;

var heartSvg='<svg t="1780012228080" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="11561" width="32" height="32"><path d="M704 128C833.621333 128 938.666667 234.666667 938.666667 384c0 298.666667-320 469.333333-426.666667 533.333333C405.333333 853.333333 85.333333 682.666667 85.333333 384c0-149.333333 106.666667-256 234.666667-256C399.36 128 469.333333 170.666667 512 213.333333c42.666667-42.666667 112.64-85.333333 192-85.333333z m-152.149333 665.770667a1141.418667 1141.418667 0 0 0 103.253333-72.576C782.293333 620.074667 853.333333 509.568 853.333333 384c0-100.693333-65.578667-170.666667-149.333333-170.666667-45.909333 0-95.573333 24.32-131.669333 60.330667L512 333.994667l-60.330667-60.330667C415.573333 237.653333 365.909333 213.333333 320 213.333333 237.226667 213.333333 170.666667 283.989333 170.666667 384c0 125.610667 71.082667 236.074667 198.186667 337.194667 31.786667 25.301333 65.706667 48.896 103.296 72.533333 12.757333 8.064 25.386667 15.786667 39.850667 24.405333 14.464-8.618667 27.093333-16.341333 39.850667-24.362666z" fill="#ffffff" p-id="11562"></path></svg>'
var heartToggleSvg='<svg t="1780012279642" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="11828" width="32" height="32"><path d="M704 128C833.621333 128 938.666667 234.666667 938.666667 384c0 298.666667-320 469.333333-426.666667 533.333333C405.333333 853.333333 85.333333 682.666667 85.333333 384c0-149.333333 106.666667-256 234.666667-256C399.36 128 469.333333 170.666667 512 213.333333c42.666667-42.666667 112.64-85.333333 192-85.333333z" fill="#ffffff" p-id="11829"></path></svg>'
var circle3 = AntdUI.Button(winform.custom_circle3);
circle3.Text = '';
circle3.Type = AntdUI.TTypeMini.Error;
circle3.Shape = AntdUI.TShape.Circle;
circle3.IconSvg = heartSvg;
circle3.AutoToggle = true;
circle3.ToggleIconSvg = heartToggleSvg;
circle3.Click = function(s,e){
    AntdUI.Message.success(baseForm, "Thanks for liking!");
};

var round1 = AntdUI.Button(winform.custom_round1);
round1.Text = "♻ Round";
round1.Type = AntdUI.TTypeMini.Success;
round1.Shape = AntdUI.TShape.Round;

// ---------- 8. Button Groups (add Message prompts) ----------
var btnGroup1 = AntdUI.Button(winform.custom_group1);
btnGroup1.Text = "Left";
btnGroup1.Type = AntdUI.TTypeMini.Primary;
btnGroup1.JoinRight = true;
btnGroup1.Click = function(s,e){
    AntdUI.Message.info(baseForm, "Left button clicked.");
};

var btnGroup2 = AntdUI.Button(winform.custom_group2);
btnGroup2.Text = "Center";
btnGroup2.Type = AntdUI.TTypeMini.Primary;
btnGroup2.JoinLeft = true;
btnGroup2.JoinRight = true;
btnGroup2.Click = function(s,e){
    AntdUI.Message.info(baseForm, "Center button clicked.");
};

var btnGroup3 = AntdUI.Button(winform.custom_group3);
btnGroup3.Text = "Right";
btnGroup3.Type = AntdUI.TTypeMini.Primary;
btnGroup3.JoinLeft = true;
btnGroup3.Click = function(s,e){
    AntdUI.Message.info(baseForm, "Right button clicked.");
};

var btnJoinLeft = AntdUI.Button(winform.custom_join_left);
btnJoinLeft.Text = "Left";
btnJoinLeft.JoinRight = true;
btnJoinLeft.Click = function(s,e){
    AntdUI.Message.info(baseForm, "Join left button clicked.");
};

var btnJoinMid = AntdUI.Button(winform.custom_join_mid);
btnJoinMid.Text = "Center";
btnJoinMid.JoinLeft = true;
btnJoinMid.JoinRight = true;
btnJoinMid.Click = function(s,e){
    AntdUI.Message.info(baseForm, "Join center button clicked.");
};

var btnJoinRight = AntdUI.Button(winform.custom_join_right);
btnJoinRight.Text = "Right";
btnJoinRight.JoinLeft = true;
btnJoinRight.Click = function(s,e){
    AntdUI.Message.info(baseForm, "Join right button clicked.");
};

var searchSvg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="#1676FC" d="M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/></svg>`;
var btnJoinSearch = AntdUI.Button(winform.custom_join_edit);
btnJoinSearch.Type = AntdUI.TTypeMini.Primary;
btnJoinSearch.IconSvg = searchSvg;
btnJoinSearch.JoinRight = true;
btnJoinSearch.Ghost = true;
btnJoinSearch.BorderWidth = 2;
btnJoinSearch.IconRatio = 1.0;
btnJoinSearch.Click = function(s,e){
    AntdUI.Message.info(baseForm, "Search button clicked.");
};

var btnJoinDel = AntdUI.Button(winform.custom_join_del);
btnJoinDel.Text = "Delete";
btnJoinDel.Type = AntdUI.TTypeMini.Primary;
btnJoinDel.JoinLeft = true;
btnJoinDel.Ghost = true;
btnJoinDel.BorderWidth = 2;
btnJoinDel.Click = function(s,e){
    AntdUI.Message.info(baseForm, "Delete button clicked.");
};

// ---------- 9. Cleanup timer on window close ----------
winform.onClose = function(hwnd,message,wParam,lParam){
    winform.clearInterval(waveTimer);
    return true; // allow close
};

// ---------- 10. Show the window ----------
winform.show();
win.loopMessage();


下一篇预告:AntdUI Input控件


最新回复 (4)
  • mfk 10小时前
    0 2

  • cyzn_lfss 9小时前
    0 3

  • ccbwx 6小时前
    0 4
    辛苦了
  • 光庆 5小时前
    0 5

返回