From 05c41a9a21e1c29f45f1454d49073192c8f89643 Mon Sep 17 00:00:00 2001 From: "zhengxuan.zhang" Date: Thu, 21 May 2026 15:02:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86CNC=E7=9B=B8=E5=85=B3=E7=9A=84?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E5=90=88=E5=B9=B6=EF=BC=8C=E7=AE=80=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- XplorePlane/Events/CncEvents.cs | 107 ++++++++++++++++++ XplorePlane/Events/CncProgramChangedEvent.cs | 15 --- .../Events/CncRoiEditRequestedEvent.cs | 37 ------ .../Events/MatrixExecutionProgressEvent.cs | 22 ---- 4 files changed, 107 insertions(+), 74 deletions(-) create mode 100644 XplorePlane/Events/CncEvents.cs delete mode 100644 XplorePlane/Events/CncProgramChangedEvent.cs delete mode 100644 XplorePlane/Events/CncRoiEditRequestedEvent.cs delete mode 100644 XplorePlane/Events/MatrixExecutionProgressEvent.cs diff --git a/XplorePlane/Events/CncEvents.cs b/XplorePlane/Events/CncEvents.cs new file mode 100644 index 0000000..51fbf06 --- /dev/null +++ b/XplorePlane/Events/CncEvents.cs @@ -0,0 +1,107 @@ +using Prism.Events; +using System; +using System.Collections.Generic; +using System.Windows; +using XplorePlane.Models; + +namespace XplorePlane.Events +{ + // ========================================================================= + // CNC 业务域事件定义 + // 包含:CNC 程序变更、ROI 编辑请求/取消、矩阵执行进度 + // ========================================================================= + + #region CNC 程序变更 + + /// + /// CNC 程序状态变更事件。 + /// 当 CNC 程序被新建、加载或修改时,由 CncProgramService 通过 IEventAggregator 发布。 + /// 订阅方:CncEditorViewModel(刷新标题栏修改标记)、MainViewModel(更新工具栏状态)。 + /// + public class CncProgramChangedEvent : PubSubEvent + { + } + + /// + /// CNC 程序变更载荷。 + /// + /// 当前程序名称(不含路径)。 + /// 是否存在未保存的修改。 + public record CncProgramChangedPayload(string ProgramName, bool IsModified); + + #endregion + + #region ROI 编辑 + + /// + /// 请求在主视口画布上激活 ROI 编辑模式的事件。 + /// 由 CNC 流水线编辑器(CncEditorViewModel)发布, + /// ViewportPanelView 订阅后操作 PolygonRoiCanvas 进入交互编辑状态。 + /// + public sealed class CncRoiEditRequestedEvent : PubSubEvent + { + } + + /// + /// ROI 编辑请求载荷,携带初始顶点及回调委托。 + /// + public class CncRoiEditRequestedPayload + { + /// + /// 已保存的 ROI 多边形顶点(图像坐标系)。 + /// 为 null 或空集合时表示新建 ROI。 + /// + public IReadOnlyList ExistingPoints { get; set; } + + /// + /// ROI 顶点发生变化时的回调,参数为最新的顶点列表。 + /// 每次用户添加或移动顶点后触发,用于实时写回参数并刷新预览。 + /// + public Action> OnPointsChanged { get; set; } + + /// + /// ROI 编辑结束(用户确认或取消)时的回调,用于清理编辑状态。 + /// + public Action OnEditFinished { get; set; } + } + + /// + /// 请求停止 ROI 编辑模式的事件。 + /// 由 CncEditorViewModel 在编辑取消或完成后发布, + /// ViewportPanelView 订阅后清理画布上的临时绘制状态。 + /// + public sealed class CncRoiEditCancelledEvent : PubSubEvent + { + } + + #endregion + + #region 矩阵执行进度 + + /// + /// 矩阵扫描执行进度事件。 + /// 矩阵执行过程中由 MatrixScanService 周期性发布, + /// 订阅方:CncEditorViewModel(进度条)、MainViewModel(状态栏)。 + /// + public class MatrixExecutionProgressEvent : PubSubEvent + { + } + + /// + /// 矩阵执行进度载荷。 + /// + /// 当前执行行(0-based)。 + /// 当前执行列(0-based)。 + /// 矩阵总格数。 + /// 已完成格数。 + /// 当前格的执行状态。 + public record MatrixExecutionProgressPayload( + int CurrentRow, + int CurrentColumn, + int TotalCells, + int CompletedCells, + MatrixCellStatus Status + ); + + #endregion +} diff --git a/XplorePlane/Events/CncProgramChangedEvent.cs b/XplorePlane/Events/CncProgramChangedEvent.cs deleted file mode 100644 index 63fe48f..0000000 --- a/XplorePlane/Events/CncProgramChangedEvent.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Prism.Events; - -namespace XplorePlane.Events -{ - /// - /// CNC 程序状态变更事件 | CNC program changed event - /// 当 CNC 程序被修改时通过 IEventAggregator 发布 | Published via IEventAggregator when CNC program is modified - /// - public class CncProgramChangedEvent : PubSubEvent - { - } - - /// CNC 程序变更载荷 | CNC program changed payload - public record CncProgramChangedPayload(string ProgramName, bool IsModified); -} \ No newline at end of file diff --git a/XplorePlane/Events/CncRoiEditRequestedEvent.cs b/XplorePlane/Events/CncRoiEditRequestedEvent.cs deleted file mode 100644 index 0211191..0000000 --- a/XplorePlane/Events/CncRoiEditRequestedEvent.cs +++ /dev/null @@ -1,37 +0,0 @@ -using Prism.Events; -using System; -using System.Collections.Generic; -using System.Windows; - -namespace XplorePlane.Events -{ - /// - /// 请求在主视口画布上激活 ROI 编辑模式的事件。 - /// 由 CNC 流水线编辑器发布,ViewportPanelView 订阅并操作 PolygonRoiCanvas。 - /// - public sealed class CncRoiEditRequestedEvent : PubSubEvent - { - } - - public class CncRoiEditRequestedPayload - { - /// 已保存的 ROI 多边形顶点(图像坐标)。为空表示新建 ROI。 - public IReadOnlyList ExistingPoints { get; set; } - - /// - /// ROI 顶点变化时的回调,参数为最新的顶点列表。 - /// 每次用户添加/移动顶点后调用,用于实时写回参数并触发预览。 - /// - public Action> OnPointsChanged { get; set; } - - /// ROI 编辑结束(用户完成或取消)时的回调。 - public Action OnEditFinished { get; set; } - } - - /// - /// 请求停止 ROI 编辑模式(清理画布状态)。 - /// - public sealed class CncRoiEditCancelledEvent : PubSubEvent - { - } -} diff --git a/XplorePlane/Events/MatrixExecutionProgressEvent.cs b/XplorePlane/Events/MatrixExecutionProgressEvent.cs deleted file mode 100644 index 05e9ea8..0000000 --- a/XplorePlane/Events/MatrixExecutionProgressEvent.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Prism.Events; -using XplorePlane.Models; - -namespace XplorePlane.Events -{ - /// - /// 矩阵执行进度事件 | Matrix execution progress event - /// 矩阵执行过程中通过 IEventAggregator 发布进度更新 | Published via IEventAggregator during matrix execution - /// - public class MatrixExecutionProgressEvent : PubSubEvent - { - } - - /// 矩阵执行进度载荷 | Matrix execution progress payload - public record MatrixExecutionProgressPayload( - int CurrentRow, - int CurrentColumn, - int TotalCells, - int CompletedCells, - MatrixCellStatus Status - ); -} \ No newline at end of file