Drawer 是从窗口边缘滑出的浮层面板,适合承载详情页、筛选面板、设置面板和临时表单。与 Modal 不同,Drawer 更像侧边面板,可从上下左右弹出。
当前 DLL 的 Drawer 是静态类,常用 AntdUI.Drawer.open(form, content, align) 或 AntdUI.Drawer.open(config)。
import win.ui;
import dotNet;
import dotNet.AntdUI;
import System.Windows.Forms;
import System.Drawing;
var winform = win.form(text="AntdUI Drawer";right=720;bottom=420)
winform.add(
customBase={cls="custom";left=0;top=0;right=720;bottom=420;z=1};
btn={cls="button";text="打开抽屉";left=40;top=40;right=180;bottom=76;z=2}
)
var baseForm = AntdUI.BaseForm(winform.customBase);
winform.btn.oncommand = function(){
var panel = System.Windows.Forms.Panel();
panel.Size = System.Drawing.Size(360,260);
var title = System.Windows.Forms.Label();
title.Text = "抽屉内容,可放表单、列表或设置项";
title.Dock = System.Windows.Forms.DockStyle.Top;
panel.Controls.Add(title);
var cfg = AntdUI.Drawer.Config(baseForm,panel);
cfg.Align = AntdUI.TAlignMini.Right;
cfg.Padding = 24;
cfg.Mask = true;
AntdUI.Drawer.open(cfg);
}
winform.show();
win.loopMessage();
Form:所属 WinForms 窗口,aardio 中推荐传 AntdUI.BaseForm。Content:要显示的 WinForms/AntdUI 控件。Align:方向,AntdUI.TAlignMini.Right/Left/Top/Bottom。Padding:内容边距。Mask:是否显示遮罩。MaskClosable:点击遮罩是否关闭。ManualActivateParent:关闭后是否手动激活父窗口。Dispose:关闭时是否释放内容控件。OnLoad / OnClose:加载与关闭回调。DisplayDelay:显示延迟,用于避免与遮罩动画抢占。var cfg = AntdUI.Drawer.Config(baseForm,panel);
cfg.Align = AntdUI.TAlignMini.Left;
cfg.Padding = 16;
cfg.MaskClosable = true;
AntdUI.Drawer.open(cfg);
常用方向:
AntdUI.TAlignMini.Right:右侧滑出,默认。AntdUI.TAlignMini.Left:左侧滑出。AntdUI.TAlignMini.Top:顶部滑出。AntdUI.TAlignMini.Bottom:底部滑出。如果不需要额外配置,可直接调用:
AntdUI.Drawer.open(baseForm,panel,AntdUI.TAlignMini.Right);
Drawer 的内容必须是 .NET System.Windows.Forms.Control。常见做法:
System.Windows.Forms.Panel() 作为容器,再往里添加 Label、Button、TextBox 等控件。Size,否则抽屉可能过小或布局不符合预期。cfg.Dispose = false;默认关闭时会释放内容。panel,避免把控件创建逻辑堆在按钮事件里。