From 6684143dc9f01ebf2e7d33506e8563d6fea8668c Mon Sep 17 00:00:00 2001 From: "zhengxuan.zhang" Date: Tue, 2 Jun 2026 11:43:25 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81CncProgramPath=20=E7=8E=B0=E5=9C=A8?= =?UTF-8?q?=E5=AD=98=E5=82=A8=E7=BB=9D=E5=AF=B9=E8=B7=AF=E5=BE=84=E2=80=94?= =?UTF-8?q?=E2=80=94AssociateCncProgram=20=E6=8E=A5=E5=8F=97=20filePath=20?= =?UTF-8?q?=E5=8F=82=E6=95=B0=EF=BC=8CViewModel=20=E4=BC=A0=E5=85=A5=20Ope?= =?UTF-8?q?nFileDialog=20=E9=80=89=E6=8B=A9=E7=9A=84=E5=AE=8C=E6=95=B4?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=202=E3=80=81=E5=81=8F=E7=A7=BB=E9=87=8F?= =?UTF-8?q?=E5=BD=B1=E5=93=8D=E6=89=80=E6=9C=89=20SavePositionNode?= =?UTF-8?q?=E2=80=94=E2=80=94=E6=89=A7=E8=A1=8C=E6=97=B6=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E4=B8=AD=E6=AF=8F=E4=B8=AA=E4=BD=8D=E7=BD=AE=E8=8A=82=E7=82=B9?= =?UTF-8?q?=E7=9A=84=20StageX/StageY=20=E9=83=BD=E4=BC=9A=E5=8F=A0?= =?UTF-8?q?=E5=8A=A0=E5=8D=95=E5=85=83=E6=A0=BC=E5=81=8F=E7=A7=BB=EF=BC=8C?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E6=95=B4=E4=BD=93=E5=B9=B3=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- XplorePlane/Services/Matrix/IMatrixService.cs | 2 +- XplorePlane/Services/Matrix/MatrixService.cs | 10 ++++++---- XplorePlane/ViewModels/Cnc/MatrixEditorViewModel.cs | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/XplorePlane/Services/Matrix/IMatrixService.cs b/XplorePlane/Services/Matrix/IMatrixService.cs index 8815d45..24a3e87 100644 --- a/XplorePlane/Services/Matrix/IMatrixService.cs +++ b/XplorePlane/Services/Matrix/IMatrixService.cs @@ -22,7 +22,7 @@ namespace XplorePlane.Services.Matrix MatrixLayout ToggleCellEnabled(MatrixLayout layout, int row, int column); /// 关联 CNC 程序到矩阵布局 | Associate a CNC program with the matrix layout - MatrixLayout AssociateCncProgram(MatrixLayout layout, CncProgram program); + MatrixLayout AssociateCncProgram(MatrixLayout layout, CncProgram program, string filePath = null); /// 将矩阵布局保存到 JSON 文件 | Save matrix layout to JSON file Task SaveAsync(MatrixLayout layout, string filePath); diff --git a/XplorePlane/Services/Matrix/MatrixService.cs b/XplorePlane/Services/Matrix/MatrixService.cs index 100fe82..cad176a 100644 --- a/XplorePlane/Services/Matrix/MatrixService.cs +++ b/XplorePlane/Services/Matrix/MatrixService.cs @@ -123,15 +123,17 @@ namespace XplorePlane.Services.Matrix } /// - public MatrixLayout AssociateCncProgram(MatrixLayout layout, CncProgram program) + public MatrixLayout AssociateCncProgram(MatrixLayout layout, CncProgram program, string filePath = null) { ArgumentNullException.ThrowIfNull(layout); ArgumentNullException.ThrowIfNull(program); - var updated = layout with { CncProgramPath = program.Name }; + // 优先使用传入的文件路径(绝对路径),否则回退到程序名 + var programPath = !string.IsNullOrWhiteSpace(filePath) ? filePath : program.Name; + var updated = layout with { CncProgramPath = programPath }; - _logger.Info("已关联 CNC 程序到矩阵布局 | Associated CNC program with matrix layout: LayoutId={LayoutId}, Program={ProgramName}", - layout.Id, program.Name); + _logger.Info("已关联 CNC 程序到矩阵布局 | Associated CNC program with matrix layout: LayoutId={LayoutId}, Program={ProgramPath}", + layout.Id, programPath); return updated; } diff --git a/XplorePlane/ViewModels/Cnc/MatrixEditorViewModel.cs b/XplorePlane/ViewModels/Cnc/MatrixEditorViewModel.cs index 6bfe8bb..dc366cc 100644 --- a/XplorePlane/ViewModels/Cnc/MatrixEditorViewModel.cs +++ b/XplorePlane/ViewModels/Cnc/MatrixEditorViewModel.cs @@ -409,7 +409,7 @@ namespace XplorePlane.ViewModels.Cnc return; } - _currentLayout = _matrixService.AssociateCncProgram(_currentLayout, program); + _currentLayout = _matrixService.AssociateCncProgram(_currentLayout, program, filePath); AssociatedProgramPath = filePath; _logger.Info("已关联 CNC 程序 | Associated CNC program: {ProgramPath}", filePath); }