#0031 新增打开图像工具箱

This commit is contained in:
zhengxuan.zhang
2026-03-16 17:12:51 +08:00
parent 140153d449
commit 3f89710850
5 changed files with 53 additions and 7 deletions
+1 -1
View File
@@ -154,7 +154,7 @@ namespace XplorePlane
protected override Window CreateShell()
{
return Container.Resolve<MainWindowB>();
return Container.Resolve<MainWindow>();
}
protected override void RegisterTypes(IContainerRegistry containerRegistry)
@@ -56,10 +56,13 @@ namespace XplorePlane.ViewModels
SaveAsPipelineCommand = new DelegateCommand(async () => await SaveAsPipelineAsync());
DeletePipelineCommand = new DelegateCommand(async () => await DeletePipelineAsync());
LoadPipelineCommand = new DelegateCommand(async () => await LoadPipelineAsync());
OpenToolboxCommand = new DelegateCommand(OpenToolbox);
MoveNodeUpCommand = new DelegateCommand<PipelineNodeViewModel>(MoveNodeUp);
MoveNodeDownCommand = new DelegateCommand<PipelineNodeViewModel>(MoveNodeDown);
}
// ── State Properties ──────────────────────────────────────────
public ObservableCollection<PipelineNodeViewModel> PipelineNodes { get; }
@@ -137,6 +140,9 @@ namespace XplorePlane.ViewModels
public DelegateCommand SaveAsPipelineCommand { get; }
public DelegateCommand DeletePipelineCommand { get; }
public DelegateCommand LoadPipelineCommand { get; }
public DelegateCommand OpenToolboxCommand { get; }
public DelegateCommand<PipelineNodeViewModel> MoveNodeUpCommand { get; }
public DelegateCommand<PipelineNodeViewModel> MoveNodeDownCommand { get; }
@@ -461,6 +467,26 @@ namespace XplorePlane.ViewModels
}
}
private void OpenToolbox() //打开图像工具箱
{
Serilog.Log.Information("OpenToolbox 被调用");
try
{
var window = new Views.OperatorToolboxWindow
{
Owner = System.Windows.Application.Current.MainWindow
};
Serilog.Log.Information("OperatorToolboxWindow 已创建,准备 Show()");
window.Show();
Serilog.Log.Information("OperatorToolboxWindow.Show() 完成");
}
catch (Exception ex)
{
Serilog.Log.Error(ex, "OpenToolbox 打开窗口失败");
}
}
private PipelineModel BuildPipelineModel()
{
return new PipelineModel
@@ -22,7 +22,7 @@ namespace XplorePlane.Views
private void OnLoaded(object sender, RoutedEventArgs e)
{
if (DataContext == null)
if (DataContext is not OperatorToolboxViewModel)
DataContext = ContainerLocator.Container.Resolve<OperatorToolboxViewModel>();
ToolboxListBox.PreviewMouseLeftButtonDown += OnPreviewMouseDown;
@@ -98,13 +98,19 @@
Content="■"
Style="{StaticResource ToolbarBtn}"
ToolTip="取消执行" />
</StackPanel>
<Button
HorizontalAlignment="Right"
Command="{Binding DeletePipelineCommand}"
Content="🗑"
Style="{StaticResource ToolbarBtn}"
ToolTip="删除流水线" />
ToolTip="工具箱" />
</StackPanel>
<Button
Width="50"
HorizontalAlignment="Right"
Command="{Binding OpenToolboxCommand}"
Content="工具箱"
Style="{StaticResource ToolbarBtn}"
ToolTip="打开算子工具箱" />
</Grid>
</Border>
@@ -1,3 +1,4 @@
using System;
using System.Windows;
using System.Windows.Controls;
using Prism.Ioc;
@@ -16,8 +17,21 @@ namespace XplorePlane.Views
private void OnLoaded(object sender, RoutedEventArgs e)
{
if (DataContext == null)
try
{
if (DataContext is not PipelineEditorViewModel)
{
Log.Information("PipelineEditorView DataContext 不是 PipelineEditorViewModel(当前={Type}),正在从容器解析...",
DataContext?.GetType().Name);
DataContext = ContainerLocator.Container.Resolve<PipelineEditorViewModel>();
}
Log.Information("PipelineEditorView DataContext 类型={Type}, HashCode={Hash}",
DataContext?.GetType().Name, DataContext?.GetHashCode());
}
catch (Exception ex)
{
Log.Error(ex, "PipelineEditorView 解析 DataContext 失败");
}
PipelineListBox.AllowDrop = true;
PipelineListBox.Drop += OnOperatorDropped;