Files
better-genshin-impact/BetterGenshinImpact/View/PickerWindow.xaml

188 lines
9.5 KiB
XML

<ui:FluentWindow x:Class="BetterGenshinImpact.View.PickerWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:view="clr-namespace:BetterGenshinImpact.View"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
ui:Design.Background="{DynamicResource ApplicationBackgroundBrush}"
ui:Design.Foreground="{DynamicResource TextFillColorPrimaryBrush}"
Title="选择捕获窗口"
Width="800"
Height="450"
ExtendsContentIntoTitleBar="True"
WindowStartupLocation="CenterScreen"
Loaded="Window_Loaded"
PreviewKeyDown="FluentWindow_PreviewKeyDown">
<ui:FluentWindow.Resources>
<!-- ListBoxItem Fluent UI 样式 -->
<Style TargetType="ListBoxItem">
<Setter Property="Margin" Value="8,4" />
<Setter Property="Padding" Value="12" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Foreground" Value="{DynamicResource TextFillColorPrimaryBrush}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<Border x:Name="Border"
Background="{TemplateBinding Background}"
CornerRadius="8"
BorderThickness="1"
BorderBrush="Transparent">
<Grid>
<Border x:Name="SelectionBackground"
Background="{DynamicResource ControlFillColorSecondaryBrush}"
CornerRadius="8"
Opacity="0"/>
<ContentPresenter />
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="SelectionBackground" Property="Opacity" Value="0.1" />
<Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource ControlElevationBorderBrush}" />
</Trigger>
<Trigger Property="IsSelected" Value="True">
<Setter TargetName="SelectionBackground" Property="Opacity" Value="0.2" />
<Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource ControlStrokeColorDefaultBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ui:FluentWindow.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<!-- 标题区域 -->
<Border Grid.Row="0"
Padding="24,36,24,20">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Text="选择捕获窗口"
FontSize="24"
FontWeight="SemiBold"
Foreground="{DynamicResource TextFillColorPrimaryBrush}"/>
<TextBlock Grid.Row="1"
Text="双击选中要捕获的窗口"
Margin="0,8,0,0"
Foreground="{DynamicResource TextFillColorTertiaryBrush}"
FontSize="14"/>
</Grid>
</Border>
<!--内容区域-->
<Border Grid.Row="1"
Background="{DynamicResource ControlFillColorDefaultBrush}"
CornerRadius="8"
Margin="15,0">
<ListBox x:Name="WindowList"
Background="Transparent"
BorderThickness="0"
Foreground="{DynamicResource TextFillColorPrimaryBrush}"
MouseDoubleClick="WindowsOnMouseDoubleClick"
VirtualizingPanel.IsVirtualizing="True"
VirtualizingPanel.VirtualizationMode="Recycling"
ScrollViewer.CanContentScroll="False"
ScrollViewer.VerticalScrollBarVisibility="Auto"
ScrollViewer.HorizontalScrollBarVisibility="Auto">
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="Padding" Value="0"/>
<Setter Property="Margin" Value="4"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Foreground" Value="{DynamicResource TextFillColorPrimaryBrush}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<Border x:Name="Border"
Background="{TemplateBinding Background}"
CornerRadius="8"
BorderThickness="1"
BorderBrush="Transparent">
<ContentPresenter />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Border" Property="Background">
<Setter.Value>
<SolidColorBrush Color="{DynamicResource ControlFillColorSecondary}" Opacity="0.5"/>
</Setter.Value>
</Setter>
<Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource ControlElevationBorderBrush}" />
</Trigger>
<Trigger Property="IsSelected" Value="True">
<Setter TargetName="Border" Property="Background">
<Setter.Value>
<SolidColorBrush Color="{DynamicResource ControlFillColorSecondary}" Opacity="0.7"/>
</Setter.Value>
</Setter>
<Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource ControlStrokeColorDefaultBrush}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type view:CapturableWindow}">
<Grid Margin="12,8" Height="48">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<!-- 内容层 -->
<Border Grid.Column="0"
Width="40"
Height="40"
Background="{DynamicResource ControlFillColorDefaultBrush}"
CornerRadius="4"
Margin="0,0,12,0">
<Image Width="24"
Height="24"
Source="{Binding Icon}"
RenderOptions.BitmapScalingMode="HighQuality"/>
</Border>
<StackPanel Grid.Column="1"
VerticalAlignment="Center">
<TextBlock Text="{Binding Name}"
FontSize="14"
FontWeight="SemiBold"
Foreground="{DynamicResource TextFillColorPrimaryBrush}"/>
<TextBlock Text="{Binding ProcessName}"
FontSize="12"
Foreground="{DynamicResource TextFillColorTertiaryBrush}"
Margin="0,4,0,0"/>
</StackPanel>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Border>
<!-- 底部操作区域 -->
<Grid Grid.Row="2" Margin="12">
<ui:Button
Name="cancelButton"
HorizontalAlignment="Right"
Width="100"
Margin="5"
Click="cancelButton_Click">取消</ui:Button>
</Grid>
</Grid>
</ui:FluentWindow>