#0026 图像工具箱新增移动和删除

This commit is contained in:
zhengxuan.zhang
2026-03-15 10:50:52 +08:00
parent 880cdfc937
commit 430a1e6ed9
2 changed files with 53 additions and 1 deletions
@@ -56,6 +56,8 @@ namespace XplorePlane.ViewModels
SaveAsPipelineCommand = new DelegateCommand(async () => await SaveAsPipelineAsync()); SaveAsPipelineCommand = new DelegateCommand(async () => await SaveAsPipelineAsync());
DeletePipelineCommand = new DelegateCommand(async () => await DeletePipelineAsync()); DeletePipelineCommand = new DelegateCommand(async () => await DeletePipelineAsync());
LoadPipelineCommand = new DelegateCommand(async () => await LoadPipelineAsync()); LoadPipelineCommand = new DelegateCommand(async () => await LoadPipelineAsync());
MoveNodeUpCommand = new DelegateCommand<PipelineNodeViewModel>(MoveNodeUp);
MoveNodeDownCommand = new DelegateCommand<PipelineNodeViewModel>(MoveNodeDown);
} }
// ── State Properties ────────────────────────────────────────── // ── State Properties ──────────────────────────────────────────
@@ -135,6 +137,8 @@ namespace XplorePlane.ViewModels
public DelegateCommand SaveAsPipelineCommand { get; } public DelegateCommand SaveAsPipelineCommand { get; }
public DelegateCommand DeletePipelineCommand { get; } public DelegateCommand DeletePipelineCommand { get; }
public DelegateCommand LoadPipelineCommand { get; } public DelegateCommand LoadPipelineCommand { get; }
public DelegateCommand<PipelineNodeViewModel> MoveNodeUpCommand { get; }
public DelegateCommand<PipelineNodeViewModel> MoveNodeDownCommand { get; }
// ── Command Implementations ─────────────────────────────────── // ── Command Implementations ───────────────────────────────────
@@ -197,6 +201,26 @@ namespace XplorePlane.ViewModels
TriggerDebouncedExecution(); TriggerDebouncedExecution();
} }
private void MoveNodeUp(PipelineNodeViewModel node)
{
if (node == null) return;
int index = PipelineNodes.IndexOf(node);
if (index <= 0) return;
PipelineNodes.Move(index, index - 1);
RenumberNodes();
TriggerDebouncedExecution();
}
private void MoveNodeDown(PipelineNodeViewModel node)
{
if (node == null) return;
int index = PipelineNodes.IndexOf(node);
if (index < 0 || index >= PipelineNodes.Count - 1) return;
PipelineNodes.Move(index, index + 1);
RenumberNodes();
TriggerDebouncedExecution();
}
private void ReorderOperator(PipelineReorderArgs args) private void ReorderOperator(PipelineReorderArgs args)
{ {
if (args == null) return; if (args == null) return;
@@ -161,10 +161,11 @@
ScrollViewer.HorizontalScrollBarVisibility="Disabled"> ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListBox.ItemTemplate> <ListBox.ItemTemplate>
<DataTemplate> <DataTemplate>
<Grid MinHeight="48"> <Grid x:Name="NodeRoot" MinHeight="48">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="44" /> <ColumnDefinition Width="44" />
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<!-- 连接线列:上半段 + 下半段 --> <!-- 连接线列:上半段 + 下半段 -->
@@ -196,11 +197,38 @@
Margin="6,0,0,0" Margin="6,0,0,0"
FontFamily="Microsoft YaHei UI" FontSize="12" FontFamily="Microsoft YaHei UI" FontSize="12"
Text="{Binding DisplayName}" /> Text="{Binding DisplayName}" />
<!-- 操作按钮:上移 / 下移 / 删除(悬停显示) -->
<StackPanel x:Name="NodeActions"
Grid.Column="2"
Orientation="Horizontal"
VerticalAlignment="Center"
Margin="0,0,4,0"
Visibility="Collapsed">
<Button Content="▲" ToolTip="上移" Width="22" Height="22"
Margin="1,0" FontSize="10" Cursor="Hand"
Background="Transparent" BorderBrush="#cdcbcb" BorderThickness="1"
Command="{Binding DataContext.MoveNodeUpCommand, RelativeSource={RelativeSource AncestorType=ListBox}}"
CommandParameter="{Binding}" />
<Button Content="▼" ToolTip="下移" Width="22" Height="22"
Margin="1,0" FontSize="10" Cursor="Hand"
Background="Transparent" BorderBrush="#cdcbcb" BorderThickness="1"
Command="{Binding DataContext.MoveNodeDownCommand, RelativeSource={RelativeSource AncestorType=ListBox}}"
CommandParameter="{Binding}" />
<Button Content="✕" ToolTip="删除" Width="22" Height="22"
Margin="1,0" FontSize="10" Cursor="Hand"
Background="Transparent" BorderBrush="#E05050" BorderThickness="1"
Command="{Binding DataContext.RemoveOperatorCommand, RelativeSource={RelativeSource AncestorType=ListBox}}"
CommandParameter="{Binding}" />
</StackPanel>
</Grid> </Grid>
<DataTemplate.Triggers> <DataTemplate.Triggers>
<DataTrigger Binding="{Binding Order}" Value="0"> <DataTrigger Binding="{Binding Order}" Value="0">
<Setter TargetName="TopLine" Property="Visibility" Value="Collapsed" /> <Setter TargetName="TopLine" Property="Visibility" Value="Collapsed" />
</DataTrigger> </DataTrigger>
<Trigger SourceName="NodeRoot" Property="IsMouseOver" Value="True">
<Setter TargetName="NodeActions" Property="Visibility" Value="Visible" />
</Trigger>
</DataTemplate.Triggers> </DataTemplate.Triggers>
</DataTemplate> </DataTemplate>
</ListBox.ItemTemplate> </ListBox.ItemTemplate>