Fix styling issues in the Search Panel #1592

This commit is contained in:
ema
2025-04-23 22:38:14 +08:00
parent fd01082a3d
commit b6c4ad5ac7
4 changed files with 195 additions and 1 deletions

View File

@@ -0,0 +1,70 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:ICSharpCode.AvalonEdit.Search;assembly=ICSharpCode.AvalonEdit">
<!-- Colors for DropDownButton and SplitButton -->
<SolidColorBrush x:Key="{ComponentResourceKey {x:Type local:DropDownButton}, ActiveBorder}" Color="#FF0A246A" />
<SolidColorBrush x:Key="{ComponentResourceKey {x:Type local:DropDownButton}, ActiveBackground}" Color="#FFB6BDD2" />
<!-- Style and Template for DropDownButton -->
<Style TargetType="{x:Type local:DropDownButton}">
<!--<Setter Property="TextElement.Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />-->
<Setter Property="Control.Padding" Value="2,2,2,2" />
<Setter Property="Border.BorderThickness" Value="1,1,1,1" />
<Setter Property="Panel.Background" Value="Transparent" />
<Setter Property="Border.BorderBrush" Value="Transparent" />
<Setter Property="FrameworkElement.HorizontalAlignment" Value="Center" />
<Setter Property="FrameworkElement.VerticalAlignment" Value="Center" />
<Setter Property="Control.HorizontalContentAlignment" Value="Center" />
<Setter Property="Control.VerticalContentAlignment" Value="Center" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate xmlns:s="clr-namespace:System;assembly=mscorlib" TargetType="local:DropDownButton">
<Border Name="OuterBorder"
Background="{TemplateBinding Panel.Background}"
BorderBrush="{TemplateBinding Border.BorderBrush}"
BorderThickness="{TemplateBinding Border.BorderThickness}"
SnapsToDevicePixels="True">
<StackPanel Orientation="Horizontal">
<ContentPresenter Margin="{TemplateBinding Control.Padding}"
HorizontalAlignment="{TemplateBinding Control.HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding Control.VerticalContentAlignment}"
Content="{TemplateBinding ContentControl.Content}"
ContentStringFormat="{TemplateBinding ContentControl.ContentStringFormat}"
ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}"
SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
<!-- CaretDownSolid8 -->
<TextBlock Width="6"
Margin="0,2,2,2"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontFamily="{DynamicResource SymbolThemeFontFamily}"
FontSize="6"
Foreground="{DynamicResource TextFillColorPrimaryBrush}"
Text="&#xeddc;" />
</StackPanel>
</Border>
<ControlTemplate.Triggers>
<!--<Trigger Property="UIElement.IsMouseOver" Value="True">
<Setter TargetName="OuterBorder" Property="Border.BorderBrush" Value="{DynamicResource {ComponentResourceKey {x:Type local:DropDownButton}, ActiveBorder}}" />
<Setter TargetName="OuterBorder" Property="Panel.Background" Value="{DynamicResource {ComponentResourceKey {x:Type local:DropDownButton}, ActiveBackground}}" />
</Trigger>-->
<!--<Trigger Property="UIElement.IsKeyboardFocused" Value="True">
<Setter TargetName="OuterBorder" Property="Border.BorderBrush" Value="{DynamicResource {ComponentResourceKey {x:Type local:DropDownButton}, ActiveBorder}}" />
<Setter TargetName="OuterBorder" Property="Panel.Background" Value="{DynamicResource {ComponentResourceKey {x:Type local:DropDownButton}, ActiveBackground}}" />
</Trigger>-->
<!--<Trigger Property="UIElement.IsEnabled" Value="False">
<Setter Property="TextElement.Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
</Trigger>-->
<!--<Trigger Property="local:DropDownButton.IsDropDownContentOpen" Value="True">
<Setter TargetName="OuterBorder" Property="Border.BorderBrush" Value="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}" />
<Setter TargetName="OuterBorder" Property="Border.BorderThickness" Value="1,1,1,0" />
<Setter TargetName="OuterBorder" Property="Border.Padding" Value="0,0,0,1" />
<Setter TargetName="OuterBorder" Property="Panel.Background" Value="Transparent" />
</Trigger>-->
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>

View File

@@ -0,0 +1,110 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:search="clr-namespace:ICSharpCode.AvalonEdit.Search;assembly=ICSharpCode.AvalonEdit">
<Style TargetType="search:SearchPanel">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type search:SearchPanel}">
<!-- For compatibility, the Card itself is not used for the time being. -->
<!-- Background="{DynamicResource CardBackgroundBrush}" -->
<!-- BorderBrush="{DynamicResource CardBorderBrush}" -->
<Border Margin="0,-1,16,0"
Padding="2"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Background="{DynamicResource WindowBackground}"
BorderBrush="#102E2E3E"
BorderThickness="1"
CornerRadius="4"
Cursor="Arrow">
<StackPanel Orientation="Horizontal">
<TextBox Name="PART_searchTextBox"
Width="150"
Height="29"
Padding="4,5,0,0"
FocusVisualStyle="{x:Null}"
Focusable="True">
<TextBox.Text>
<Binding Path="SearchPattern"
RelativeSource="{RelativeSource TemplatedParent}"
UpdateSourceTrigger="PropertyChanged">
<Binding.ValidationRules>
<ExceptionValidationRule />
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
<search:DropDownButton Height="24">
<search:DropDownButton.DropDownContent>
<Popup Name="PART_dropdownPopup"
AllowsTransparency="True"
StaysOpen="False">
<Border Background="{DynamicResource WindowBackground}"
BorderBrush="{DynamicResource CardBorderBrush}"
BorderThickness="1"
CornerRadius="4">
<StackPanel Orientation="Vertical">
<CheckBox Margin="3"
Content="{Binding Localization.MatchCaseText, RelativeSource={RelativeSource TemplatedParent}}"
IsChecked="{Binding MatchCase, RelativeSource={RelativeSource TemplatedParent}}" />
<CheckBox Margin="3"
Content="{Binding Localization.MatchWholeWordsText, RelativeSource={RelativeSource TemplatedParent}}"
IsChecked="{Binding WholeWords, RelativeSource={RelativeSource TemplatedParent}}" />
<CheckBox Margin="3"
Content="{Binding Localization.UseRegexText, RelativeSource={RelativeSource TemplatedParent}}"
IsChecked="{Binding UseRegex, RelativeSource={RelativeSource TemplatedParent}}" />
</StackPanel>
</Border>
</Popup>
</search:DropDownButton.DropDownContent>
</search:DropDownButton>
<Button Width="24"
Height="24"
Margin="3,3,0,3"
Padding="0"
Command="search:SearchCommands.FindPrevious"
ToolTip="{Binding Localization.FindPreviousText, RelativeSource={RelativeSource TemplatedParent}}">
<!-- ChevronUp -->
<TextBlock HorizontalAlignment="Center"
VerticalAlignment="Center"
FontFamily="{DynamicResource SymbolThemeFontFamily}"
FontSize="12"
Text="&#xe70e;" />
</Button>
<Button Width="24"
Height="24"
Margin="3"
Padding="0"
Command="search:SearchCommands.FindNext"
ToolTip="{Binding Localization.FindNextText, RelativeSource={RelativeSource TemplatedParent}}">
<!-- ChevronDown -->
<TextBlock HorizontalAlignment="Center"
VerticalAlignment="Center"
FontFamily="{DynamicResource SymbolThemeFontFamily}"
FontSize="12"
Text="&#xe70d;" />
</Button>
<Button Width="16"
Height="16"
Padding="0"
HorizontalAlignment="Right"
VerticalAlignment="Top"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center"
Command="search:SearchCommands.CloseSearchPanel"
Focusable="False">
<!-- CalculatorMultiply -->
<TextBlock HorizontalAlignment="Center"
VerticalAlignment="Center"
FontFamily="{DynamicResource SymbolThemeFontFamily}"
FontSize="10"
Text="&#xe947;" />
</Button>
</StackPanel>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>

View File

@@ -49,6 +49,20 @@ public class Plugin : IViewer
_hlmLight = GetHighlightingManager(Themes.Light, "Light"); _hlmLight = GetHighlightingManager(Themes.Light, "Light");
_hlmDark = GetHighlightingManager(Themes.Dark, "Dark"); _hlmDark = GetHighlightingManager(Themes.Dark, "Dark");
// Implementation of the Search Panel Styled with Fluent Theme
{
var groupDictionary = new ResourceDictionary();
groupDictionary.MergedDictionaries.Add(new ResourceDictionary()
{
Source = new Uri("pack://application:,,,/QuickLook.Plugin.TextViewer;component/Controls/DropDownButton.xaml", UriKind.Absolute)
});
groupDictionary.MergedDictionaries.Add(new ResourceDictionary()
{
Source = new Uri("pack://application:,,,/QuickLook.Plugin.TextViewer;component/Controls/SearchPanel.xaml", UriKind.Absolute)
});
Application.Current.Resources.MergedDictionaries.Add(groupDictionary);
}
} }
public bool CanHandle(string path) public bool CanHandle(string path)

View File

@@ -59,7 +59,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="AvalonEdit" Version="6.3.0.90" /> <PackageReference Include="AvalonEdit" Version="6.3.1.120" />
<PackageReference Include="UTF.Unknown" Version="2.5.1" /> <PackageReference Include="UTF.Unknown" Version="2.5.1" />
<Reference Include="WindowsBase" /> <Reference Include="WindowsBase" />
</ItemGroup> </ItemGroup>