Skip to content

Commit b6c4ad5

Browse files
committed
Fix styling issues in the Search Panel #1592
1 parent fd01082 commit b6c4ad5

File tree

4 files changed

+195
-1
lines changed

4 files changed

+195
-1
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3+
xmlns:local="clr-namespace:ICSharpCode.AvalonEdit.Search;assembly=ICSharpCode.AvalonEdit">
4+
5+
<!-- Colors for DropDownButton and SplitButton -->
6+
<SolidColorBrush x:Key="{ComponentResourceKey {x:Type local:DropDownButton}, ActiveBorder}" Color="#FF0A246A" />
7+
<SolidColorBrush x:Key="{ComponentResourceKey {x:Type local:DropDownButton}, ActiveBackground}" Color="#FFB6BDD2" />
8+
9+
<!-- Style and Template for DropDownButton -->
10+
<Style TargetType="{x:Type local:DropDownButton}">
11+
<!--<Setter Property="TextElement.Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />-->
12+
<Setter Property="Control.Padding" Value="2,2,2,2" />
13+
<Setter Property="Border.BorderThickness" Value="1,1,1,1" />
14+
<Setter Property="Panel.Background" Value="Transparent" />
15+
<Setter Property="Border.BorderBrush" Value="Transparent" />
16+
<Setter Property="FrameworkElement.HorizontalAlignment" Value="Center" />
17+
<Setter Property="FrameworkElement.VerticalAlignment" Value="Center" />
18+
<Setter Property="Control.HorizontalContentAlignment" Value="Center" />
19+
<Setter Property="Control.VerticalContentAlignment" Value="Center" />
20+
<Setter Property="Template">
21+
<Setter.Value>
22+
<ControlTemplate xmlns:s="clr-namespace:System;assembly=mscorlib" TargetType="local:DropDownButton">
23+
<Border Name="OuterBorder"
24+
Background="{TemplateBinding Panel.Background}"
25+
BorderBrush="{TemplateBinding Border.BorderBrush}"
26+
BorderThickness="{TemplateBinding Border.BorderThickness}"
27+
SnapsToDevicePixels="True">
28+
<StackPanel Orientation="Horizontal">
29+
<ContentPresenter Margin="{TemplateBinding Control.Padding}"
30+
HorizontalAlignment="{TemplateBinding Control.HorizontalContentAlignment}"
31+
VerticalAlignment="{TemplateBinding Control.VerticalContentAlignment}"
32+
Content="{TemplateBinding ContentControl.Content}"
33+
ContentStringFormat="{TemplateBinding ContentControl.ContentStringFormat}"
34+
ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}"
35+
SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
36+
<!-- CaretDownSolid8 -->
37+
<TextBlock Width="6"
38+
Margin="0,2,2,2"
39+
HorizontalAlignment="Center"
40+
VerticalAlignment="Center"
41+
FontFamily="{DynamicResource SymbolThemeFontFamily}"
42+
FontSize="6"
43+
Foreground="{DynamicResource TextFillColorPrimaryBrush}"
44+
Text="&#xeddc;" />
45+
</StackPanel>
46+
</Border>
47+
<ControlTemplate.Triggers>
48+
<!--<Trigger Property="UIElement.IsMouseOver" Value="True">
49+
<Setter TargetName="OuterBorder" Property="Border.BorderBrush" Value="{DynamicResource {ComponentResourceKey {x:Type local:DropDownButton}, ActiveBorder}}" />
50+
<Setter TargetName="OuterBorder" Property="Panel.Background" Value="{DynamicResource {ComponentResourceKey {x:Type local:DropDownButton}, ActiveBackground}}" />
51+
</Trigger>-->
52+
<!--<Trigger Property="UIElement.IsKeyboardFocused" Value="True">
53+
<Setter TargetName="OuterBorder" Property="Border.BorderBrush" Value="{DynamicResource {ComponentResourceKey {x:Type local:DropDownButton}, ActiveBorder}}" />
54+
<Setter TargetName="OuterBorder" Property="Panel.Background" Value="{DynamicResource {ComponentResourceKey {x:Type local:DropDownButton}, ActiveBackground}}" />
55+
</Trigger>-->
56+
<!--<Trigger Property="UIElement.IsEnabled" Value="False">
57+
<Setter Property="TextElement.Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
58+
</Trigger>-->
59+
<!--<Trigger Property="local:DropDownButton.IsDropDownContentOpen" Value="True">
60+
<Setter TargetName="OuterBorder" Property="Border.BorderBrush" Value="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}" />
61+
<Setter TargetName="OuterBorder" Property="Border.BorderThickness" Value="1,1,1,0" />
62+
<Setter TargetName="OuterBorder" Property="Border.Padding" Value="0,0,0,1" />
63+
<Setter TargetName="OuterBorder" Property="Panel.Background" Value="Transparent" />
64+
</Trigger>-->
65+
</ControlTemplate.Triggers>
66+
</ControlTemplate>
67+
</Setter.Value>
68+
</Setter>
69+
</Style>
70+
</ResourceDictionary>
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3+
xmlns:search="clr-namespace:ICSharpCode.AvalonEdit.Search;assembly=ICSharpCode.AvalonEdit">
4+
5+
<Style TargetType="search:SearchPanel">
6+
<Setter Property="Template">
7+
<Setter.Value>
8+
<ControlTemplate TargetType="{x:Type search:SearchPanel}">
9+
<!-- For compatibility, the Card itself is not used for the time being. -->
10+
<!-- Background="{DynamicResource CardBackgroundBrush}" -->
11+
<!-- BorderBrush="{DynamicResource CardBorderBrush}" -->
12+
<Border Margin="0,-1,16,0"
13+
Padding="2"
14+
HorizontalAlignment="Right"
15+
VerticalAlignment="Top"
16+
Background="{DynamicResource WindowBackground}"
17+
BorderBrush="#102E2E3E"
18+
BorderThickness="1"
19+
CornerRadius="4"
20+
Cursor="Arrow">
21+
<StackPanel Orientation="Horizontal">
22+
<TextBox Name="PART_searchTextBox"
23+
Width="150"
24+
Height="29"
25+
Padding="4,5,0,0"
26+
FocusVisualStyle="{x:Null}"
27+
Focusable="True">
28+
<TextBox.Text>
29+
<Binding Path="SearchPattern"
30+
RelativeSource="{RelativeSource TemplatedParent}"
31+
UpdateSourceTrigger="PropertyChanged">
32+
<Binding.ValidationRules>
33+
<ExceptionValidationRule />
34+
</Binding.ValidationRules>
35+
</Binding>
36+
</TextBox.Text>
37+
</TextBox>
38+
<search:DropDownButton Height="24">
39+
<search:DropDownButton.DropDownContent>
40+
<Popup Name="PART_dropdownPopup"
41+
AllowsTransparency="True"
42+
StaysOpen="False">
43+
<Border Background="{DynamicResource WindowBackground}"
44+
BorderBrush="{DynamicResource CardBorderBrush}"
45+
BorderThickness="1"
46+
CornerRadius="4">
47+
<StackPanel Orientation="Vertical">
48+
<CheckBox Margin="3"
49+
Content="{Binding Localization.MatchCaseText, RelativeSource={RelativeSource TemplatedParent}}"
50+
IsChecked="{Binding MatchCase, RelativeSource={RelativeSource TemplatedParent}}" />
51+
<CheckBox Margin="3"
52+
Content="{Binding Localization.MatchWholeWordsText, RelativeSource={RelativeSource TemplatedParent}}"
53+
IsChecked="{Binding WholeWords, RelativeSource={RelativeSource TemplatedParent}}" />
54+
<CheckBox Margin="3"
55+
Content="{Binding Localization.UseRegexText, RelativeSource={RelativeSource TemplatedParent}}"
56+
IsChecked="{Binding UseRegex, RelativeSource={RelativeSource TemplatedParent}}" />
57+
</StackPanel>
58+
</Border>
59+
</Popup>
60+
</search:DropDownButton.DropDownContent>
61+
</search:DropDownButton>
62+
<Button Width="24"
63+
Height="24"
64+
Margin="3,3,0,3"
65+
Padding="0"
66+
Command="search:SearchCommands.FindPrevious"
67+
ToolTip="{Binding Localization.FindPreviousText, RelativeSource={RelativeSource TemplatedParent}}">
68+
<!-- ChevronUp -->
69+
<TextBlock HorizontalAlignment="Center"
70+
VerticalAlignment="Center"
71+
FontFamily="{DynamicResource SymbolThemeFontFamily}"
72+
FontSize="12"
73+
Text="&#xe70e;" />
74+
</Button>
75+
<Button Width="24"
76+
Height="24"
77+
Margin="3"
78+
Padding="0"
79+
Command="search:SearchCommands.FindNext"
80+
ToolTip="{Binding Localization.FindNextText, RelativeSource={RelativeSource TemplatedParent}}">
81+
<!-- ChevronDown -->
82+
<TextBlock HorizontalAlignment="Center"
83+
VerticalAlignment="Center"
84+
FontFamily="{DynamicResource SymbolThemeFontFamily}"
85+
FontSize="12"
86+
Text="&#xe70d;" />
87+
</Button>
88+
<Button Width="16"
89+
Height="16"
90+
Padding="0"
91+
HorizontalAlignment="Right"
92+
VerticalAlignment="Top"
93+
HorizontalContentAlignment="Center"
94+
VerticalContentAlignment="Center"
95+
Command="search:SearchCommands.CloseSearchPanel"
96+
Focusable="False">
97+
<!-- CalculatorMultiply -->
98+
<TextBlock HorizontalAlignment="Center"
99+
VerticalAlignment="Center"
100+
FontFamily="{DynamicResource SymbolThemeFontFamily}"
101+
FontSize="10"
102+
Text="&#xe947;" />
103+
</Button>
104+
</StackPanel>
105+
</Border>
106+
</ControlTemplate>
107+
</Setter.Value>
108+
</Setter>
109+
</Style>
110+
</ResourceDictionary>

QuickLook.Plugin/QuickLook.Plugin.TextViewer/Plugin.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,20 @@ public void Init()
4949

5050
_hlmLight = GetHighlightingManager(Themes.Light, "Light");
5151
_hlmDark = GetHighlightingManager(Themes.Dark, "Dark");
52+
53+
// Implementation of the Search Panel Styled with Fluent Theme
54+
{
55+
var groupDictionary = new ResourceDictionary();
56+
groupDictionary.MergedDictionaries.Add(new ResourceDictionary()
57+
{
58+
Source = new Uri("pack://application:,,,/QuickLook.Plugin.TextViewer;component/Controls/DropDownButton.xaml", UriKind.Absolute)
59+
});
60+
groupDictionary.MergedDictionaries.Add(new ResourceDictionary()
61+
{
62+
Source = new Uri("pack://application:,,,/QuickLook.Plugin.TextViewer;component/Controls/SearchPanel.xaml", UriKind.Absolute)
63+
});
64+
Application.Current.Resources.MergedDictionaries.Add(groupDictionary);
65+
}
5266
}
5367

5468
public bool CanHandle(string path)

QuickLook.Plugin/QuickLook.Plugin.TextViewer/QuickLook.Plugin.TextViewer.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
</PropertyGroup>
6060

6161
<ItemGroup>
62-
<PackageReference Include="AvalonEdit" Version="6.3.0.90" />
62+
<PackageReference Include="AvalonEdit" Version="6.3.1.120" />
6363
<PackageReference Include="UTF.Unknown" Version="2.5.1" />
6464
<Reference Include="WindowsBase" />
6565
</ItemGroup>

0 commit comments

Comments
 (0)