Files
xuyueandClaude Opus 5.5 98be8331bc 第 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>
2026-10-22 10:15:14 +08:00

48 lines
1.3 KiB
C#

using System.Drawing;
using System.Text.Json.Nodes;
using Sim.Host;
namespace System.Windows.Forms;
public abstract class ButtonBase : Control
{
private FlatStyle _flatStyle = FlatStyle.Standard;
public bool UseVisualStyleBackColor { get; set; } = true;
public bool UseMnemonic { get; set; } = true;
public ContentAlignment TextAlign { get; set; } = ContentAlignment.MiddleCenter;
public FlatStyle FlatStyle
{
get => _flatStyle;
set => SetProp(ref _flatStyle, value, nameof(FlatStyle));
}
protected override void WriteProps(JsonObject props)
{
base.WriteProps(props);
props["FlatStyle"] = _flatStyle.ToString();
}
}
public class Button : ButtonBase, IButtonControl
{
protected override Size DefaultSize => new(75, 23);
public DialogResult DialogResult { get; set; }
public void NotifyDefault(bool value) { }
public void PerformClick()
{
if (Enabled && Visible) OnClick(EventArgs.Empty);
}
protected override void OnClick(EventArgs e)
{
// 按钮设置了 DialogResult 时,点击会把结果交给所在的模态窗体并关闭它
if (DialogResult != DialogResult.None && FindForm() is { } form) form.DialogResult = DialogResult;
base.OnClick(e);
}
}