1、CncProgramPath 现在存储绝对路径——AssociateCncProgram 接受 filePath 参数,ViewModel 传入 OpenFileDialog 选择的完整路径

2、偏移量影响所有 SavePositionNode——执行时模板中每个位置节点的 StageX/StageY 都会叠加单元格偏移,实现整体平移
This commit is contained in:
zhengxuan.zhang
2026-06-02 11:43:25 +08:00
parent dd62d04124
commit 6684143dc9
3 changed files with 8 additions and 6 deletions
@@ -22,7 +22,7 @@ namespace XplorePlane.Services.Matrix
MatrixLayout ToggleCellEnabled(MatrixLayout layout, int row, int column);
/// <summary>关联 CNC 程序到矩阵布局 | Associate a CNC program with the matrix layout</summary>
MatrixLayout AssociateCncProgram(MatrixLayout layout, CncProgram program);
MatrixLayout AssociateCncProgram(MatrixLayout layout, CncProgram program, string filePath = null);
/// <summary>将矩阵布局保存到 JSON 文件 | Save matrix layout to JSON file</summary>
Task SaveAsync(MatrixLayout layout, string filePath);
+6 -4
View File
@@ -123,15 +123,17 @@ namespace XplorePlane.Services.Matrix
}
/// <inheritdoc />
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;
}
@@ -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);
}