aardio 文档

静态弹层组件

AntdUI 中很多反馈/弹层不是普通控件,而是静态类方法:MessageNotificationModalDrawerPopoverTooltipTourPreview。它们通常通过 open(...)success/info/warn/error(...) 方法弹出。

owner:在 aardio 中优先使用 BaseForm

静态弹层需要一个 AntdUI 可识别的所有者窗口。推荐在 aardio 窗口里放一个 custom 宿主,然后创建并嵌入 AntdUI.BaseForm,再把这个 baseForm 传给 Message.ConfigNotification.ConfigModal.ConfigDrawer.Config 等。

import win.ui;
import dotNet;
import dotNet.AntdUI;
import System.Windows.Forms;
/*DSG{{*/
var winform = win.form(text="AntdUI 弹层";right=620;bottom=360)
winform.add(
btn={cls="button";text="提示";left=40;top=40;right=180;bottom=76;z=2};
customBase={cls="custom";left=40;top=316;right=337;bottom=344;hide=1;z=1}
)
/*}}*/

// 构造一个 AntdUI / WinForms 所有者窗口(可设为隐藏不显示),供静态弹层定位与挂载。
var baseForm = AntdUI.BaseForm(winform.customBase);

winform.btn.oncommand = function(){
    var cfg = AntdUI.Message.Config(baseForm,"保存成功",AntdUI.TType.Success);
    cfg.AutoClose = 3;
    cfg.Align = AntdUI.TAlignFrom.Top;
    AntdUI.Message.open(cfg);
}

winform.show();
win.loopMessage();

BaseForm 本质上是 .NET System.Windows.Forms.Form,符合 AntdUI 静态弹层的 owner/target 需求;普通 aardio win.form 或窗口句柄不等价于 AntdUI 期望的 WinForms Form

Message 全局提示

适合短反馈:保存成功、删除失败、加载中。

常用方法:

常用配置字段:TargetTextIconAutoCloseClickCloseTopMostAlignShowInWindowMaxWidth

Notification 通知提醒

适合更明显的通知卡片,可包含标题、正文、状态图标、关闭按钮与链接操作。

var cfg = AntdUI.Notification.Config(baseForm,"任务完成","文件已导出。",AntdUI.TType.Success,AntdUI.TAlignFrom.TR);
cfg.AutoClose = 5;
cfg.ShowInWindow = true;
AntdUI.Notification.open(cfg);

常用配置字段:IDTitleTextIconAlignRadiusAutoCloseClickCloseCloseIconShowInWindowEnableSoundOnClose

Modal 模态对话框

适合需要用户确认的场景:删除确认、提交前确认、展示复杂内容。

var cfg = AntdUI.Modal.Config(baseForm,"删除确认","确定删除这条记录吗?",AntdUI.TType.Warn);
cfg.OkText = "删除";
cfg.CancelText = "取消";
cfg.MaskClosable = false;
var result = AntdUI.Modal.open(cfg);

常用配置字段:TitleContentIconWidthMaskMaskClosableCloseIconKeyboardOkTextCancelTextOkTypeOnOkBtnsOnBtnsResizable

复杂内容可传入 System.Windows.Forms.ControlModal.TextLine[]

Drawer 抽屉

适合从侧边滑出的表单、详情页、设置面板。

import System.Windows.Forms;
import System.Drawing;

var panel = System.Windows.Forms.Panel();
panel.Size = System.Drawing.Size(360,240);

var cfg = AntdUI.Drawer.Config(baseForm,panel);
cfg.Align = AntdUI.TAlignMini.Right;
cfg.Padding = 24;
AntdUI.Drawer.open(cfg);

常用配置字段:FormContentAlignPaddingMaskMaskClosableDisposeOnLoadOnCloseDisplayDelay

Popover 气泡卡片

Popover 依附在某个 WinForms/AntdUI 控件上,适合显示轻量详情、操作说明或短操作入口。

var cfg = AntdUI.Popover.Config(btn,"订单提醒","您有 3 条待处理订单。");
cfg.SetArrow(AntdUI.TAlign.Bottom).SetAutoClose(0).SetPadding(16,12);
AntdUI.Popover.open(cfg);

Content 可为字符串、WinForms 控件或 Popover.TextRow[]。多段文本示例:

import dotNet;
import System.Drawing;

var rows = dotNet.createArray(AntdUI.Popover.TextRow,2);
rows.SetValue(AntdUI.Popover.TextRow("查看"),0);
rows.SetValue(AntdUI.Popover.TextRow("详情",2,0xFF0000FF),1);
AntdUI.Popover.open(btn,rows,AntdUI.TAlign.BL);

常见注意点:目标必须是 WinForms/AntdUI 控件,普通 aardio 按钮不能直接作为 Popover 目标。

Tooltip 文字提示

Tooltip 用于非常短的解释性文字,可直接打开,也可用配置对象控制宽度、圆角、箭头和颜色。

var cfg = AntdUI.Tooltip.Config(btn,"这是一个文字提示");
cfg.SetArrow(AntdUI.TAlign.Top).SetRadius(8).SetCustomWidth(180);
AntdUI.Tooltip.open(cfg);

如果需要标题、复杂内容或可点击内容,请改用 Popover

Preview / ImagePreview 图片预览

import System.Drawing;

var image = System.Drawing.Bitmap(160,90);
var cfg = AntdUI.Preview.Config(baseForm,image);
cfg.SetFit(AntdUI.TFit.Contain).SetKeyboard(true);
AntdUI.Preview.open(cfg);

Preview.Config 的 owner 是 WinForms Form,在 aardio 中仍建议使用 AntdUI.BaseForm

Tour 漫游式引导

Tour 用于分步骤引导用户认识界面。每一步由 StepCall 回调决定要高亮的控件或区域。

var cfg = AntdUI.Tour.Config(baseForm,function(result){
    if(result.Index == 0){
        result.Set(btn);
    }
    else {
        result.Close();
    }
});
cfg.SetScale(1.08).SetMaskClosable(true).SetClickNext(true);
AntdUI.Tour.open(cfg);

常见注意点:baseForm 必须是 WinForms Formresult.Set(control) 的 control 也必须是 WinForms/AntdUI 控件。

通用建议

  1. 优先配置对象:字段名比长参数列表更稳定,也更适合 aardio 调用。
  2. 绑定 BaseForm:在 aardio 中用嵌入的 AntdUI.BaseForm 作为 owner。
  3. 避免跨线程直接操作 UI:工作线程完成后,把结果切回 UI 线程再弹提示。
  4. 长耗时任务用 loading:完成后调用返回对象的 OK/Error/Warn/Info 或关闭方法。
  5. 版本差异用反射确认:若示例参数不匹配,使用 aardio 反射脚本查看当前 DLL 的方法签名。

Markdown 格式