Global dark theme

This commit is contained in:
Paddy Xu
2018-04-18 22:23:28 +03:00
parent 9eea55b7aa
commit 8c4a37e3a6
21 changed files with 100 additions and 52 deletions

View File

@@ -37,7 +37,7 @@ namespace QuickLook.Common.Plugin
private bool _titlebarBlurVisibility;
private bool _titlebarColourVisibility = true;
private bool _titlebarOverlap;
private bool _useDarkTheme;
private Themes _theme = Themes.None;
private object _viewerContent;
/// <summary>
@@ -168,12 +168,12 @@ namespace QuickLook.Common.Plugin
/// <summary>
/// Switch to dark theme?
/// </summary>
public bool UseDarkTheme
public Themes Theme
{
get => _useDarkTheme;
get => _theme;
set
{
_useDarkTheme = value;
_theme = value;
OnPropertyChanged();
}
}
@@ -213,7 +213,7 @@ namespace QuickLook.Common.Plugin
CanResize = true;
FullWindowDragging = false;
UseDarkTheme = false;
Theme = Themes.None;
TitlebarOverlap = false;
TitlebarAutoHide = false;
TitlebarBlurVisibility = false;

View File

@@ -0,0 +1,26 @@
// Copyright © 2018 Paddy Xu
//
// This file is part of QuickLook program.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
namespace QuickLook.Common.Plugin
{
public enum Themes
{
None,
Dark,
Light
}
}

View File

@@ -57,6 +57,7 @@
<Compile Include="Plugin\IViewer.cs" />
<Compile Include="NativeMethods\Kernel32.cs" />
<Compile Include="Helpers\ProcessHelper.cs" />
<Compile Include="Plugin\Themes.cs" />
<Compile Include="Properties\Annotations.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Helpers\SettingHelper.cs" />
@@ -64,6 +65,19 @@
<Compile Include="NativeMethods\User32.cs" />
<Compile Include="Helpers\WindowHelper.cs" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Page Include="Styles\MainWindowStyles.Dark.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Styles\MainWindowStyles.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Styles\ScrollBarStyleDictionary.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -0,0 +1,15 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<SolidColorBrush x:Key="MainWindowBackground" Color="#CC292929" />
<SolidColorBrush x:Key="MainWindowBackgroundNoTransparent" Color="#FF292929" />
<SolidColorBrush x:Key="WindowTextForeground" Color="#FFEFEFEF" />
<SolidColorBrush x:Key="WindowTextForegroundAlternative" Color="#FFD4D4D4" />
<SolidColorBrush x:Key="CaptionTextHoverBorder" Color="#DDB9B9B9" />
<SolidColorBrush x:Key="CaptionButtonIconForeground" Color="#E5EFEFEF" />
<SolidColorBrush x:Key="CaptionButtonHoverBackground" Color="#22FFFFFF" />
<SolidColorBrush x:Key="CaptionButtonPressBackground" Color="#44FFFFFF" />
<SolidColorBrush x:Key="CaptionCloseButtonHoverForeground" Color="#E5EFEFEF" />
<SolidColorBrush x:Key="CaptionCloseButtonHoverBackground" Color="#FFE81123" />
<SolidColorBrush x:Key="CaptionCloseButtonPressBackground" Color="#FFB5394B" />
<SolidColorBrush x:Key="CaptionBackground" Color="#CC0E0E0E" />
</ResourceDictionary>

View File

@@ -0,0 +1,93 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<Thickness x:Key="MainWindowShadowMarginThickness">1</Thickness>
<Thickness x:Key="MainWindowResizeThickness">6</Thickness>
<system:Double x:Key="MainWindowCaptionHeight">32</system:Double>
<SolidColorBrush x:Key="MainWindowBackground" Color="#BBFAFAFA" />
<SolidColorBrush x:Key="MainWindowBackgroundNoTransparent" Color="#FFFAFAFA" />
<SolidColorBrush x:Key="WindowTextForeground" Color="#FF0E0E0E" />
<SolidColorBrush x:Key="WindowTextForegroundAlternative" Color="#FF626262" />
<SolidColorBrush x:Key="CaptionTextHoverBorder" Color="#FF3D3D3D" />
<SolidColorBrush x:Key="CaptionButtonIconForeground" Color="#E50E0E0E" />
<SolidColorBrush x:Key="CaptionButtonHoverBackground" Color="#44FFFFFF" />
<SolidColorBrush x:Key="CaptionButtonPressBackground" Color="#88FFFFFF" />
<SolidColorBrush x:Key="CaptionCloseButtonHoverForeground" Color="#E5EFEFEF" />
<SolidColorBrush x:Key="CaptionCloseButtonHoverBackground" Color="#FFE81123" />
<SolidColorBrush x:Key="CaptionCloseButtonPressBackground" Color="#FFB5394B" />
<SolidColorBrush x:Key="CaptionBackground" Color="#BBDADADA" />
<Style x:Key="CaptionButtonBaseStyle" TargetType="Button">
<Setter Property="Focusable" Value="False" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="Foreground" Value="{DynamicResource WindowTextForeground}" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="WindowChrome.IsHitTestVisibleInChrome" Value="True" />
</Style>
<Style x:Key="CaptionTextButtonStyle" TargetType="Button" BasedOn="{StaticResource CaptionButtonBaseStyle}">
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Padding" Value="6,2,6,2" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Background="{TemplateBinding Background}"
BorderThickness="{TemplateBinding BorderThickness}"
BorderBrush="{TemplateBinding BorderBrush}" Padding="{TemplateBinding Padding}">
<ContentPresenter />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="BorderBrush" Value="{DynamicResource CaptionTextHoverBorder}" />
<Setter Property="Background" Value="{DynamicResource CaptionButtonHoverBackground}" />
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background" Value="{DynamicResource CaptionButtonPressBackground}" />
</Trigger>
</Style.Triggers>
</Style>
<Style x:Key="CaptionButtonStyle" TargetType="Button" BasedOn="{StaticResource CaptionButtonBaseStyle}">
<Setter Property="Width" Value="45" />
<Setter Property="Height" Value="32" />
<Setter Property="FontSize" Value="13" />
<Setter Property="FontFamily" Value="{StaticResource SegoeMDL2}" />
<Setter Property="Foreground" Value="{DynamicResource CaptionButtonIconForeground}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border Background="{TemplateBinding Background}" BorderThickness="0"
Padding="{TemplateBinding Padding}">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="{DynamicResource CaptionButtonHoverBackground}" />
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background" Value="{DynamicResource CaptionButtonPressBackground}" />
</Trigger>
</Style.Triggers>
</Style>
<Style x:Key="CaptionCloseButtonStyle" TargetType="Button" BasedOn="{StaticResource CaptionButtonStyle}">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Foreground" Value="{DynamicResource CaptionCloseButtonHoverForeground}" />
<Setter Property="Background" Value="{DynamicResource CaptionCloseButtonHoverBackground}" />
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background" Value="{DynamicResource CaptionCloseButtonPressBackground}" />
</Trigger>
</Style.Triggers>
</Style>
</ResourceDictionary>

View File

@@ -0,0 +1,171 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<SolidColorBrush x:Key="StandardBorderBrush" Color="#888" />
<SolidColorBrush x:Key="StandardBackgroundBrush" Color="#FFF" />
<SolidColorBrush x:Key="HoverBorderBrush" Color="#DDD" />
<SolidColorBrush x:Key="SelectedBackgroundBrush" Color="Gray" />
<SolidColorBrush x:Key="SelectedForegroundBrush" Color="White" />
<SolidColorBrush x:Key="DisabledForegroundBrush" Color="#888" />
<SolidColorBrush x:Key="NormalBrush" Color="#888" />
<SolidColorBrush x:Key="NormalBorderBrush" Color="#888" />
<SolidColorBrush x:Key="HorizontalNormalBrush" Color="#888" />
<SolidColorBrush x:Key="HorizontalNormalBorderBrush" Color="#888" />
<LinearGradientBrush x:Key="StandardBrush"
StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#FFF" Offset="0.0" />
<GradientStop Color="#CCC" Offset="1.0" />
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<SolidColorBrush x:Key="GlyphBrush" Color="#444" />
<LinearGradientBrush x:Key="PressedBrush"
StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#BBB" Offset="0.0" />
<GradientStop Color="#EEE" Offset="0.1" />
<GradientStop Color="#EEE" Offset="0.9" />
<GradientStop Color="#FFF" Offset="1.0" />
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<!-- SrollViewer ScrollBar Repeat Buttons (at each end) -->
<Style x:Key="ScrollBarLineButton" TargetType="{x:Type RepeatButton}">
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="OverridesDefaultStyle" Value="true" />
<Setter Property="Focusable" Value="false" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RepeatButton}">
<Border x:Name="Border" Margin="1" CornerRadius="2" Background="{StaticResource NormalBrush}"
BorderBrush="{StaticResource NormalBorderBrush}" BorderThickness="0.25">
<Path HorizontalAlignment="Center" VerticalAlignment="Center"
Fill="{StaticResource GlyphBrush}"
Data="{Binding Path=Content, RelativeSource={RelativeSource TemplatedParent}}" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsPressed" Value="true">
<Setter TargetName="Border" Property="Background"
Value="{StaticResource PressedBrush}" />
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground"
Value="{StaticResource DisabledForegroundBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- SrollViewer ScrollBar Repeat Buttons (The part in the middle,
not the thumb the long area between the buttons ) -->
<Style x:Key="ScrollBarPageButton" TargetType="{x:Type RepeatButton}">
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="OverridesDefaultStyle" Value="true" />
<Setter Property="IsTabStop" Value="false" />
<Setter Property="Focusable" Value="false" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RepeatButton}">
<Border Background="Transparent" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- ScrollViewer ScrollBar Thumb, that part that can be dragged
up/down or left/right Buttons -->
<Style x:Key="ScrollBarThumb" TargetType="{x:Type Thumb}">
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="OverridesDefaultStyle" Value="true" />
<Setter Property="IsTabStop" Value="false" />
<Setter Property="Focusable" Value="false" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Thumb}">
<Border CornerRadius="2" Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="0.25" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- VerticalScrollBar Template using the previously created Templates -->
<ControlTemplate x:Key="VerticalScrollBar"
TargetType="{x:Type ScrollBar}">
<Grid Width="13">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Border Grid.RowSpan="3" CornerRadius="2" Background="Transparent" />
<Track x:Name="PART_Track" Grid.Row="0" IsDirectionReversed="true">
<Track.DecreaseRepeatButton>
<RepeatButton Style="{StaticResource ScrollBarPageButton}" Command="ScrollBar.PageUpCommand" />
</Track.DecreaseRepeatButton>
<Track.Thumb>
<Thumb Style="{StaticResource ScrollBarThumb}" Margin="1,0"
Background="{StaticResource HorizontalNormalBrush}"
BorderBrush="{StaticResource HorizontalNormalBorderBrush}" />
</Track.Thumb>
<Track.IncreaseRepeatButton>
<RepeatButton Style="{StaticResource ScrollBarPageButton}" Command="ScrollBar.PageDownCommand" />
</Track.IncreaseRepeatButton>
</Track>
</Grid>
</ControlTemplate>
<!-- HorizontalScrollBar Template using the previously created Templates -->
<ControlTemplate x:Key="HorizontalScrollBar"
TargetType="{x:Type ScrollBar}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Border
Grid.ColumnSpan="3"
CornerRadius="2"
Background="Transparent" />
<Track
x:Name="PART_Track"
Grid.Column="0"
IsDirectionReversed="False">
<Track.DecreaseRepeatButton>
<RepeatButton
Style="{StaticResource ScrollBarPageButton}"
Command="ScrollBar.PageLeftCommand" />
</Track.DecreaseRepeatButton>
<Track.Thumb>
<Thumb
Style="{StaticResource ScrollBarThumb}"
Margin="0,2"
Background="{StaticResource NormalBrush}"
BorderBrush="{StaticResource NormalBorderBrush}" />
</Track.Thumb>
<Track.IncreaseRepeatButton>
<RepeatButton
Style="{StaticResource ScrollBarPageButton}"
Command="ScrollBar.PageRightCommand" />
</Track.IncreaseRepeatButton>
</Track>
</Grid>
</ControlTemplate>
<!-- Style for overall ScrollBar -->
<Style x:Key="{x:Type ScrollBar}" TargetType="{x:Type ScrollBar}">
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="OverridesDefaultStyle" Value="true" />
<Style.Triggers>
<Trigger Property="Orientation" Value="Horizontal">
<Setter Property="Width" Value="Auto" />
<Setter Property="Height" Value="15" />
<Setter Property="Template"
Value="{StaticResource HorizontalScrollBar}" />
</Trigger>
<Trigger Property="Orientation" Value="Vertical">
<Setter Property="Width" Value="13" />
<Setter Property="Height" Value="Auto" />
<Setter Property="Template"
Value="{StaticResource VerticalScrollBar}" />
</Trigger>
</Style.Triggers>
</Style>
</ResourceDictionary>