#0025 新增加载按钮;修复线居中
This commit is contained in:
@@ -55,6 +55,7 @@ namespace XplorePlane.ViewModels
|
||||
SavePipelineCommand = new DelegateCommand(async () => await SavePipelineAsync());
|
||||
SaveAsPipelineCommand = new DelegateCommand(async () => await SaveAsPipelineAsync());
|
||||
DeletePipelineCommand = new DelegateCommand(async () => await DeletePipelineAsync());
|
||||
LoadPipelineCommand = new DelegateCommand(async () => await LoadPipelineAsync());
|
||||
}
|
||||
|
||||
// ── State Properties ──────────────────────────────────────────
|
||||
@@ -133,6 +134,7 @@ namespace XplorePlane.ViewModels
|
||||
public DelegateCommand SavePipelineCommand { get; }
|
||||
public DelegateCommand SaveAsPipelineCommand { get; }
|
||||
public DelegateCommand DeletePipelineCommand { get; }
|
||||
public DelegateCommand LoadPipelineCommand { get; }
|
||||
|
||||
// ── Command Implementations ───────────────────────────────────
|
||||
|
||||
@@ -383,6 +385,58 @@ namespace XplorePlane.ViewModels
|
||||
await Task.CompletedTask;
|
||||
}
|
||||
|
||||
private async Task LoadPipelineAsync()
|
||||
{
|
||||
var dialog = new OpenFileDialog
|
||||
{
|
||||
Filter = "流水线文件 (*.pipeline.json)|*.pipeline.json",
|
||||
InitialDirectory = GetPipelineDirectory()
|
||||
};
|
||||
|
||||
if (dialog.ShowDialog() != true) return;
|
||||
|
||||
try
|
||||
{
|
||||
var model = await _persistenceService.LoadAsync(dialog.FileName);
|
||||
|
||||
PipelineNodes.Clear();
|
||||
SelectedNode = null;
|
||||
|
||||
PipelineName = model.Name;
|
||||
SelectedDevice = model.DeviceId;
|
||||
_currentFilePath = dialog.FileName;
|
||||
|
||||
foreach (var nodeModel in model.Nodes)
|
||||
{
|
||||
var displayName = _imageProcessingService.GetProcessorDisplayName(nodeModel.OperatorKey)
|
||||
?? nodeModel.OperatorKey;
|
||||
var node = new PipelineNodeViewModel(nodeModel.OperatorKey, displayName)
|
||||
{
|
||||
Order = nodeModel.Order,
|
||||
IsEnabled = nodeModel.IsEnabled
|
||||
};
|
||||
LoadNodeParameters(node);
|
||||
|
||||
// 恢复已保存的参数值
|
||||
foreach (var param in node.Parameters)
|
||||
{
|
||||
if (nodeModel.Parameters.TryGetValue(param.Name, out var savedValue))
|
||||
param.Value = savedValue;
|
||||
}
|
||||
|
||||
PipelineNodes.Add(node);
|
||||
}
|
||||
|
||||
Serilog.Log.Information("流水线已加载:{Name},节点数={Count}", model.Name, PipelineNodes.Count);
|
||||
StatusMessage = $"已加载流水线:{model.Name}({PipelineNodes.Count} 个节点)";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Serilog.Log.Warning("加载流水线失败:{Error}", ex.Message);
|
||||
StatusMessage = $"加载失败:{ex.Message}";
|
||||
}
|
||||
}
|
||||
|
||||
private PipelineModel BuildPipelineModel()
|
||||
{
|
||||
return new PipelineModel
|
||||
|
||||
Reference in New Issue
Block a user