修复算子工具箱搜索功能

This commit is contained in:
zhengxuan.zhang
2026-05-06 10:01:27 +08:00
parent fdf2419eb6
commit fd4048a6c0
3 changed files with 13 additions and 1 deletions
@@ -36,6 +36,7 @@ namespace XplorePlane.ViewModels
{ {
private readonly IImageProcessingService _imageProcessingService; private readonly IImageProcessingService _imageProcessingService;
private string _searchText = string.Empty; private string _searchText = string.Empty;
private OperatorGroupViewModel _selectedGroup;
// UI 元数据(分类 + 图标)由 ProcessorUiMetadata 统一提供,保持工具箱与流水线图标一致 // UI 元数据(分类 + 图标)由 ProcessorUiMetadata 统一提供,保持工具箱与流水线图标一致
@@ -52,6 +53,12 @@ namespace XplorePlane.ViewModels
public ObservableCollection<OperatorDescriptor> FilteredOperators { get; } public ObservableCollection<OperatorDescriptor> FilteredOperators { get; }
public ObservableCollection<OperatorGroupViewModel> FilteredGroups { get; } public ObservableCollection<OperatorGroupViewModel> FilteredGroups { get; }
public OperatorGroupViewModel SelectedGroup
{
get => _selectedGroup;
set => SetProperty(ref _selectedGroup, value);
}
public string SearchText public string SearchText
{ {
get => _searchText; get => _searchText;
@@ -78,6 +85,7 @@ namespace XplorePlane.ViewModels
{ {
FilteredOperators.Clear(); FilteredOperators.Clear();
FilteredGroups.Clear(); FilteredGroups.Clear();
SelectedGroup = null;
var filtered = string.IsNullOrWhiteSpace(SearchText) var filtered = string.IsNullOrWhiteSpace(SearchText)
? AvailableOperators ? AvailableOperators
@@ -101,6 +109,8 @@ namespace XplorePlane.ViewModels
Operators = new ObservableCollection<OperatorDescriptor>(group) Operators = new ObservableCollection<OperatorDescriptor>(group)
}); });
} }
SelectedGroup = FilteredGroups.FirstOrDefault();
} }
private static int GetCategoryOrder(string category) => category switch private static int GetCategoryOrder(string category) => category switch
@@ -100,6 +100,7 @@
<TabControl x:Name="ToolboxListBox" <TabControl x:Name="ToolboxListBox"
Margin="8" Margin="8"
ItemContainerStyle="{StaticResource OperatorToolboxTabItemStyle}" ItemContainerStyle="{StaticResource OperatorToolboxTabItemStyle}"
SelectedItem="{Binding SelectedGroup, Mode=TwoWay}"
ItemsSource="{Binding FilteredGroups}"> ItemsSource="{Binding FilteredGroups}">
<TabControl.ItemTemplate> <TabControl.ItemTemplate>
<DataTemplate> <DataTemplate>
@@ -3,7 +3,8 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:views="clr-namespace:XplorePlane.Views" xmlns:views="clr-namespace:XplorePlane.Views"
Title="算子工具箱" Title="算子工具箱"
Width="500" Height="560" Width="460" Height="540"
MinWidth="420" MinHeight="500"
WindowStartupLocation="CenterOwner" WindowStartupLocation="CenterOwner"
ShowInTaskbar="False" ShowInTaskbar="False"
WindowStyle="None" WindowStyle="None"