树形节点图标直接复用项目现有图标资源;调整CNC编辑界面大小
This commit is contained in:
@@ -205,6 +205,32 @@ namespace XplorePlane.Services.Cnc
|
||||
return updated;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public CncProgram UpdateNode(CncProgram program, int index, CncNode node)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(program);
|
||||
ArgumentNullException.ThrowIfNull(node);
|
||||
|
||||
if (index < 0 || index >= program.Nodes.Count)
|
||||
throw new ArgumentOutOfRangeException(nameof(index),
|
||||
$"Index out of range: {index}, Count={program.Nodes.Count}");
|
||||
|
||||
var nodes = new List<CncNode>(program.Nodes)
|
||||
{
|
||||
[index] = node with { Index = index }
|
||||
};
|
||||
|
||||
var updated = program with
|
||||
{
|
||||
Nodes = nodes.AsReadOnly(),
|
||||
UpdatedAt = DateTime.UtcNow
|
||||
};
|
||||
|
||||
_logger.Info("Updated node: Index={Index}, Type={NodeType}, Program={ProgramName}",
|
||||
index, node.NodeType, program.Name);
|
||||
return updated;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task SaveAsync(CncProgram program, string filePath)
|
||||
{
|
||||
|
||||
@@ -4,36 +4,28 @@ using XplorePlane.Models;
|
||||
namespace XplorePlane.Services.Cnc
|
||||
{
|
||||
/// <summary>
|
||||
/// CNC 程序管理服务接口,负责程序的创建、节点编辑、序列化/反序列化和文件读写
|
||||
/// CNC program management service interface for creation, node editing, serialization and file I/O
|
||||
/// CNC program management service interface.
|
||||
/// </summary>
|
||||
public interface ICncProgramService
|
||||
{
|
||||
/// <summary>创建空的 CNC 程序 | Create an empty CNC program</summary>
|
||||
CncProgram CreateProgram(string name);
|
||||
|
||||
/// <summary>根据节点类型创建节点(从 IAppStateService 捕获设备状态)| Create a node by type (captures device state from IAppStateService)</summary>
|
||||
CncNode CreateNode(CncNodeType type);
|
||||
|
||||
/// <summary>在指定索引之后插入节点并重新编号 | Insert a node after the given index and renumber</summary>
|
||||
CncProgram InsertNode(CncProgram program, int afterIndex, CncNode node);
|
||||
|
||||
/// <summary>移除指定索引的节点并重新编号 | Remove the node at the given index and renumber</summary>
|
||||
CncProgram RemoveNode(CncProgram program, int index);
|
||||
|
||||
/// <summary>将节点从旧索引移动到新索引并重新编号 | Move a node from old index to new index and renumber</summary>
|
||||
CncProgram MoveNode(CncProgram program, int oldIndex, int newIndex);
|
||||
|
||||
/// <summary>将 CNC 程序保存到 .xp 文件 | Save CNC program to .xp file</summary>
|
||||
CncProgram UpdateNode(CncProgram program, int index, CncNode node);
|
||||
|
||||
Task SaveAsync(CncProgram program, string filePath);
|
||||
|
||||
/// <summary>从 .xp 文件加载 CNC 程序 | Load CNC program from .xp file</summary>
|
||||
Task<CncProgram> LoadAsync(string filePath);
|
||||
|
||||
/// <summary>将 CNC 程序序列化为 JSON 字符串 | Serialize CNC program to JSON string</summary>
|
||||
string Serialize(CncProgram program);
|
||||
|
||||
/// <summary>从 JSON 字符串反序列化 CNC 程序 | Deserialize CNC program from JSON string</summary>
|
||||
CncProgram Deserialize(string json);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user