<Page x:Class="XFEToolBox.Client.Views.Pages.DownloadPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:gif="http://wpfanimatedgif.codeplex.com"
xmlns:controls="clr-namespace:XFEToolBox.WpfCore.Controls;assembly=XFEToolBox.WpfCore"
Background="Transparent" Title="" Loaded="Page_Loaded">
<Page.Resources>
<Style x:Key="CategoryComboBoxItemStyle" TargetType="ComboBoxItem">
<Setter Property="Padding" Value="9,7"/>
<Setter Property="Margin" Value="0,1"/>
<Setter Property="Foreground" Value="#4F4F64"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ComboBoxItem">
<Border x:Name="ItemSurface" Padding="{TemplateBinding Padding}" Background="{TemplateBinding Background}"
BorderBrush="Transparent" BorderThickness="1" CornerRadius="8">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Border x:Name="SelectedMark" Width="3" Height="14" CornerRadius="2"
Background="Transparent" VerticalAlignment="Center"/>
<ContentPresenter Grid.Column="1" Margin="8,0,2,0" VerticalAlignment="Center"
TextElement.Foreground="{TemplateBinding Foreground}"/>
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsHighlighted" Value="True">
<Setter TargetName="ItemSurface" Property="Background" Value="#F4F4FC"/>
<Setter TargetName="ItemSurface" Property="BorderBrush" Value="#E5E5F5"/>
<Setter Property="Foreground" Value="#6262B9"/>
</Trigger>
<Trigger Property="IsSelected" Value="True">
<Setter TargetName="ItemSurface" Property="Background" Value="#ECECFB"/>
<Setter TargetName="ItemSurface" Property="BorderBrush" Value="#D2D2F1"/>
<Setter TargetName="SelectedMark" Property="Background" Value="{DynamicResource MainColor}"/>
<Setter Property="Foreground" Value="#5555B5"/>
<Setter Property="FontWeight" Value="SemiBold"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="CategoryComboBoxStyle" TargetType="ComboBox">
<Setter Property="Foreground" Value="White"/>
<Setter Property="Background" Value="#1EFFFFFF"/>
<Setter Property="BorderBrush" Value="#A8FFFFFF"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Padding" Value="12,0,8,0"/>
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="ItemContainerStyle" Value="{StaticResource CategoryComboBoxItemStyle}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ComboBox">
<Grid x:Name="ComboRoot" SnapsToDevicePixels="True">
<Border x:Name="ComboSurface" Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="11"/>
<ToggleButton x:Name="DropDownToggle" Focusable="False" ClickMode="Press" Cursor="Hand"
IsChecked="{Binding IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"
Background="Transparent" BorderThickness="0" Foreground="{TemplateBinding Foreground}"
Padding="{TemplateBinding Padding}">
<ToggleButton.Template>
<ControlTemplate TargetType="ToggleButton">
<Grid Background="Transparent">
<Grid>
<Grid.ColumnDefinitions><ColumnDefinition Width="*"/><ColumnDefinition Width="24"/></Grid.ColumnDefinitions>
<ContentPresenter Margin="{TemplateBinding Padding}" VerticalAlignment="Center" HorizontalAlignment="Left"
Content="{Binding SelectionBoxItem, RelativeSource={RelativeSource AncestorType=ComboBox}}"
ContentTemplate="{Binding SelectionBoxItemTemplate, RelativeSource={RelativeSource AncestorType=ComboBox}}"
ContentTemplateSelector="{Binding ItemTemplateSelector, RelativeSource={RelativeSource AncestorType=ComboBox}}"
ContentStringFormat="{Binding SelectionBoxItemStringFormat, RelativeSource={RelativeSource AncestorType=ComboBox}}"
TextElement.Foreground="{TemplateBinding Foreground}"/>
<Path x:Name="Arrow" Grid.Column="1" Width="8" Height="5" Stretch="Fill" Fill="#F4F4FF"
HorizontalAlignment="Center" VerticalAlignment="Center" RenderTransformOrigin="0.5,0.5"
Data="M 0,0 L 4,4 L 8,0 Z">
<Path.RenderTransform><RotateTransform Angle="0"/></Path.RenderTransform>
</Path>
</Grid>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="Arrow" Property="RenderTransform">
<Setter.Value><RotateTransform Angle="180"/></Setter.Value>
</Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</ToggleButton.Template>
</ToggleButton>
<Popup x:Name="PART_Popup" Placement="Bottom" IsOpen="{TemplateBinding IsDropDownOpen}"
AllowsTransparency="True" Focusable="False" PopupAnimation="Fade">
<Border MinWidth="{Binding ActualWidth, ElementName=ComboRoot}" Margin="0,7,0,0" Padding="6"
Background="#FEFEFF" BorderBrush="#CECEE8" BorderThickness="1" CornerRadius="12">
<Border.Effect><DropShadowEffect Color="#3C365D" BlurRadius="20" ShadowDepth="4" Opacity="0.20"/></Border.Effect>
<ScrollViewer MaxHeight="230" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
<ItemsPresenter KeyboardNavigation.DirectionalNavigation="Contained"/>
</ScrollViewer>
</Border>
</Popup>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="ComboSurface" Property="Background" Value="#2AFFFFFF"/>
<Setter TargetName="ComboSurface" Property="BorderBrush" Value="#DCFFFFFF"/>
</Trigger>
<Trigger Property="IsDropDownOpen" Value="True">
<Setter TargetName="ComboSurface" Property="Background" Value="#38FFFFFF"/>
<Setter TargetName="ComboSurface" Property="BorderBrush" Value="White"/>
</Trigger>
<Trigger Property="IsEnabled" Value="False"><Setter Property="Opacity" Value="0.58"/></Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- 软件卡片是选项卡式入口,保留独立模板,不套用普通 Button 外观。 -->
<Style x:Key="SoftwareCardStyle" TargetType="Button">
<!-- 与工具箱卡片保持一致的固定高度,虚拟化列表仅创建当前可见的卡片行。 -->
<Setter Property="Height" Value="142"/>
<Setter Property="Margin" Value="5"/>
<Setter Property="Padding" Value="0"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="VerticalContentAlignment" Value="Stretch"/>
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border x:Name="CardBorder" Margin="2" Padding="15" Background="White"
BorderBrush="#E7E7F1" BorderThickness="1" CornerRadius="16"
RenderTransformOrigin="0.5,0.5">
<Border.RenderTransform>
<ScaleTransform ScaleX="1" ScaleY="1"/>
</Border.RenderTransform>
<Border.Effect>
<DropShadowEffect Color="#7777C9" BlurRadius="14" ShadowDepth="3" Opacity="0.06"/>
</Border.Effect>
<ContentPresenter/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="CardBorder" Property="Background" Value="#FCFCFF"/>
<Setter TargetName="CardBorder" Property="BorderBrush" Value="#BEBEEE"/>
<Setter TargetName="CardBorder" Property="Effect">
<Setter.Value>
<DropShadowEffect Color="#7777C9" BlurRadius="18" ShadowDepth="4" Opacity="0.20"/>
</Setter.Value>
</Setter>
<Setter TargetName="CardBorder" Property="RenderTransform">
<Setter.Value>
<ScaleTransform ScaleX="1.016" ScaleY="1.016"/>
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter TargetName="CardBorder" Property="RenderTransform">
<Setter.Value>
<ScaleTransform ScaleX="0.985" ScaleY="0.985"/>
</Setter.Value>
</Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<DataTemplate x:Key="SoftwareCardContentTemplate">
<Button Style="{StaticResource SoftwareCardStyle}" CommandParameter="{Binding}"
Loaded="SoftwareCard_Loaded" Click="SoftwareCard_Click">
<Button.ContextMenu>
<ContextMenu DataContext="{Binding PlacementTarget.CommandParameter, RelativeSource={RelativeSource Self}}">
<MenuItem Header="固定/取消固定到主页" CommandParameter="{Binding}" Click="TogglePinnedSoftwareMenuItem_Click"/>
</ContextMenu>
</Button.ContextMenu>
<Grid>
<Grid.ColumnDefinitions><ColumnDefinition Width="60"/><ColumnDefinition Width="*"/></Grid.ColumnDefinitions>
<Border Width="48" Height="48" CornerRadius="14" Background="#EEEEFB" VerticalAlignment="Top" HorizontalAlignment="Left">
<Image gif:ImageBehavior.AnimatedSource="{Binding IconSource}"
gif:ImageBehavior.RepeatBehavior="Forever"
Width="31" Height="31" Stretch="Uniform"/>
</Border>
<Grid Grid.Column="1">
<Grid.RowDefinitions><RowDefinition Height="Auto"/><RowDefinition Height="*"/><RowDefinition Height="Auto"/></Grid.RowDefinitions>
<DockPanel LastChildFill="True">
<Border DockPanel.Dock="Right" Margin="7,0,0,0" Padding="7,3" Background="#EEEEFB" CornerRadius="7">
<TextBlock Text="{Binding DownloadModeText}" Foreground="#7777C8" FontSize="9"/>
</Border>
<controls:ScrollTextBlock InnerText="{Binding Name}" Height="22"
InnerFontSize="14" InnerFontWeight="SemiBold" InnerForeground="#3D3D52"
InnerTextAlignment="Left" AutoAlignment="False" AutoRolling="False"
IsRolling="{Binding IsMouseOver, RelativeSource={RelativeSource AncestorType=Button}, Mode=OneWay}"
RollingBack="True" RollingTimeMillisecond="2800"/>
</DockPanel>
<TextBlock Grid.Row="1" Text="{Binding Summary}" Margin="0,8,0,8" Foreground="#7F7F91" FontSize="10.5"
TextWrapping="Wrap" TextTrimming="CharacterEllipsis" MaxHeight="45"/>
<Grid Grid.Row="2">
<controls:ScrollTextBlock InnerText="{Binding Publisher}" Height="18" Margin="0,0,72,0"
InnerFontSize="9.5" InnerForeground="#A0A0B0"
InnerTextAlignment="Left" AutoAlignment="False" AutoRolling="False"
IsRolling="{Binding IsMouseOver, RelativeSource={RelativeSource AncestorType=Button}, Mode=OneWay}"
RollingBack="True" RollingTimeMillisecond="2600"/>
<TextBlock Text="{Binding Version}" HorizontalAlignment="Right" Foreground="#8585D8" FontSize="9.5"/>
</Grid>
</Grid>
</Grid>
</Button>
</DataTemplate>
<DataTemplate x:Key="SoftwareCategoryHeaderTemplate">
<Border Margin="5,9,5,2" Padding="12,8" Background="#F9F9FD"
BorderBrush="#E6E6F2" BorderThickness="1" CornerRadius="13">
<Grid>
<Grid.ColumnDefinitions><ColumnDefinition Width="3"/><ColumnDefinition Width="*"/><ColumnDefinition Width="Auto"/></Grid.ColumnDefinitions>
<Border Width="3" Height="21" Background="{Binding Category.AccentBrush}" CornerRadius="2"/>
<TextBlock Grid.Column="1" Text="{Binding Category.Name}" Margin="10,0,0,0" Foreground="#414155"
FontSize="13.5" FontWeight="SemiBold" VerticalAlignment="Center"/>
<Border Grid.Column="2" Padding="9,4" Background="{Binding Category.TintBrush}" CornerRadius="9" VerticalAlignment="Center">
<StackPanel Orientation="Horizontal">
<Ellipse Width="5" Height="5" Fill="{Binding Category.AccentBrush}" Margin="0,0,6,0" VerticalAlignment="Center"/>
<TextBlock Text="{Binding Category.CountText}" Foreground="{Binding Category.AccentBrush}" FontSize="9.5" FontWeight="SemiBold"/>
</StackPanel>
</Border>
</Grid>
</Border>
</DataTemplate>
<DataTemplate x:Key="SoftwareCardsRowTemplate">
<Grid>
<Grid.ColumnDefinitions><ColumnDefinition Width="*"/><ColumnDefinition Width="*"/></Grid.ColumnDefinitions>
<ContentControl Content="{Binding PrimaryCard}" ContentTemplate="{StaticResource SoftwareCardContentTemplate}"/>
<ContentControl Grid.Column="1" Content="{Binding SecondaryCard}" ContentTemplate="{StaticResource SoftwareCardContentTemplate}"
Visibility="{Binding SecondaryCardVisibility}"/>
</Grid>
</DataTemplate>
<DataTemplate x:Key="SoftwareCatalogRowTemplate">
<ContentControl Content="{Binding}" Focusable="False">
<ContentControl.Style>
<Style TargetType="ContentControl">
<Setter Property="ContentTemplate" Value="{StaticResource SoftwareCardsRowTemplate}"/>
<Style.Triggers>
<DataTrigger Binding="{Binding IsHeader}" Value="True">
<Setter Property="ContentTemplate" Value="{StaticResource SoftwareCategoryHeaderTemplate}"/>
</DataTrigger>
</Style.Triggers>
</Style>
</ContentControl.Style>
</ContentControl>
</DataTemplate>
</Page.Resources>
<Grid Margin="14,10,14,12">
<Grid.RowDefinitions><RowDefinition Height="Auto"/><RowDefinition Height="*"/><RowDefinition Height="Auto"/></Grid.RowDefinitions>
<Grid Margin="0,0,0,10">
<Grid.ColumnDefinitions><ColumnDefinition Width="*"/><ColumnDefinition Width="128"/><ColumnDefinition Width="Auto"/><ColumnDefinition Width="Auto"/></Grid.ColumnDefinitions>
<controls:TextEditor x:Name="SearchTextBox" Height="38" Padding="11,0" Background="#1EFFFFFF" Foreground="White" CaretBrush="White"
EditorCornerRadius="11" EditorBorderBrush="#A8FFFFFF" EditorHoverBorderBrush="#DCFFFFFF" EditorFocusedBorderBrush="White"
HintText="搜索软件名称、介绍、发布者或标签" HintForeground="#EEEEFF" HintTextMargin="0" Icon="{StaticResource SearchIconGeometry}"
IconBrush="#F4F4FF" ToolTip="搜索软件名称、介绍、发布者或标签" KeyDown="SearchTextBox_KeyDown"/>
<ComboBox x:Name="CategoryFilter" Grid.Column="1" Height="38" Margin="8,0,0,0"
Style="{StaticResource CategoryComboBoxStyle}" VerticalContentAlignment="Center"
SelectionChanged="CategoryFilter_SelectionChanged"/>
<Button x:Name="SearchButton" Grid.Column="2" Content="搜索" controls:ButtonAssist.IsPrimary="True" Height="38" Margin="8,0,0,0"
Background="#2AFFFFFF" Foreground="White" BorderBrush="#B8FFFFFF" BorderThickness="1"
controls:ButtonAssist.CornerRadius="11"
controls:ButtonAssist.HoverBackground="#42FFFFFF" controls:ButtonAssist.HoverForeground="White" controls:ButtonAssist.HoverBorderBrush="White"
controls:ButtonAssist.PressedBackground="#20FFFFFF" controls:ButtonAssist.PressedForeground="White" controls:ButtonAssist.PressedBorderBrush="#E8FFFFFF"
Click="SearchButton_Click"/>
<Button x:Name="RefreshButton" Grid.Column="3" Content="刷新" Height="38" Margin="8,0,0,0" Click="RefreshButton_Click"/>
</Grid>
<Border Grid.Row="1" Background="White" CornerRadius="18" Padding="7">
<Grid>
<ListBox x:Name="SoftwareCards" Background="Transparent" BorderThickness="0" Padding="0"
Focusable="False" HorizontalContentAlignment="Stretch"
ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Auto"
ScrollViewer.CanContentScroll="True" VirtualizingPanel.IsVirtualizing="True"
VirtualizingPanel.VirtualizationMode="Recycling" VirtualizingPanel.ScrollUnit="Pixel"
VirtualizingPanel.CacheLength="1" VirtualizingPanel.CacheLengthUnit="Page"
ItemTemplate="{StaticResource SoftwareCatalogRowTemplate}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate><VirtualizingStackPanel/></ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="Padding" Value="0"/>
<Setter Property="Margin" Value="0"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="Focusable" Value="False"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<ContentPresenter HorizontalAlignment="Stretch"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
<StackPanel x:Name="EmptyState" HorizontalAlignment="Center" VerticalAlignment="Center" Visibility="Collapsed">
<Border Width="58" Height="58" Background="#ECECF8" CornerRadius="19" HorizontalAlignment="Center"><Image Source="/Resources/Image/download.png" Width="28" Height="28" Opacity="0.7"/></Border>
<TextBlock x:Name="EmptyTitle" Text="暂时没有找到软件" Foreground="#68687D" FontSize="13" FontWeight="SemiBold" HorizontalAlignment="Center" Margin="0,11,0,0"/>
<TextBlock x:Name="EmptyHint" Text="可以换个关键词,或稍后刷新再试" Foreground="#A0A0B0" FontSize="10" HorizontalAlignment="Center" Margin="0,4,0,0"/>
</StackPanel>
</Grid>
</Border>
<Grid Grid.Row="2" Margin="4,9,4,0">
<TextBlock x:Name="StatusText" Text="准备就绪" Foreground="White" FontSize="10.5" VerticalAlignment="Center" TextTrimming="CharacterEllipsis"/>
<TextBlock x:Name="SoftwareCountText" HorizontalAlignment="Right" Foreground="#DEDEFA" FontSize="10" VerticalAlignment="Center"/>
</Grid>
</Grid>
</Page>
<Page x:Class="XFEToolBox.Client.Views.Pages.DownloadPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:gif="http://wpfanimatedgif.codeplex.com"
xmlns:controls="clr-namespace:XFEToolBox.WpfCore.Controls;assembly=XFEToolBox.WpfCore"
Background="Transparent" Title="" Loaded="Page_Loaded">
<Page.Resources>
<Style x:Key="CategoryComboBoxItemStyle" TargetType="ComboBoxItem">
<Setter Property="Padding" Value="9,7"/>
<Setter Property="Margin" Value="0,1"/>
<Setter Property="Foreground" Value="#4F4F64"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ComboBoxItem">
<Border x:Name="ItemSurface" Padding="{TemplateBinding Padding}" Background="{TemplateBinding Background}"
BorderBrush="Transparent" BorderThickness="1" CornerRadius="8">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Border x:Name="SelectedMark" Width="3" Height="14" CornerRadius="2"
Background="Transparent" VerticalAlignment="Center"/>
<ContentPresenter Grid.Column="1" Margin="8,0,2,0" VerticalAlignment="Center"
TextElement.Foreground="{TemplateBinding Foreground}"/>
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsHighlighted" Value="True">
<Setter TargetName="ItemSurface" Property="Background" Value="#F4F4FC"/>
<Setter TargetName="ItemSurface" Property="BorderBrush" Value="#E5E5F5"/>
<Setter Property="Foreground" Value="#6262B9"/>
</Trigger>
<Trigger Property="IsSelected" Value="True">
<Setter TargetName="ItemSurface" Property="Background" Value="#ECECFB"/>
<Setter TargetName="ItemSurface" Property="BorderBrush" Value="#D2D2F1"/>
<Setter TargetName="SelectedMark" Property="Background" Value="{DynamicResource MainColor}"/>
<Setter Property="Foreground" Value="#5555B5"/>
<Setter Property="FontWeight" Value="SemiBold"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="CategoryComboBoxStyle" TargetType="ComboBox">
<Setter Property="Foreground" Value="White"/>
<Setter Property="Background" Value="#1EFFFFFF"/>
<Setter Property="BorderBrush" Value="#A8FFFFFF"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Padding" Value="12,0,8,0"/>
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="ItemContainerStyle" Value="{StaticResource CategoryComboBoxItemStyle}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ComboBox">
<Grid x:Name="ComboRoot" SnapsToDevicePixels="True">
<Border x:Name="ComboSurface" Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="11"/>
<ToggleButton x:Name="DropDownToggle" Focusable="False" ClickMode="Press" Cursor="Hand"
IsChecked="{Binding IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"
Background="Transparent" BorderThickness="0" Foreground="{TemplateBinding Foreground}"
Padding="{TemplateBinding Padding}">
<ToggleButton.Template>
<ControlTemplate TargetType="ToggleButton">
<Grid Background="Transparent">
<Grid>
<Grid.ColumnDefinitions><ColumnDefinition Width="*"/><ColumnDefinition Width="24"/></Grid.ColumnDefinitions>
<ContentPresenter Margin="{TemplateBinding Padding}" VerticalAlignment="Center" HorizontalAlignment="Left"
Content="{Binding SelectionBoxItem, RelativeSource={RelativeSource AncestorType=ComboBox}}"
ContentTemplate="{Binding SelectionBoxItemTemplate, RelativeSource={RelativeSource AncestorType=ComboBox}}"
ContentTemplateSelector="{Binding ItemTemplateSelector, RelativeSource={RelativeSource AncestorType=ComboBox}}"
ContentStringFormat="{Binding SelectionBoxItemStringFormat, RelativeSource={RelativeSource AncestorType=ComboBox}}"
TextElement.Foreground="{TemplateBinding Foreground}"/>
<Path x:Name="Arrow" Grid.Column="1" Width="8" Height="5" Stretch="Fill" Fill="#F4F4FF"
HorizontalAlignment="Center" VerticalAlignment="Center" RenderTransformOrigin="0.5,0.5"
Data="M 0,0 L 4,4 L 8,0 Z">
<Path.RenderTransform><RotateTransform Angle="0"/></Path.RenderTransform>
</Path>
</Grid>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="Arrow" Property="RenderTransform">
<Setter.Value><RotateTransform Angle="180"/></Setter.Value>
</Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</ToggleButton.Template>
</ToggleButton>
<Popup x:Name="PART_Popup" Placement="Bottom" IsOpen="{TemplateBinding IsDropDownOpen}"
AllowsTransparency="True" Focusable="False" PopupAnimation="Fade">
<Border MinWidth="{Binding ActualWidth, ElementName=ComboRoot}" Margin="0,7,0,0" Padding="6"
Background="#FEFEFF" BorderBrush="#CECEE8" BorderThickness="1" CornerRadius="12">
<Border.Effect><DropShadowEffect Color="#3C365D" BlurRadius="20" ShadowDepth="4" Opacity="0.20"/></Border.Effect>
<ScrollViewer MaxHeight="230" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
<ItemsPresenter KeyboardNavigation.DirectionalNavigation="Contained"/>
</ScrollViewer>
</Border>
</Popup>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="ComboSurface" Property="Background" Value="#2AFFFFFF"/>
<Setter TargetName="ComboSurface" Property="BorderBrush" Value="#DCFFFFFF"/>
</Trigger>
<Trigger Property="IsDropDownOpen" Value="True">
<Setter TargetName="ComboSurface" Property="Background" Value="#38FFFFFF"/>
<Setter TargetName="ComboSurface" Property="BorderBrush" Value="White"/>
</Trigger>
<Trigger Property="IsEnabled" Value="False"><Setter Property="Opacity" Value="0.58"/></Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- 软件卡片是选项卡式入口,保留独立模板,不套用普通 Button 外观。 -->
<Style x:Key="SoftwareCardStyle" TargetType="Button">
<!-- 与工具箱卡片保持一致的固定高度,虚拟化列表仅创建当前可见的卡片行。 -->
<Setter Property="Height" Value="142"/>
<Setter Property="Margin" Value="5"/>
<Setter Property="Padding" Value="0"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="VerticalContentAlignment" Value="Stretch"/>
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border x:Name="CardBorder" Margin="2" Padding="15" Background="White"
BorderBrush="#E7E7F1" BorderThickness="1" CornerRadius="16"
RenderTransformOrigin="0.5,0.5">
<Border.RenderTransform>
<ScaleTransform ScaleX="1" ScaleY="1"/>
</Border.RenderTransform>
<Border.Effect>
<DropShadowEffect Color="#7777C9" BlurRadius="14" ShadowDepth="3" Opacity="0.06"/>
</Border.Effect>
<ContentPresenter/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="CardBorder" Property="Background" Value="#FCFCFF"/>
<Setter TargetName="CardBorder" Property="BorderBrush" Value="#BEBEEE"/>
<Setter TargetName="CardBorder" Property="Effect">
<Setter.Value>
<DropShadowEffect Color="#7777C9" BlurRadius="18" ShadowDepth="4" Opacity="0.20"/>
</Setter.Value>
</Setter>
<Setter TargetName="CardBorder" Property="RenderTransform">
<Setter.Value>
<ScaleTransform ScaleX="1.016" ScaleY="1.016"/>
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter TargetName="CardBorder" Property="RenderTransform">
<Setter.Value>
<ScaleTransform ScaleX="0.985" ScaleY="0.985"/>
</Setter.Value>
</Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<DataTemplate x:Key="SoftwareCardContentTemplate">
<Button Style="{StaticResource SoftwareCardStyle}" CommandParameter="{Binding}"
Loaded="SoftwareCard_Loaded" Click="SoftwareCard_Click">
<Button.ContextMenu>
<ContextMenu DataContext="{Binding PlacementTarget.CommandParameter, RelativeSource={RelativeSource Self}}">
<MenuItem Header="固定/取消固定到主页" CommandParameter="{Binding}" Click="TogglePinnedSoftwareMenuItem_Click"/>
</ContextMenu>
</Button.ContextMenu>
<Grid>
<Grid.ColumnDefinitions><ColumnDefinition Width="60"/><ColumnDefinition Width="*"/></Grid.ColumnDefinitions>
<Border Width="48" Height="48" CornerRadius="14" Background="#EEEEFB" VerticalAlignment="Top" HorizontalAlignment="Left">
<Image gif:ImageBehavior.AnimatedSource="{Binding IconSource}"
gif:ImageBehavior.RepeatBehavior="Forever"
Width="31" Height="31" Stretch="Uniform"/>
</Border>
<Grid Grid.Column="1">
<Grid.RowDefinitions><RowDefinition Height="Auto"/><RowDefinition Height="*"/><RowDefinition Height="Auto"/></Grid.RowDefinitions>
<DockPanel LastChildFill="True">
<Border DockPanel.Dock="Right" Margin="7,0,0,0" Padding="7,3" Background="#EEEEFB" CornerRadius="7">
<TextBlock Text="{Binding DownloadModeText}" Foreground="#7777C8" FontSize="9"/>
</Border>
<controls:ScrollTextBlock InnerText="{Binding Name}" Height="22"
InnerFontSize="14" InnerFontWeight="SemiBold" InnerForeground="#3D3D52"
InnerTextAlignment="Left" AutoAlignment="False" AutoRolling="False"
IsRolling="{Binding IsMouseOver, RelativeSource={RelativeSource AncestorType=Button}, Mode=OneWay}"
RollingBack="True" RollingTimeMillisecond="2800"/>
</DockPanel>
<TextBlock Grid.Row="1" Text="{Binding Summary}" Margin="0,8,0,8" Foreground="#7F7F91" FontSize="10.5"
TextWrapping="Wrap" TextTrimming="CharacterEllipsis" MaxHeight="45"/>
<Grid Grid.Row="2">
<controls:ScrollTextBlock InnerText="{Binding Publisher}" Height="18" Margin="0,0,72,0"
InnerFontSize="9.5" InnerForeground="#A0A0B0"
InnerTextAlignment="Left" AutoAlignment="False" AutoRolling="False"
IsRolling="{Binding IsMouseOver, RelativeSource={RelativeSource AncestorType=Button}, Mode=OneWay}"
RollingBack="True" RollingTimeMillisecond="2600"/>
<TextBlock Text="{Binding Version}" HorizontalAlignment="Right" Foreground="#8585D8" FontSize="9.5"/>
</Grid>
</Grid>
</Grid>
</Button>
</DataTemplate>
<DataTemplate x:Key="SoftwareCategoryHeaderTemplate">
<Border Margin="5,9,5,2" Padding="12,8" Background="#F9F9FD"
BorderBrush="#E6E6F2" BorderThickness="1" CornerRadius="13">
<Grid>
<Grid.ColumnDefinitions><ColumnDefinition Width="3"/><ColumnDefinition Width="*"/><ColumnDefinition Width="Auto"/></Grid.ColumnDefinitions>
<Border Width="3" Height="21" Background="{Binding Category.AccentBrush}" CornerRadius="2"/>
<TextBlock Grid.Column="1" Text="{Binding Category.Name}" Margin="10,0,0,0" Foreground="#414155"
FontSize="13.5" FontWeight="SemiBold" VerticalAlignment="Center"/>
<Border Grid.Column="2" Padding="9,4" Background="{Binding Category.TintBrush}" CornerRadius="9" VerticalAlignment="Center">
<StackPanel Orientation="Horizontal">
<Ellipse Width="5" Height="5" Fill="{Binding Category.AccentBrush}" Margin="0,0,6,0" VerticalAlignment="Center"/>
<TextBlock Text="{Binding Category.CountText}" Foreground="{Binding Category.AccentBrush}" FontSize="9.5" FontWeight="SemiBold"/>
</StackPanel>
</Border>
</Grid>
</Border>
</DataTemplate>
<DataTemplate x:Key="SoftwareCardsRowTemplate">
<Grid>
<Grid.ColumnDefinitions><ColumnDefinition Width="*"/><ColumnDefinition Width="*"/></Grid.ColumnDefinitions>
<ContentControl Content="{Binding PrimaryCard}" ContentTemplate="{StaticResource SoftwareCardContentTemplate}"/>
<ContentControl Grid.Column="1" Content="{Binding SecondaryCard}" ContentTemplate="{StaticResource SoftwareCardContentTemplate}"
Visibility="{Binding SecondaryCardVisibility}"/>
</Grid>
</DataTemplate>
<DataTemplate x:Key="SoftwareCatalogRowTemplate">
<ContentControl Content="{Binding}" Focusable="False">
<ContentControl.Style>
<Style TargetType="ContentControl">
<Setter Property="ContentTemplate" Value="{StaticResource SoftwareCardsRowTemplate}"/>
<Style.Triggers>
<DataTrigger Binding="{Binding IsHeader}" Value="True">
<Setter Property="ContentTemplate" Value="{StaticResource SoftwareCategoryHeaderTemplate}"/>
</DataTrigger>
</Style.Triggers>
</Style>
</ContentControl.Style>
</ContentControl>
</DataTemplate>
</Page.Resources>
<Grid Margin="14,10,14,12">
<Grid.RowDefinitions><RowDefinition Height="Auto"/><RowDefinition Height="*"/><RowDefinition Height="Auto"/></Grid.RowDefinitions>
<Grid Margin="0,0,0,10">
<Grid.ColumnDefinitions><ColumnDefinition Width="*"/><ColumnDefinition Width="128"/><ColumnDefinition Width="Auto"/><ColumnDefinition Width="Auto"/></Grid.ColumnDefinitions>
<controls:TextEditor x:Name="SearchTextBox" Height="38" Padding="11,0" Background="#1EFFFFFF" Foreground="White" CaretBrush="White"
EditorCornerRadius="11" EditorBorderBrush="#A8FFFFFF" EditorHoverBorderBrush="#DCFFFFFF" EditorFocusedBorderBrush="White"
HintText="搜索软件名称、介绍、发布者或标签" HintForeground="#EEEEFF" HintTextMargin="0" Icon="{StaticResource SearchIconGeometry}"
IconBrush="#F4F4FF" ToolTip="搜索软件名称、介绍、发布者或标签" KeyDown="SearchTextBox_KeyDown"/>
<ComboBox x:Name="CategoryFilter" Grid.Column="1" Height="38" Margin="8,0,0,0"
Style="{StaticResource CategoryComboBoxStyle}" VerticalContentAlignment="Center"
SelectionChanged="CategoryFilter_SelectionChanged"/>
<Button x:Name="SearchButton" Grid.Column="2" Content="搜索" controls:ButtonAssist.IsPrimary="True" Height="38" Margin="8,0,0,0"
Background="#2AFFFFFF" Foreground="White" BorderBrush="#B8FFFFFF" BorderThickness="1"
controls:ButtonAssist.CornerRadius="11"
controls:ButtonAssist.HoverBackground="#42FFFFFF" controls:ButtonAssist.HoverForeground="White" controls:ButtonAssist.HoverBorderBrush="White"
controls:ButtonAssist.PressedBackground="#20FFFFFF" controls:ButtonAssist.PressedForeground="White" controls:ButtonAssist.PressedBorderBrush="#E8FFFFFF"
Click="SearchButton_Click"/>
<Button x:Name="RefreshButton" Grid.Column="3" Content="刷新" Height="38" Margin="8,0,0,0" Click="RefreshButton_Click"/>
</Grid>
<Border Grid.Row="1" Background="White" CornerRadius="18" Padding="7">
<Grid>
<ListBox x:Name="SoftwareCards" Background="Transparent" BorderThickness="0" Padding="0"
Focusable="False" HorizontalContentAlignment="Stretch"
ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Auto"
ScrollViewer.CanContentScroll="True" VirtualizingPanel.IsVirtualizing="True"
VirtualizingPanel.VirtualizationMode="Recycling" VirtualizingPanel.ScrollUnit="Pixel"
VirtualizingPanel.CacheLength="1" VirtualizingPanel.CacheLengthUnit="Page"
ItemTemplate="{StaticResource SoftwareCatalogRowTemplate}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate><VirtualizingStackPanel/></ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="Padding" Value="0"/>
<Setter Property="Margin" Value="0"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="Focusable" Value="False"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<ContentPresenter HorizontalAlignment="Stretch"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
<StackPanel x:Name="EmptyState" HorizontalAlignment="Center" VerticalAlignment="Center" Visibility="Collapsed">
<Border Width="58" Height="58" Background="#ECECF8" CornerRadius="19" HorizontalAlignment="Center"><Image Source="/Resources/Image/download.png" Width="28" Height="28" Opacity="0.7"/></Border>
<TextBlock x:Name="EmptyTitle" Text="暂时没有找到软件" Foreground="#68687D" FontSize="13" FontWeight="SemiBold" HorizontalAlignment="Center" Margin="0,11,0,0"/>
<TextBlock x:Name="EmptyHint" Text="可以换个关键词,或稍后刷新再试" Foreground="#A0A0B0" FontSize="10" HorizontalAlignment="Center" Margin="0,4,0,0"/>
</StackPanel>
</Grid>
</Border>
<Grid Grid.Row="2" Margin="4,9,4,0">
<TextBlock x:Name="StatusText" Text="准备就绪" Foreground="White" FontSize="10.5" VerticalAlignment="Center" TextTrimming="CharacterEllipsis"/>
<TextBlock x:Name="SoftwareCountText" HorizontalAlignment="Right" Foreground="#DEDEFA" FontSize="10" VerticalAlignment="Center"/>
</Grid>
</Grid>
</Page>