第 0 阶段:教材项目 2 任务 1 在网页中原样运行
- runtime:仿真 WinForms 子集(Form、Button、Label、TextBox、ComboBox、 GroupBox、Timer、MessageBox、界面线程消息循环、跨线程检查)、 教材设备类库(DeviceCtrlHelper、LED 控件)、运行器(常驻编译服务 + 运行模式) - server:Bun + Hono,WebSocket 会话,每次运行一个进程,消息转发 - web:Vue + Naive UI,WinForms 风格窗体渲染、MessageBox、实训台 LED 屏 - 端到端测试与 100 个程序并发的压力测试 - 教材逐任务摘要(docs/教材摘要) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
98be8331bc
71 files changed
+7919
No files matched your search
@@ -0,0 +1,45 @@
|
||||
using System.Text.Json.Nodes;
|
||||
using Sim.Host;
|
||||
|
||||
namespace System.Windows.Forms;
|
||||
|
||||
/// <summary>在浏览器里弹出对话框,阻塞到用户点击按钮后返回结果(期间界面线程照常处理 Timer 等消息)</summary>
|
||||
public static class MessageBox
|
||||
{
|
||||
public static DialogResult Show(string? text) => Show(text, "");
|
||||
|
||||
public static DialogResult Show(string? text, string? caption) =>
|
||||
Show(text, caption, MessageBoxButtons.OK, MessageBoxIcon.None);
|
||||
|
||||
public static DialogResult Show(string? text, string? caption, MessageBoxButtons buttons) =>
|
||||
Show(text, caption, buttons, MessageBoxIcon.None);
|
||||
|
||||
public static DialogResult Show(string? text, string? caption, MessageBoxButtons buttons, MessageBoxIcon icon) =>
|
||||
ShowCore(text, caption, buttons, icon);
|
||||
|
||||
public static DialogResult Show(string? text, string? caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton) =>
|
||||
ShowCore(text, caption, buttons, icon);
|
||||
|
||||
public static DialogResult Show(IWin32Window? owner, string? text) => Show(text);
|
||||
|
||||
public static DialogResult Show(IWin32Window? owner, string? text, string? caption) => Show(text, caption);
|
||||
|
||||
public static DialogResult Show(IWin32Window? owner, string? text, string? caption, MessageBoxButtons buttons) =>
|
||||
Show(text, caption, buttons);
|
||||
|
||||
public static DialogResult Show(IWin32Window? owner, string? text, string? caption, MessageBoxButtons buttons, MessageBoxIcon icon) =>
|
||||
Show(text, caption, buttons, icon);
|
||||
|
||||
private static DialogResult ShowCore(string? text, string? caption, MessageBoxButtons buttons, MessageBoxIcon icon)
|
||||
{
|
||||
var reply = SimHost.Request(new JsonObject
|
||||
{
|
||||
["type"] = "messageBox",
|
||||
["text"] = text ?? "",
|
||||
["caption"] = caption ?? "",
|
||||
["buttons"] = buttons.ToString(),
|
||||
["icon"] = icon.ToString(),
|
||||
});
|
||||
return Enum.TryParse<DialogResult>((string?)reply, out var result) ? result : DialogResult.Cancel;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user