Phase 7: 自定义图标系统 + 组合嵌套 + 删除功能 + UI 优化
- 安装 FontAwesome.Sharp v6.6.0,新增 Helpers/IconProvider.cs(190+ 图标,11 分类) - ToolEditWindow/GroupEditWindow: 添加图标选择 ComboBox,按分类分组,带图标预览 - MainWindow 卡片模板: 使用 fa:IconBlock 渲染图标,IconCode 为空时回退首字母 - 组合角标从 emoji 改为 FontAwesome Cubes 图标,放置于卡片右上角 - ComboBox 样式修复: TextBlock→ContentPresenter,支持 ItemTemplate+DisplayMemberPath - ComboBox 滚轮修复: CanContentScroll=False 解决分组模式下滑轮跳组问题 - 编辑弹窗: 所有输入控件添加 VerticalContentAlignment=Center - 组合可包含其他组合: GetAncestorIds 递归排除自身及祖先防止循环引用 - ProcessExecutionService: 支持嵌套组合递归执行,visited 集合防死循环 - MainWindow 右键菜单新增删除功能,工具和组合均支持 - 移除侧边栏顶部个人工具箱标题文字 - 更新测试: 适配组合嵌套逻辑,新增祖先排除测试 (83/83 通过)
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
xmlns:local="clr-namespace:PersonalToolBox.Views"
|
||||
xmlns:vm="clr-namespace:PersonalToolBox.ViewModels"
|
||||
xmlns:models="clr-namespace:PersonalToolBox.Models"
|
||||
xmlns:fa="http://schemas.awesome.incremented/wpf/xaml/fontawesome.sharp"
|
||||
mc:Ignorable="d"
|
||||
Title="个人工具箱" Height="650" Width="960"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
@@ -15,6 +16,7 @@
|
||||
<!-- 值转换器(必须定义在 DataTemplate 之前,确保 StaticResource 能解析) -->
|
||||
<local:BoolToOpacityConverter x:Key="BoolToOpacityConverter"/>
|
||||
<local:FirstCharConverter x:Key="FirstCharConverter"/>
|
||||
<local:StringToIconCharConverter x:Key="StringToIconCharConverter"/>
|
||||
|
||||
<!-- 工具卡片模板 -->
|
||||
<DataTemplate x:Key="ToolCardTemplate" DataType="{x:Type models:ToolItem}">
|
||||
@@ -66,24 +68,41 @@
|
||||
</Style>
|
||||
</MenuItem.Style>
|
||||
</MenuItem>
|
||||
<Separator/>
|
||||
<MenuItem Header="删除"
|
||||
Command="{Binding PlacementTarget.Tag.DeleteToolCommand, RelativeSource={RelativeSource AncestorType=ContextMenu}}"
|
||||
CommandParameter="{Binding}"/>
|
||||
</ContextMenu>
|
||||
</Border.ContextMenu>
|
||||
<Grid>
|
||||
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
|
||||
<Grid HorizontalAlignment="Center" Margin="0,0,0,4">
|
||||
<TextBlock Text="{Binding Name, Converter={StaticResource FirstCharConverter}}"
|
||||
FontSize="28"
|
||||
<!-- FontAwesome 图标(IconCode 有值时显示) -->
|
||||
<fa:IconBlock Icon="{Binding IconCode, Converter={StaticResource StringToIconCharConverter}}"
|
||||
FontSize="28"
|
||||
Foreground="{DynamicResource Theme.Accent}"
|
||||
HorizontalAlignment="Center">
|
||||
<fa:IconBlock.Style>
|
||||
<Style TargetType="fa:IconBlock">
|
||||
<Setter Property="Visibility" Value="Visible"/>
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding IconCode}" Value="">
|
||||
<Setter Property="Visibility" Value="Collapsed"/>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</fa:IconBlock.Style>
|
||||
</fa:IconBlock>
|
||||
<!-- 首字母回退(IconCode 为空时显示) -->
|
||||
<TextBlock FontSize="28"
|
||||
Foreground="{DynamicResource Theme.Accent}"
|
||||
HorizontalAlignment="Center"/>
|
||||
<!-- 组合角标 -->
|
||||
<TextBlock Text="📦" FontSize="11"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Bottom"
|
||||
Margin="0,0,-12,-4">
|
||||
HorizontalAlignment="Center">
|
||||
<TextBlock.Style>
|
||||
<Style TargetType="TextBlock">
|
||||
<Setter Property="Visibility" Value="Collapsed"/>
|
||||
<Setter Property="Text" Value="{Binding Name, Converter={StaticResource FirstCharConverter}}"/>
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding IsGroup}" Value="True">
|
||||
<DataTrigger Binding="{Binding IconCode}" Value="">
|
||||
<Setter Property="Visibility" Value="Visible"/>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
@@ -98,6 +117,24 @@
|
||||
TextTrimming="CharacterEllipsis"
|
||||
MaxWidth="120"/>
|
||||
</StackPanel>
|
||||
<!-- 组合角标 -->
|
||||
<fa:IconBlock Icon="Cubes" FontSize="11"
|
||||
Foreground="{DynamicResource Theme.Accent}"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Top"
|
||||
Margin="0,4,6,0">
|
||||
<fa:IconBlock.Style>
|
||||
<Style TargetType="fa:IconBlock">
|
||||
<Setter Property="Visibility" Value="Collapsed"/>
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding IsGroup}" Value="True">
|
||||
<Setter Property="Visibility" Value="Visible"/>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</fa:IconBlock.Style>
|
||||
</fa:IconBlock>
|
||||
</Grid>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</Window.Resources>
|
||||
@@ -120,21 +157,13 @@
|
||||
<Border Grid.Column="0" Background="{DynamicResource Theme.SidebarBackground}">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="50"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="42"/>
|
||||
<RowDefinition Height="42"/>
|
||||
<RowDefinition Height="45"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBlock Grid.Row="0"
|
||||
Text="个人工具箱"
|
||||
FontSize="18" FontWeight="Bold"
|
||||
Foreground="{DynamicResource Theme.Accent}"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center"/>
|
||||
|
||||
<ListBox Grid.Row="1"
|
||||
<ListBox Grid.Row="0"
|
||||
x:Name="CategoryListBox"
|
||||
ItemsSource="{Binding Categories}"
|
||||
SelectedItem="{Binding SelectedCategory}"
|
||||
@@ -186,7 +215,7 @@
|
||||
</ListBox>
|
||||
|
||||
<!-- 分类管理按钮 -->
|
||||
<Button Grid.Row="2"
|
||||
<Button Grid.Row="1"
|
||||
Command="{Binding AddCategoryCommand}"
|
||||
Background="Transparent"
|
||||
BorderThickness="1"
|
||||
@@ -202,7 +231,7 @@
|
||||
</StackPanel>
|
||||
</Button>
|
||||
|
||||
<Button Grid.Row="3"
|
||||
<Button Grid.Row="2"
|
||||
Command="{Binding ToggleAutoStartCommand}"
|
||||
Background="Transparent"
|
||||
BorderThickness="1"
|
||||
@@ -224,7 +253,7 @@
|
||||
<TextBlock VerticalAlignment="Center" TextAlignment="Center"/>
|
||||
</Button>
|
||||
|
||||
<Button Grid.Row="4"
|
||||
<Button Grid.Row="3"
|
||||
Command="{Binding ToggleThemeCommand}"
|
||||
Background="Transparent"
|
||||
BorderThickness="1"
|
||||
|
||||
Reference in New Issue
Block a user