[PowerLauncher] Fix getting theme changed event for and between HighContrast setting

This commit is contained in:
punker76
2020-10-31 11:58:31 +01:00
parent f89b98e7c7
commit fa1448163a
10 changed files with 198 additions and 15 deletions

View File

@@ -12,6 +12,7 @@
<system:String x:Key="Theme.BaseColorScheme">Dark</system:String>
<system:String x:Key="Theme.ColorScheme">Accent1</system:String>
<Color x:Key="Theme.PrimaryAccentColor">Black</Color>
<system:Boolean x:Key="Theme.IsHighContrast">False</system:Boolean>
<Color x:Key="SystemBaseMediumLowColor">#FF818181</Color>
<SolidColorBrush x:Key="SystemChromeLow" Color="#FF171717" options:Freeze="True" />
@@ -35,7 +36,7 @@
<Color x:Key="ScrollBarBackgroundPointerOver">#FF1b1b1b</Color>
<SolidColorBrush x:Key="ScrollBarLineButtonForeground">#FFcdcdcd</SolidColorBrush>
<SolidColorBrush x:Key="ScrollBarLineButtonForeground" Color="#FFcdcdcd" />
<Color x:Key="ScrollBarLineButtonForegroundPointerOver">#FFcdcdcd</Color>
<Color x:Key="ScrollBarLineButtonForegroundPointerPressed">#FF171717</Color>

View File

@@ -12,6 +12,7 @@
<system:String x:Key="Theme.BaseColorScheme">HighContrast</system:String>
<system:String x:Key="Theme.ColorScheme">Accent2</system:String>
<Color x:Key="Theme.PrimaryAccentColor">White</Color>
<system:Boolean x:Key="Theme.IsHighContrast">True</system:Boolean>
<Color x:Key="SystemBaseMediumLowColor">#ffff00</Color>
<SolidColorBrush x:Key="SystemChromeLow" Color="Black" options:Freeze="True" />
@@ -35,7 +36,7 @@
<Color x:Key="ScrollBarBackgroundPointerOver">#FF000000</Color>
<SolidColorBrush x:Key="ScrollBarLineButtonForeground">#FFFFFFFF</SolidColorBrush>
<SolidColorBrush x:Key="ScrollBarLineButtonForeground" Color="#FFFFFFFF" />
<Color x:Key="ScrollBarLineButtonForegroundPointerOver">#FFFFFFFF</Color>
<Color x:Key="ScrollBarLineButtonForegroundPointerPressed">#FFFFFFFF</Color>

View File

@@ -12,6 +12,7 @@
<system:String x:Key="Theme.BaseColorScheme">HighContrast</system:String>
<system:String x:Key="Theme.ColorScheme">Accent3</system:String>
<Color x:Key="Theme.PrimaryAccentColor">White</Color>
<system:Boolean x:Key="Theme.IsHighContrast">True</system:Boolean>
<Color x:Key="SystemBaseMediumLowColor">#ffff00</Color>
<SolidColorBrush x:Key="SystemChromeLow" Color="Black" options:Freeze="True" />
@@ -35,7 +36,7 @@
<Color x:Key="ScrollBarBackgroundPointerOver">#FF000000</Color>
<SolidColorBrush x:Key="ScrollBarLineButtonForeground">#FFFFFFFF</SolidColorBrush>
<SolidColorBrush x:Key="ScrollBarLineButtonForeground" Color="#FFFFFFFF" />
<Color x:Key="ScrollBarLineButtonForegroundPointerOver">#FFFFFFFF</Color>
<Color x:Key="ScrollBarLineButtonForegroundPointerPressed">#FFFFFFFF</Color>

View File

@@ -12,6 +12,7 @@
<system:String x:Key="Theme.BaseColorScheme">HighContrast</system:String>
<system:String x:Key="Theme.ColorScheme">Accent4</system:String>
<Color x:Key="Theme.PrimaryAccentColor">White</Color>
<system:Boolean x:Key="Theme.IsHighContrast">True</system:Boolean>
<Color x:Key="SystemBaseMediumLowColor">#66FFFFFF</Color>
<SolidColorBrush x:Key="SystemChromeLow" Color="Black" options:Freeze="True" />
@@ -35,7 +36,7 @@
<Color x:Key="ScrollBarBackgroundPointerOver">#FF000000</Color>
<SolidColorBrush x:Key="ScrollBarLineButtonForeground">#FFFFFFFF</SolidColorBrush>
<SolidColorBrush x:Key="ScrollBarLineButtonForeground" Color="#FFFFFFFF" />
<Color x:Key="ScrollBarLineButtonForegroundPointerOver">#FFFFFFFF</Color>
<Color x:Key="ScrollBarLineButtonForegroundPointerPressed">#FFFFFFFF</Color>

View File

@@ -12,6 +12,7 @@
<system:String x:Key="Theme.BaseColorScheme">HighContrast</system:String>
<system:String x:Key="Theme.ColorScheme">Accent5</system:String>
<Color x:Key="Theme.PrimaryAccentColor">White</Color>
<system:Boolean x:Key="Theme.IsHighContrast">True</system:Boolean>
<Color x:Key="SystemBaseMediumLowColor">#66000000</Color>
<SolidColorBrush x:Key="SystemChromeLow" Color="White" options:Freeze="True" />
@@ -35,7 +36,7 @@
<Color x:Key="ScrollBarBackgroundPointerOver">#FFf0f0f0</Color>
<SolidColorBrush x:Key="ScrollBarLineButtonForeground">#FF000000</SolidColorBrush>
<SolidColorBrush x:Key="ScrollBarLineButtonForeground" Color="#FF000000" />
<Color x:Key="ScrollBarLineButtonForegroundPointerOver">#FF000000</Color>
<Color x:Key="ScrollBarLineButtonForegroundPointerPressed">#FF000000</Color>

View File

@@ -12,6 +12,7 @@
<system:String x:Key="Theme.BaseColorScheme">Light</system:String>
<system:String x:Key="Theme.ColorScheme">Accent1</system:String>
<Color x:Key="Theme.PrimaryAccentColor">White</Color>
<system:Boolean x:Key="Theme.IsHighContrast">False</system:Boolean>
<Color x:Key="SystemBaseMediumLowColor">#66000000</Color>
<SolidColorBrush x:Key="SystemChromeLow" Color="#FFF2F2F2" options:Freeze="True" />
@@ -35,7 +36,7 @@
<Color x:Key="ScrollBarBackgroundPointerOver">#FFf0f0f0</Color>
<SolidColorBrush x:Key="ScrollBarLineButtonForeground">#FF1d1d1d</SolidColorBrush>
<SolidColorBrush x:Key="ScrollBarLineButtonForeground" Color="#FF1d1d1d" />
<Color x:Key="ScrollBarLineButtonForegroundPointerOver">#FF1d1d1d</Color>
<Color x:Key="ScrollBarLineButtonForegroundPointerPressed">#FFf3f3f3</Color>

View File

@@ -0,0 +1,111 @@
{
"DefaultValues": {
"Theme.IsHighContrast": "false"
},
"BaseColorSchemes": [
{
"Name": "Dark",
"Values": {
"PrimaryAccentColor": "Black",
"SystemBaseMediumLowColor": "#FF818181",
"SystemChromeLow": "#FF171717",
"TextControlPlaceholderForeground": "#FF818181",
"TextBox.Static.Border": "Transparent",
"TextBox.MouseOver.Border": "Transparent",
"TextBox.Focus.Border": "Transparent",
"ButtonBackgroundPointerOver": "#30FFFFFF",
"ButtonBorderPointerOver": "#61FFFFFF",
"ButtonBackgroundPressed": "#30FFFFFF",
"ButtonBorderPressed": "#61FFFFFF",
"ListViewItemBackgroundPointerOver": "#FF363636",
"ControlTextBrushKey": "White",
"SecondaryTextForeground": "#FFa1a1a1",
"InactiveSelectionHighlightBrushKey": "White",
"DialogBorderBrush": "#FF373737",
"ScrollBarThumbBackground": "#FF7a7a7a",
"ScrollBarThumbPointerOver": "#FF767676",
"ScrollBarThumbPointerPressed": "#FFa4a4a4",
"ScrollBarBackgroundPointerOver": "#FF1b1b1b",
"ScrollBarLineButtonForeground": "#FFcdcdcd",
"ScrollBarLineButtonForegroundPointerOver": "#FFcdcdcd",
"ScrollBarLineButtonForegroundPointerPressed": "#FF171717",
"ScrollBarLineButtonBackground": "Transparent",
"ScrollBarLineButtonBackgroundPointerOver": "#FF313131",
"ScrollBarLineButtonBackgroundPointerPressed": "#FFa4a4a4",
"ToolTipBorderBrushKey": "#5B000000",
"ToolTipForegroundBrushKey": "#FFFFFFFF",
"ToolTipBackgroundBrushKey": "#FF2B2B2B"
}
},
{
"Name": "Light",
"Values": {
"PrimaryAccentColor": "White",
"SystemBaseMediumLowColor": "#66000000",
"SystemChromeLow": "#FFF2F2F2",
"TextControlPlaceholderForeground": "#FF5b5b5b",
"TextBox.Static.Border": "Transparent",
"TextBox.MouseOver.Border": "Transparent",
"TextBox.Focus.Border": "Transparent",
"ButtonBackgroundPointerOver": "#2E000000",
"ButtonBorderPointerOver": "#61000000",
"ButtonBackgroundPressed": "#30000000",
"ButtonBorderPressed": "#61000000",
"ListViewItemBackgroundPointerOver": "#FFd2d2d2",
"ControlTextBrushKey": "Black",
"SecondaryTextForeground": "#FF434343",
"InactiveSelectionHighlightBrushKey": "Black",
"DialogBorderBrush": "#FFf7f7f7",
"ScrollBarThumbBackground": "#FF7a7a7a",
"ScrollBarThumbPointerOver": "#FFa0a0a0",
"ScrollBarThumbPointerPressed": "#FF747474",
"ScrollBarBackgroundPointerOver": "#FFf0f0f0",
"ScrollBarLineButtonForeground": "#FF1d1d1d",
"ScrollBarLineButtonForegroundPointerOver": "#FF1d1d1d",
"ScrollBarLineButtonForegroundPointerPressed": "#FFf3f3f3",
"ScrollBarLineButtonBackground": "Transparent",
"ScrollBarLineButtonBackgroundPointerOver": "#FFd2d2d2",
"ScrollBarLineButtonBackgroundPointerPressed": "#FF5d5d5d",
"ToolTipBorderBrushKey": "#FFD0D0D0",
"ToolTipForegroundBrushKey": "#FF000000",
"ToolTipBackgroundBrushKey": "#FFFBFBFB"
}
},
{
"Name": "HighContrast",
"Values": {
"Theme.IsHighContrast": "true",
"PrimaryAccentColor": "White",
"SystemBaseMediumLowColor": "#ffff00",
"SystemChromeLow": "Black",
"TextControlPlaceholderForeground": "#FF008000",
"TextBox.Static.Border": "Transparent",
"TextBox.MouseOver.Border": "Transparent",
"TextBox.Focus.Border": "Transparent",
"ButtonBackgroundPointerOver": "Black",
"ButtonBorderPointerOver": "White",
"ButtonBackgroundPressed": "White",
"ButtonBorderPressed": "White",
"ListViewItemBackgroundPointerOver": "#FF003300",
"ControlTextBrushKey": "#FFffff00",
"SecondaryTextForeground": "#FF008000",
"InactiveSelectionHighlightBrushKey": "#FFFFFFFF",
"DialogBorderBrush": "#FF373737",
"ScrollBarThumbBackground": "White",
"ScrollBarThumbPointerOver": "#FF008000",
"ScrollBarThumbPointerPressed": "#FF008000",
"ScrollBarBackgroundPointerOver": "#FF000000",
"ScrollBarLineButtonForeground": "#FFFFFFFF",
"ScrollBarLineButtonForegroundPointerOver": "#FFFFFFFF",
"ScrollBarLineButtonForegroundPointerPressed": "#FFFFFFFF",
"ScrollBarLineButtonBackground": "Black",
"ScrollBarLineButtonBackgroundPointerOver": "#FF000000",
"ScrollBarLineButtonBackgroundPointerPressed": "#FF000000",
"ToolTipBorderBrushKey": "#5B000000",
"ToolTipForegroundBrushKey": "#FFFFFFFF",
"ToolTipBackgroundBrushKey": "#FF2B2B2B"
}
}
],
"ColorSchemes": []
}

View File

@@ -0,0 +1,50 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:options="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options"
xmlns:system="clr-namespace:System;assembly=System.Runtime"
mc:Ignorable="options">
<!-- Metadata -->
<system:String x:Key="Theme.Name">{{ThemeName}}</system:String>
<system:String x:Key="Theme.Origin">PowerToysRun</system:String>
<system:String x:Key="Theme.DisplayName">{{ThemeDisplayName}}</system:String>
<system:String x:Key="Theme.BaseColorScheme">{{BaseColorScheme}}</system:String>
<system:String x:Key="Theme.ColorScheme">{{ColorScheme}}</system:String>
<Color x:Key="Theme.PrimaryAccentColor">{{PrimaryAccentColor}}</Color>
<system:Boolean x:Key="Theme.IsHighContrast">{{IsHighContrast}}</system:Boolean>
<Color x:Key="SystemBaseMediumLowColor">{{SystemBaseMediumLowColor}}</Color>
<SolidColorBrush x:Key="SystemChromeLow" Color="{{SystemChromeLow}}" options:Freeze="True" />
<SolidColorBrush x:Key="TextControlPlaceholderForeground" Color="{{TextControlPlaceholderForeground}}" />
<SolidColorBrush x:Key="TextBox.Static.Border" Color="{{TextBox.Static.Border}}"/>
<SolidColorBrush x:Key="TextBox.MouseOver.Border" Color="{{TextBox.MouseOver.Border}}"/>
<SolidColorBrush x:Key="TextBox.Focus.Border" Color="{{TextBox.Focus.Border}}"/>
<SolidColorBrush x:Key="ButtonBackgroundPointerOver" Color="{{ButtonBackgroundPointerOver}}" />
<SolidColorBrush x:Key="ButtonBorderPointerOver" Color="{{ButtonBorderPointerOver}}" />
<SolidColorBrush x:Key="ButtonBackgroundPressed" Color="{{ButtonBackgroundPressed}}" />
<SolidColorBrush x:Key="ButtonBorderPressed" Color="{{ButtonBorderPressed}}" />
<SolidColorBrush x:Key="ListViewItemBackgroundPointerOver" Color="{{ListViewItemBackgroundPointerOver}}" />
<SolidColorBrush x:Key="ControlTextBrushKey" Color="{{ControlTextBrushKey}}" />
<SolidColorBrush x:Key="SecondaryTextForeground" Color="{{SecondaryTextForeground}}" />
<SolidColorBrush x:Key="InactiveSelectionHighlightBrushKey" Color="{{InactiveSelectionHighlightBrushKey}}" />
<SolidColorBrush x:Key="DialogBorderBrush" Color="{{DialogBorderBrush}}" />
<SolidColorBrush x:Key="ScrollBarThumbBackground" Color="{{ScrollBarThumbBackground}}" />
<Color x:Key="ScrollBarThumbPointerOver">{{ScrollBarThumbPointerOver}}</Color>
<Color x:Key="ScrollBarThumbPointerPressed">{{ScrollBarThumbPointerPressed}}</Color>
<Color x:Key="ScrollBarBackgroundPointerOver">{{ScrollBarBackgroundPointerOver}}</Color>
<SolidColorBrush x:Key="ScrollBarLineButtonForeground" Color="{{ScrollBarLineButtonForeground}}" />
<Color x:Key="ScrollBarLineButtonForegroundPointerOver">{{ScrollBarLineButtonForegroundPointerOver}}</Color>
<Color x:Key="ScrollBarLineButtonForegroundPointerPressed">{{ScrollBarLineButtonForegroundPointerPressed}}</Color>
<SolidColorBrush x:Key="ScrollBarLineButtonBackground" Color="{{ScrollBarLineButtonBackground}}"/>
<Color x:Key="ScrollBarLineButtonBackgroundPointerOver">{{ScrollBarLineButtonBackgroundPointerOver}}</Color>
<Color x:Key="ScrollBarLineButtonBackgroundPointerPressed">{{ScrollBarLineButtonBackgroundPointerPressed}}</Color>
<SolidColorBrush x:Key="ToolTipBorderBrushKey" Color="{{ToolTipBorderBrushKey}}" />
<SolidColorBrush x:Key="ToolTipForegroundBrushKey" Color="{{ToolTipForegroundBrushKey}}" />
<SolidColorBrush x:Key="ToolTipBackgroundBrushKey" Color="{{ToolTipBackgroundBrushKey}}" />
</ResourceDictionary>

View File

@@ -63,10 +63,9 @@ namespace Wox.Plugin
ControlzEx.Theming.ThemeManager.Current.ThemeChanged += Current_ThemeChanged;
// Currently we don't need to sync all, because the accent is not used
// If we want to sync all and use runtime generated themes,
// then it's necessary to have a "GeneratorParameters.json" and "Theme.Template.xaml".
ControlzEx.Theming.ThemeManager.Current.ThemeSyncMode = ControlzEx.Theming.ThemeSyncMode.SyncWithAppMode;
// Currently there is an issue in ControlzEx, so we must use SyncAll to sync also HighContrast themes.
// We can change this after using next release.
ControlzEx.Theming.ThemeManager.Current.ThemeSyncMode = ControlzEx.Theming.ThemeSyncMode.SyncAll;
ControlzEx.Theming.ThemeManager.Current.SyncTheme();
}
@@ -123,22 +122,22 @@ namespace Wox.Plugin
else if (theme == Theme.HighContrastOne)
{
currentTheme = Theme.HighContrastOne;
ControlzEx.Theming.ThemeManager.Current.ChangeTheme(_app, HighContrastOneTheme);
ControlzEx.Theming.ThemeManager.Current.ChangeTheme(_app, HighContrastOneTheme, true);
}
else if (theme == Theme.HighContrastTwo)
{
currentTheme = Theme.HighContrastTwo;
ControlzEx.Theming.ThemeManager.Current.ChangeTheme(_app, HighContrastTwoTheme);
ControlzEx.Theming.ThemeManager.Current.ChangeTheme(_app, HighContrastTwoTheme, true);
}
else if (theme == Theme.HighContrastWhite)
{
currentTheme = Theme.HighContrastWhite;
ControlzEx.Theming.ThemeManager.Current.ChangeTheme(_app, HighContrastWhiteTheme);
ControlzEx.Theming.ThemeManager.Current.ChangeTheme(_app, HighContrastWhiteTheme, true);
}
else if (theme == Theme.HighContrastBlack)
{
currentTheme = Theme.HighContrastBlack;
ControlzEx.Theming.ThemeManager.Current.ChangeTheme(_app, HighContrastBlackTheme);
ControlzEx.Theming.ThemeManager.Current.ChangeTheme(_app, HighContrastBlackTheme, true);
}
else if (theme == Theme.Light)
{
@@ -161,7 +160,15 @@ namespace Wox.Plugin
private void Current_ThemeChanged(object sender, ControlzEx.Theming.ThemeChangedEventArgs e)
{
ResetTheme();
ControlzEx.Theming.ThemeManager.Current.ThemeChanged -= Current_ThemeChanged;
try
{
ResetTheme();
}
finally
{
ControlzEx.Theming.ThemeManager.Current.ThemeChanged += Current_ThemeChanged;
}
}
protected virtual void Dispose(bool disposing)

View File

@@ -49,6 +49,15 @@
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup>
<DefaultItemExcludes>$(DefaultItemExcludes);**/*.Template.xaml</DefaultItemExcludes>
</PropertyGroup>
<ItemGroup>
<EmbeddedResource Include="**/*.Template.xaml" />
<EmbeddedResource Include="**/GeneratorParameters.json" />
<UpToDateCheckInput Include="**/*.xaml" />
</ItemGroup>
<ItemGroup>
<None Include="README.md" />
</ItemGroup>