- ToolItem 模型新增 AutoRunOnStart 属性,持久化到配置文件 - App.OnStartup 启动后自动执行标记为自启动的工具/组合(间隔500ms) - 工具编辑窗口和组合编辑窗口新增「随软件启动自动运行」CheckBox - 主界面工具卡片左上角 Rocket 角标标识已启用自启的项目
263 lines
14 KiB
XML
263 lines
14 KiB
XML
<Window x:Class="PersonalToolBox.Views.GroupEditWindow"
|
||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||
xmlns:fa="http://schemas.awesome.incremented/wpf/xaml/fontawesome.sharp"
|
||
Title="{Binding WindowTitle}" Height="580" Width="520"
|
||
WindowStartupLocation="CenterOwner"
|
||
ResizeMode="NoResize"
|
||
Background="{DynamicResource Theme.Background}">
|
||
|
||
<Window.Resources>
|
||
<!-- ComboBox 下拉项样式 -->
|
||
<Style TargetType="ComboBoxItem">
|
||
<Setter Property="Background" Value="{DynamicResource Theme.InputBackground}"/>
|
||
<Setter Property="Foreground" Value="{DynamicResource Theme.Foreground}"/>
|
||
<Setter Property="Padding" Value="6,3"/>
|
||
<Setter Property="Template">
|
||
<Setter.Value>
|
||
<ControlTemplate TargetType="ComboBoxItem">
|
||
<Border x:Name="Border"
|
||
Background="{TemplateBinding Background}"
|
||
Padding="{TemplateBinding Padding}">
|
||
<ContentPresenter VerticalAlignment="Center"/>
|
||
</Border>
|
||
<ControlTemplate.Triggers>
|
||
<Trigger Property="IsHighlighted" Value="True">
|
||
<Setter TargetName="Border" Property="Background" Value="{DynamicResource Theme.Accent}"/>
|
||
<Setter Property="Foreground" Value="{DynamicResource Theme.ButtonForeground}"/>
|
||
</Trigger>
|
||
</ControlTemplate.Triggers>
|
||
</ControlTemplate>
|
||
</Setter.Value>
|
||
</Setter>
|
||
</Style>
|
||
|
||
<!-- ComboBox 整体样式(兼容 DisplayMemberPath 和 ItemTemplate) -->
|
||
<Style TargetType="ComboBox">
|
||
<Setter Property="Background" Value="{DynamicResource Theme.InputBackground}"/>
|
||
<Setter Property="Foreground" Value="{DynamicResource Theme.Foreground}"/>
|
||
<Setter Property="BorderBrush" Value="{DynamicResource Theme.InputBorder}"/>
|
||
<Setter Property="BorderThickness" Value="1"/>
|
||
<Setter Property="VerticalContentAlignment" Value="Center"/>
|
||
<Setter Property="Template">
|
||
<Setter.Value>
|
||
<ControlTemplate TargetType="ComboBox">
|
||
<Grid>
|
||
<ToggleButton x:Name="ToggleButton"
|
||
Background="{TemplateBinding Background}"
|
||
BorderBrush="{TemplateBinding BorderBrush}"
|
||
BorderThickness="{TemplateBinding BorderThickness}"
|
||
IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
|
||
ClickMode="Press">
|
||
<ToggleButton.Template>
|
||
<ControlTemplate TargetType="ToggleButton">
|
||
<Border Background="{TemplateBinding Background}"
|
||
BorderBrush="{TemplateBinding BorderBrush}"
|
||
BorderThickness="{TemplateBinding BorderThickness}"
|
||
Padding="{TemplateBinding Padding}">
|
||
<Grid>
|
||
<ContentPresenter x:Name="ContentSite"
|
||
Content="{Binding SelectionBoxItem, RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}"
|
||
ContentTemplate="{Binding SelectionBoxItemTemplate, RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}"
|
||
ContentStringFormat="{Binding SelectionBoxItemStringFormat, RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}"
|
||
VerticalAlignment="Center"
|
||
HorizontalAlignment="Left"
|
||
Margin="6,0,0,0"/>
|
||
<Path x:Name="Arrow" Data="M0,0 L4,4 8,0" Stroke="{TemplateBinding Foreground}"
|
||
StrokeThickness="1.5" HorizontalAlignment="Right" Width="8"
|
||
VerticalAlignment="Center" Margin="0,0,6,0"/>
|
||
</Grid>
|
||
</Border>
|
||
</ControlTemplate>
|
||
</ToggleButton.Template>
|
||
</ToggleButton>
|
||
<Popup x:Name="Popup"
|
||
IsOpen="{TemplateBinding IsDropDownOpen}"
|
||
Placement="Bottom"
|
||
AllowsTransparency="True"
|
||
Focusable="False"
|
||
PopupAnimation="Slide">
|
||
<Grid MaxHeight="{TemplateBinding MaxDropDownHeight}"
|
||
MinWidth="{TemplateBinding ActualWidth}">
|
||
<Border Background="{DynamicResource Theme.InputBackground}"
|
||
BorderBrush="{DynamicResource Theme.InputBorder}"
|
||
BorderThickness="1"
|
||
SnapsToDevicePixels="True">
|
||
<ScrollViewer CanContentScroll="False">
|
||
<ItemsPresenter/>
|
||
</ScrollViewer>
|
||
</Border>
|
||
</Grid>
|
||
</Popup>
|
||
</Grid>
|
||
</ControlTemplate>
|
||
</Setter.Value>
|
||
</Setter>
|
||
</Style>
|
||
</Window.Resources>
|
||
|
||
<Grid Margin="16">
|
||
<Grid.RowDefinitions>
|
||
<RowDefinition Height="Auto"/>
|
||
<RowDefinition Height="Auto"/>
|
||
<RowDefinition Height="Auto"/>
|
||
<RowDefinition Height="Auto"/>
|
||
<RowDefinition Height="Auto"/>
|
||
<RowDefinition Height="*"/>
|
||
<RowDefinition Height="Auto"/>
|
||
<RowDefinition Height="Auto"/>
|
||
</Grid.RowDefinitions>
|
||
<Grid.ColumnDefinitions>
|
||
<ColumnDefinition Width="70"/>
|
||
<ColumnDefinition Width="*"/>
|
||
</Grid.ColumnDefinitions>
|
||
|
||
<!-- 组合名称 -->
|
||
<TextBlock Grid.Row="0" Grid.Column="0"
|
||
Text="名称:"
|
||
Foreground="{DynamicResource Theme.Foreground}"
|
||
VerticalAlignment="Center" Margin="0,0,0,10"/>
|
||
<TextBox Grid.Row="0" Grid.Column="1"
|
||
Text="{Binding Name, UpdateSourceTrigger=PropertyChanged}"
|
||
Background="{DynamicResource Theme.InputBackground}"
|
||
Foreground="{DynamicResource Theme.Foreground}"
|
||
BorderBrush="{DynamicResource Theme.InputBorder}"
|
||
VerticalContentAlignment="Center"
|
||
Height="28" Margin="0,0,0,10" Padding="6,0"/>
|
||
|
||
<!-- 图标 -->
|
||
<TextBlock Grid.Row="1" Grid.Column="0"
|
||
Text="图标:"
|
||
Foreground="{DynamicResource Theme.Foreground}"
|
||
VerticalAlignment="Center" Margin="0,0,0,10"/>
|
||
<ComboBox Grid.Row="1" Grid.Column="1"
|
||
ItemsSource="{Binding AvailableIconsView}"
|
||
SelectedItem="{Binding SelectedIcon}"
|
||
Height="28" Margin="0,0,0,10" Padding="4,0">
|
||
<ComboBox.GroupStyle>
|
||
<GroupStyle>
|
||
<GroupStyle.HeaderTemplate>
|
||
<DataTemplate>
|
||
<TextBlock Text="{Binding Name}"
|
||
FontWeight="SemiBold"
|
||
Foreground="{DynamicResource Theme.Accent}"
|
||
FontSize="11"
|
||
Margin="10,6,0,2"/>
|
||
</DataTemplate>
|
||
</GroupStyle.HeaderTemplate>
|
||
</GroupStyle>
|
||
</ComboBox.GroupStyle>
|
||
<ComboBox.ItemTemplate>
|
||
<DataTemplate>
|
||
<StackPanel Orientation="Horizontal">
|
||
<fa:IconBlock Icon="{Binding Icon}"
|
||
FontSize="16" Width="28"
|
||
Foreground="{DynamicResource Theme.Accent}"
|
||
VerticalAlignment="Center"/>
|
||
<TextBlock Text="{Binding Name}"
|
||
Foreground="{DynamicResource Theme.Foreground}"
|
||
VerticalAlignment="Center" Margin="8,0,0,0"/>
|
||
</StackPanel>
|
||
</DataTemplate>
|
||
</ComboBox.ItemTemplate>
|
||
</ComboBox>
|
||
|
||
<!-- 所属分类 -->
|
||
<TextBlock Grid.Row="2" Grid.Column="0"
|
||
Text="分类:"
|
||
Foreground="{DynamicResource Theme.Foreground}"
|
||
VerticalAlignment="Center" Margin="0,0,0,10"/>
|
||
<ComboBox Grid.Row="2" Grid.Column="1"
|
||
ItemsSource="{Binding Categories}"
|
||
SelectedItem="{Binding SelectedCategory}"
|
||
DisplayMemberPath="Name"
|
||
Height="28" Margin="0,0,0,10" Padding="4,0"/>
|
||
|
||
<!-- 快捷键 -->
|
||
<TextBlock Grid.Row="3" Grid.Column="0"
|
||
Text="快捷键:"
|
||
Foreground="{DynamicResource Theme.Foreground}"
|
||
VerticalAlignment="Center" Margin="0,0,0,10"/>
|
||
<TextBox Grid.Row="3" Grid.Column="1"
|
||
Text="{Binding HotKey, UpdateSourceTrigger=PropertyChanged}"
|
||
Background="{DynamicResource Theme.InputBackground}"
|
||
Foreground="{DynamicResource Theme.Foreground}"
|
||
BorderBrush="{DynamicResource Theme.InputBorder}"
|
||
VerticalContentAlignment="Center"
|
||
Height="28" Margin="0,0,0,10" Padding="6,0"/>
|
||
|
||
<!-- 自动运行 -->
|
||
<CheckBox Grid.Row="4" Grid.Column="1"
|
||
IsChecked="{Binding AutoRunOnStart}"
|
||
Content="随软件启动自动运行"
|
||
Foreground="{DynamicResource Theme.Foreground}"
|
||
VerticalAlignment="Center"
|
||
Margin="0,0,0,10"/>
|
||
|
||
<!-- 子工具选择 -->
|
||
<TextBlock Grid.Row="5" Grid.Column="0"
|
||
Text="包含工具:"
|
||
Foreground="{DynamicResource Theme.Foreground}"
|
||
VerticalAlignment="Top" Margin="0,4,0,0"/>
|
||
<Border Grid.Row="5" Grid.Column="1"
|
||
Background="{DynamicResource Theme.InputBackground}"
|
||
BorderBrush="{DynamicResource Theme.InputBorder}"
|
||
BorderThickness="1"
|
||
Margin="0,0,0,10">
|
||
<ListBox ItemsSource="{Binding AvailableTools}"
|
||
Background="Transparent"
|
||
BorderThickness="0"
|
||
MaxHeight="240">
|
||
<ListBox.ItemTemplate>
|
||
<DataTemplate>
|
||
<CheckBox IsChecked="{Binding IsSelected}"
|
||
Margin="4,2">
|
||
<StackPanel Orientation="Horizontal">
|
||
<TextBlock Text="{Binding Tool.Name}"
|
||
Foreground="{DynamicResource Theme.Foreground}"/>
|
||
<TextBlock Text=" [组合]"
|
||
Foreground="{DynamicResource Theme.Accent}"
|
||
FontSize="10"
|
||
VerticalAlignment="Center"
|
||
Margin="2,0,0,0">
|
||
<TextBlock.Style>
|
||
<Style TargetType="TextBlock">
|
||
<Setter Property="Visibility" Value="Collapsed"/>
|
||
<Style.Triggers>
|
||
<DataTrigger Binding="{Binding Tool.IsGroup}" Value="True">
|
||
<Setter Property="Visibility" Value="Visible"/>
|
||
</DataTrigger>
|
||
</Style.Triggers>
|
||
</Style>
|
||
</TextBlock.Style>
|
||
</TextBlock>
|
||
</StackPanel>
|
||
</CheckBox>
|
||
</DataTemplate>
|
||
</ListBox.ItemTemplate>
|
||
</ListBox>
|
||
</Border>
|
||
|
||
<!-- 按钮 -->
|
||
<StackPanel Grid.Row="7" Grid.Column="1"
|
||
Orientation="Horizontal" HorizontalAlignment="Right"
|
||
Margin="0,10,0,0">
|
||
<Button Content="保存"
|
||
Command="{Binding SaveCommand}"
|
||
Background="{DynamicResource Theme.ButtonBackground}"
|
||
Foreground="{DynamicResource Theme.ButtonForeground}"
|
||
BorderThickness="0"
|
||
Width="80" Height="30" FontSize="13"
|
||
Cursor="Hand" Margin="0,0,10,0"/>
|
||
<Button Content="取消"
|
||
Command="{Binding CancelCommand}"
|
||
Background="{DynamicResource Theme.CardBackground}"
|
||
Foreground="{DynamicResource Theme.Foreground}"
|
||
BorderBrush="{DynamicResource Theme.CardBorder}"
|
||
BorderThickness="1"
|
||
Width="80" Height="30" FontSize="13"
|
||
Cursor="Hand"/>
|
||
</StackPanel>
|
||
</Grid>
|
||
</Window>
|