[PT Run] Option for override theme (#7355)

* option for override PT Run theme

* fix startup theme detection and moved strings in resources

* xaml fixed

* fix title spacing

* launcher theme fix

moved theme enum
removed settings direct access

* missing files

* theme manager dispose removed

Co-authored-by: Clint Rutkas <clint@rutkas.com>
This commit is contained in:
Davide Giacometti
2020-10-24 00:05:07 +02:00
committed by GitHub
parent 6424667396
commit 146e7866a6
23 changed files with 189 additions and 48 deletions

View File

@@ -0,0 +1,17 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace ManagedCommon
{
public enum Theme
{
System,
Light,
Dark,
HighContrastOne,
HighContrastTwo,
HighContrastBlack,
HighContrastWhite,
}
}

View File

@@ -51,6 +51,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\common\interop\interop.vcxproj" /> <ProjectReference Include="..\..\common\interop\interop.vcxproj" />
<ProjectReference Include="..\..\common\ManagedCommon\ManagedCommon.csproj" />
<ProjectReference Include="..\..\common\ManagedTelemetry\Telemetry\Telemetry.csproj" /> <ProjectReference Include="..\..\common\ManagedTelemetry\Telemetry\Telemetry.csproj" />
</ItemGroup> </ItemGroup>

View File

@@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information. // See the LICENSE file in the project root for more information.
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
using ManagedCommon;
namespace Microsoft.PowerToys.Settings.UI.Library namespace Microsoft.PowerToys.Settings.UI.Library
{ {
@@ -44,6 +45,9 @@ namespace Microsoft.PowerToys.Settings.UI.Library
[JsonPropertyName("clear_input_on_launch")] [JsonPropertyName("clear_input_on_launch")]
public bool ClearInputOnLaunch { get; set; } public bool ClearInputOnLaunch { get; set; }
[JsonPropertyName("theme")]
public Theme Theme { get; set; }
public PowerLauncherProperties() public PowerLauncherProperties()
{ {
OpenPowerLauncher = new HotkeySettings(false, false, true, false, 32); OpenPowerLauncher = new HotkeySettings(false, false, true, false, 32);
@@ -56,6 +60,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library
DisableDriveDetectionWarning = false; DisableDriveDetectionWarning = false;
ClearInputOnLaunch = false; ClearInputOnLaunch = false;
MaximumNumberOfResults = 4; MaximumNumberOfResults = 4;
Theme = Theme.System;
} }
} }
} }

View File

@@ -6,6 +6,7 @@ using System;
using System.Globalization; using System.Globalization;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Text.Json; using System.Text.Json;
using ManagedCommon;
using Microsoft.PowerToys.Settings.UI.Library.Helpers; using Microsoft.PowerToys.Settings.UI.Library.Helpers;
using Microsoft.PowerToys.Settings.UI.Library.Interfaces; using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
@@ -13,6 +14,10 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
{ {
public class PowerLauncherViewModel : Observable public class PowerLauncherViewModel : Observable
{ {
private bool _isDarkThemeRadioButtonChecked;
private bool _isLightThemeRadioButtonChecked;
private bool _isSystemThemeRadioButtonChecked;
private GeneralSettings GeneralSettingsConfig { get; set; } private GeneralSettings GeneralSettingsConfig { get; set; }
private readonly ISettingsUtils _settingsUtils; private readonly ISettingsUtils _settingsUtils;
@@ -63,6 +68,19 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
settings.Properties.MaximumNumberOfResults = 4; settings.Properties.MaximumNumberOfResults = 4;
callback(settings); callback(settings);
} }
switch (settings.Properties.Theme)
{
case Theme.Light:
_isLightThemeRadioButtonChecked = true;
break;
case Theme.Dark:
_isDarkThemeRadioButtonChecked = true;
break;
case Theme.System:
_isSystemThemeRadioButtonChecked = true;
break;
}
} }
public PowerLauncherViewModel(PowerLauncherSettings settings, SendCallback callback) public PowerLauncherViewModel(PowerLauncherSettings settings, SendCallback callback)
@@ -149,6 +167,63 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
} }
} }
public bool IsDarkThemeRadioButtonChecked
{
get
{
return _isDarkThemeRadioButtonChecked;
}
set
{
if (value == true)
{
settings.Properties.Theme = Theme.Dark;
_isDarkThemeRadioButtonChecked = value;
UpdateSettings();
}
}
}
public bool IsLightThemeRadioButtonChecked
{
get
{
return _isLightThemeRadioButtonChecked;
}
set
{
if (value == true)
{
settings.Properties.Theme = Theme.Light;
_isDarkThemeRadioButtonChecked = value;
UpdateSettings();
}
}
}
public bool IsSystemThemeRadioButtonChecked
{
get
{
return _isSystemThemeRadioButtonChecked;
}
set
{
if (value == true)
{
settings.Properties.Theme = Theme.System;
_isDarkThemeRadioButtonChecked = value;
UpdateSettings();
}
}
}
public HotkeySettings OpenPowerLauncher public HotkeySettings OpenPowerLauncher
{ {
get get

View File

@@ -302,6 +302,9 @@
<data name="PowerLauncher_ClearInputOnLaunch.Content" xml:space="preserve"> <data name="PowerLauncher_ClearInputOnLaunch.Content" xml:space="preserve">
<value>Clear the previous query on launch</value> <value>Clear the previous query on launch</value>
</data> </data>
<data name="PowerLauncher_Theme.Text" xml:space="preserve">
<value>Choose color</value>
</data>
<data name="KeyboardManager_KeysMappingLayoutRightHeader.Text" xml:space="preserve"> <data name="KeyboardManager_KeysMappingLayoutRightHeader.Text" xml:space="preserve">
<value>To:</value> <value>To:</value>
<comment>Keyboard Manager mapping keys view right header</comment> <comment>Keyboard Manager mapping keys view right header</comment>
@@ -774,4 +777,13 @@
<data name="ImageResizer_FilenameFormatPlaceholder.PlaceholderText" xml:space="preserve"> <data name="ImageResizer_FilenameFormatPlaceholder.PlaceholderText" xml:space="preserve">
<value>Example: %1 (%2)</value> <value>Example: %1 (%2)</value>
</data> </data>
<data name="PowerLauncher_Radio_Theme_Dark.Content" xml:space="preserve">
<value>Dark</value>
</data>
<data name="PowerLauncher_Radio_Theme_Default.Content" xml:space="preserve">
<value>System default</value>
</data>
<data name="PowerLauncher_Radio_Theme_Light.Content" xml:space="preserve">
<value>Light</value>
</data>
</root> </root>

View File

@@ -143,7 +143,22 @@
IsChecked="{x:Bind Mode=TwoWay, Path=ViewModel.DisableDriveDetectionWarning}" IsChecked="{x:Bind Mode=TwoWay, Path=ViewModel.DisableDriveDetectionWarning}"
IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.EnablePowerLauncher}" IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.EnablePowerLauncher}"
/> />
<TextBlock x:Uid="Appearance_GroupSettings"
Style="{StaticResource SettingsGroupTitleStyle}"
Foreground="{x:Bind Mode=OneWay, Path=ViewModel.EnablePowerLauncher, Converter={StaticResource ModuleEnabledToForegroundConverter}}" />
<TextBlock x:Uid="PowerLauncher_Theme"
Margin="{StaticResource SmallTopMargin}"
Foreground="{x:Bind Mode=OneWay, Path=ViewModel.EnablePowerLauncher, Converter={StaticResource ModuleEnabledToForegroundConverter}}" />
<muxc:RadioButtons IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.EnablePowerLauncher}">
<RadioButton x:Uid="PowerLauncher_Radio_Theme_Dark"
IsChecked="{Binding Mode=TwoWay, Path=IsDarkThemeRadioButtonChecked}" />
<RadioButton x:Uid="PowerLauncher_Radio_Theme_Light"
IsChecked="{Binding Mode=TwoWay, Path=IsLightThemeRadioButtonChecked}" />
<RadioButton x:Uid="PowerLauncher_Radio_Theme_Default"
IsChecked="{Binding Mode=TwoWay, Path=IsSystemThemeRadioButtonChecked}" />
</muxc:RadioButtons>
</StackPanel> </StackPanel>
<RelativePanel x:Name="SidePanel" <RelativePanel x:Name="SidePanel"

View File

@@ -5,6 +5,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using ManagedCommon;
using Wox.Plugin; using Wox.Plugin;
using Wox.Plugin.Logger; using Wox.Plugin.Logger;

View File

@@ -6,6 +6,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Windows.Controls; using System.Windows.Controls;
using ManagedCommon;
using Microsoft.Plugin.Folder.Sources; using Microsoft.Plugin.Folder.Sources;
using Microsoft.PowerToys.Settings.UI.Library; using Microsoft.PowerToys.Settings.UI.Library;
using Wox.Infrastructure.Storage; using Wox.Infrastructure.Storage;

View File

@@ -8,6 +8,7 @@ using System.Collections.Immutable;
using System.Globalization; using System.Globalization;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using ManagedCommon;
using Microsoft.Plugin.Folder.Sources.Result; using Microsoft.Plugin.Folder.Sources.Result;
using Wox.Plugin; using Wox.Plugin;

View File

@@ -11,6 +11,7 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Windows.Controls; using System.Windows.Controls;
using ManagedCommon;
using Microsoft.Plugin.Indexer.DriveDetection; using Microsoft.Plugin.Indexer.DriveDetection;
using Microsoft.Plugin.Indexer.SearchHelper; using Microsoft.Plugin.Indexer.SearchHelper;
using Microsoft.PowerToys.Settings.UI.Library; using Microsoft.PowerToys.Settings.UI.Library;

View File

@@ -8,6 +8,7 @@ using System.Collections.Immutable;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using ManagedCommon;
using Microsoft.Plugin.Program.ProgramArgumentParser; using Microsoft.Plugin.Program.ProgramArgumentParser;
using Microsoft.Plugin.Program.Programs; using Microsoft.Plugin.Program.Programs;
using Microsoft.Plugin.Program.Storage; using Microsoft.Plugin.Program.Storage;

View File

@@ -16,6 +16,7 @@ using System.Windows;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
using ManagedCommon;
using Microsoft.Plugin.Program.Logger; using Microsoft.Plugin.Program.Logger;
using Microsoft.Plugin.Program.Win32; using Microsoft.Plugin.Program.Win32;
using Wox.Infrastructure; using Wox.Infrastructure;

View File

@@ -11,6 +11,7 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Windows.Input; using System.Windows.Input;
using ManagedCommon;
using Microsoft.PowerToys.Settings.UI.Library; using Microsoft.PowerToys.Settings.UI.Library;
using Wox.Infrastructure.Storage; using Wox.Infrastructure.Storage;
using Wox.Plugin; using Wox.Plugin;

View File

@@ -7,6 +7,7 @@ using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Text; using System.Text;
using ManagedCommon;
using Microsoft.Plugin.Uri.UriHelper; using Microsoft.Plugin.Uri.UriHelper;
using Wox.Infrastructure.Storage; using Wox.Infrastructure.Storage;
using Wox.Plugin; using Wox.Plugin;

View File

@@ -5,6 +5,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using ManagedCommon;
using Microsoft.Plugin.WindowWalker.Components; using Microsoft.Plugin.WindowWalker.Components;
using Wox.Plugin; using Wox.Plugin;

View File

@@ -111,7 +111,7 @@ namespace PowerLauncher
RegisterExitEvents(); RegisterExitEvents();
_settingsWatcher = new SettingsWatcher(_settings); _settingsWatcher = new SettingsWatcher(_settings, _themeManager);
_mainVM.MainWindowVisibility = Visibility.Visible; _mainVM.MainWindowVisibility = Visibility.Visible;
_mainVM.ColdStartFix(); _mainVM.ColdStartFix();

View File

@@ -7,6 +7,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using System.Windows; using System.Windows;
using ManagedCommon;
using PowerLauncher.Helper; using PowerLauncher.Helper;
using PowerLauncher.ViewModel; using PowerLauncher.ViewModel;
using Wox.Core.Plugin; using Wox.Core.Plugin;

View File

@@ -6,6 +6,7 @@ using System;
using System.IO; using System.IO;
using System.Threading; using System.Threading;
using System.Windows.Input; using System.Windows.Input;
using ManagedCommon;
using Microsoft.PowerToys.Settings.UI.Library; using Microsoft.PowerToys.Settings.UI.Library;
using Microsoft.PowerToys.Settings.UI.Library.Utilities; using Microsoft.PowerToys.Settings.UI.Library.Utilities;
using PowerLauncher.Helper; using PowerLauncher.Helper;
@@ -27,11 +28,13 @@ namespace PowerLauncher
private static readonly object _watcherSyncObject = new object(); private static readonly object _watcherSyncObject = new object();
private readonly FileSystemWatcher _watcher; private readonly FileSystemWatcher _watcher;
private readonly Settings _settings; private readonly Settings _settings;
private readonly ThemeManager _themeManager;
public SettingsWatcher(Settings settings) public SettingsWatcher(Settings settings, ThemeManager themeManager)
{ {
_settingsUtils = new SettingsUtils(new SystemIOProvider()); _settingsUtils = new SettingsUtils(new SystemIOProvider());
_settings = settings; _settings = settings;
_themeManager = themeManager;
// Set up watcher // Set up watcher
_watcher = Microsoft.PowerToys.Settings.UI.Library.Utilities.Helper.GetFileWatcher(PowerLauncherSettings.ModuleName, "settings.json", OverloadSettings); _watcher = Microsoft.PowerToys.Settings.UI.Library.Utilities.Helper.GetFileWatcher(PowerLauncherSettings.ModuleName, "settings.json", OverloadSettings);
@@ -100,6 +103,12 @@ namespace PowerLauncher
_settings.ClearInputOnLaunch = overloadSettings.Properties.ClearInputOnLaunch; _settings.ClearInputOnLaunch = overloadSettings.Properties.ClearInputOnLaunch;
} }
if (_settings.Theme != overloadSettings.Properties.Theme)
{
_settings.Theme = overloadSettings.Properties.Theme;
_themeManager.ChangeTheme(_settings.Theme, _settings.Theme == Theme.System);
}
retry = false; retry = false;
} }

View File

@@ -11,6 +11,7 @@ using System.Reflection;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
using ManagedCommon;
using Wox.Infrastructure.Storage; using Wox.Infrastructure.Storage;
using Wox.Plugin; using Wox.Plugin;
using Wox.Plugin.Logger; using Wox.Plugin.Logger;

View File

@@ -5,6 +5,7 @@
using System; using System;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Drawing; using System.Drawing;
using ManagedCommon;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Converters; using Newtonsoft.Json.Converters;
using Wox.Plugin; using Wox.Plugin;
@@ -44,7 +45,7 @@ namespace Wox.Infrastructure.UserSettings
public string Language { get; set; } = "en"; public string Language { get; set; } = "en";
public string Theme { get; set; } = "Dark"; public Theme Theme { get; set; } = Theme.System;
public string QueryBoxFont { get; set; } = FontFamily.GenericSansSerif.Name; public string QueryBoxFont { get; set; } = FontFamily.GenericSansSerif.Name;

View File

@@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information. // See the LICENSE file in the project root for more information.
using System.Collections.Generic; using System.Collections.Generic;
using ManagedCommon;
namespace Wox.Plugin namespace Wox.Plugin
{ {
@@ -71,7 +72,6 @@ namespace Wox.Plugin
/// <summary> /// <summary>
/// Get all loaded plugins /// Get all loaded plugins
/// </summary> /// </summary>
/// <returns></returns>
List<PluginPair> GetAllPlugins(); List<PluginPair> GetAllPlugins();
} }
} }

View File

@@ -3,11 +3,10 @@
// See the LICENSE file in the project root for more information. // See the LICENSE file in the project root for more information.
using System; using System;
using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Windows; using System.Windows;
using ControlzEx.Theming;
using MahApps.Metro.Theming; using MahApps.Metro.Theming;
using ManagedCommon;
using Microsoft.Win32; using Microsoft.Win32;
namespace Wox.Plugin namespace Wox.Plugin
@@ -39,32 +38,32 @@ namespace Wox.Plugin
Uri darkThemeUri = new Uri("pack://application:,,,/Themes/Dark.xaml"); Uri darkThemeUri = new Uri("pack://application:,,,/Themes/Dark.xaml");
ControlzEx.Theming.ThemeManager.Current.AddLibraryTheme( ControlzEx.Theming.ThemeManager.Current.AddLibraryTheme(
new LibraryTheme( new ControlzEx.Theming.LibraryTheme(
highContrastOneThemeUri, highContrastOneThemeUri,
MahAppsLibraryThemeProvider.DefaultInstance)); MahAppsLibraryThemeProvider.DefaultInstance));
ControlzEx.Theming.ThemeManager.Current.AddLibraryTheme( ControlzEx.Theming.ThemeManager.Current.AddLibraryTheme(
new LibraryTheme( new ControlzEx.Theming.LibraryTheme(
highContrastTwoThemeUri, highContrastTwoThemeUri,
MahAppsLibraryThemeProvider.DefaultInstance)); MahAppsLibraryThemeProvider.DefaultInstance));
ControlzEx.Theming.ThemeManager.Current.AddLibraryTheme( ControlzEx.Theming.ThemeManager.Current.AddLibraryTheme(
new LibraryTheme( new ControlzEx.Theming.LibraryTheme(
highContrastBlackThemeUri, highContrastBlackThemeUri,
MahAppsLibraryThemeProvider.DefaultInstance)); MahAppsLibraryThemeProvider.DefaultInstance));
ControlzEx.Theming.ThemeManager.Current.AddLibraryTheme( ControlzEx.Theming.ThemeManager.Current.AddLibraryTheme(
new LibraryTheme( new ControlzEx.Theming.LibraryTheme(
highContrastWhiteThemeUri, highContrastWhiteThemeUri,
MahAppsLibraryThemeProvider.DefaultInstance)); MahAppsLibraryThemeProvider.DefaultInstance));
ControlzEx.Theming.ThemeManager.Current.AddLibraryTheme( ControlzEx.Theming.ThemeManager.Current.AddLibraryTheme(
new LibraryTheme( new ControlzEx.Theming.LibraryTheme(
lightThemeUri, lightThemeUri,
MahAppsLibraryThemeProvider.DefaultInstance)); MahAppsLibraryThemeProvider.DefaultInstance));
ControlzEx.Theming.ThemeManager.Current.AddLibraryTheme( ControlzEx.Theming.ThemeManager.Current.AddLibraryTheme(
new LibraryTheme( new ControlzEx.Theming.LibraryTheme(
darkThemeUri, darkThemeUri,
MahAppsLibraryThemeProvider.DefaultInstance)); MahAppsLibraryThemeProvider.DefaultInstance));
ResetTheme(); ResetTheme();
ControlzEx.Theming.ThemeManager.Current.ThemeSyncMode = ThemeSyncMode.SyncAll; ControlzEx.Theming.ThemeManager.Current.ThemeSyncMode = ControlzEx.Theming.ThemeSyncMode.SyncAll;
ControlzEx.Theming.ThemeManager.Current.ThemeChanged += Current_ThemeChanged; ControlzEx.Theming.ThemeManager.Current.ThemeChanged += Current_ThemeChanged;
} }
@@ -90,67 +89,73 @@ namespace Wox.Plugin
case "hcblack": case "hcblack":
return Theme.HighContrastBlack; return Theme.HighContrastBlack;
default: default:
return Theme.None; return Theme.HighContrastOne;
} }
} }
private void ResetTheme() private void ResetTheme()
{ {
if (WindowsThemeHelper.IsHighContrastEnabled()) ChangeTheme(currentTheme, false);
{
Theme highContrastBaseType = GetHighContrastBaseType();
ChangeTheme(highContrastBaseType);
}
else
{
string baseColor = WindowsThemeHelper.GetWindowsBaseColor();
ChangeTheme((Theme)Enum.Parse(typeof(Theme), baseColor));
}
} }
private void ChangeTheme(Theme theme) public void ChangeTheme(Theme theme, bool forceSystem)
{ {
Theme oldTheme = currentTheme; Theme oldTheme = currentTheme;
if (theme == Theme.HighContrastOne) if (theme == Theme.System)
{
currentTheme = Theme.System;
if (ControlzEx.Theming.WindowsThemeHelper.IsHighContrastEnabled())
{
Theme highContrastBaseType = GetHighContrastBaseType();
ChangeTheme(highContrastBaseType, true);
}
else
{
string baseColor = ControlzEx.Theming.WindowsThemeHelper.GetWindowsBaseColor();
ChangeTheme((Theme)Enum.Parse(typeof(Theme), baseColor), true);
}
}
else if (theme == Theme.HighContrastOne)
{ {
ControlzEx.Theming.ThemeManager.Current.ChangeTheme(_app, HighContrastOneTheme);
currentTheme = Theme.HighContrastOne; currentTheme = Theme.HighContrastOne;
ControlzEx.Theming.ThemeManager.Current.ChangeTheme(_app, HighContrastOneTheme);
} }
else if (theme == Theme.HighContrastTwo) else if (theme == Theme.HighContrastTwo)
{ {
ControlzEx.Theming.ThemeManager.Current.ChangeTheme(_app, HighContrastTwoTheme);
currentTheme = Theme.HighContrastTwo; currentTheme = Theme.HighContrastTwo;
ControlzEx.Theming.ThemeManager.Current.ChangeTheme(_app, HighContrastTwoTheme);
} }
else if (theme == Theme.HighContrastWhite) else if (theme == Theme.HighContrastWhite)
{ {
ControlzEx.Theming.ThemeManager.Current.ChangeTheme(_app, HighContrastWhiteTheme);
currentTheme = Theme.HighContrastWhite; currentTheme = Theme.HighContrastWhite;
ControlzEx.Theming.ThemeManager.Current.ChangeTheme(_app, HighContrastWhiteTheme);
} }
else if (theme == Theme.HighContrastBlack) else if (theme == Theme.HighContrastBlack)
{ {
ControlzEx.Theming.ThemeManager.Current.ChangeTheme(_app, HighContrastBlackTheme);
currentTheme = Theme.HighContrastBlack; currentTheme = Theme.HighContrastBlack;
ControlzEx.Theming.ThemeManager.Current.ChangeTheme(_app, HighContrastBlackTheme);
} }
else if (theme == Theme.Light) else if (theme == Theme.Light)
{ {
ControlzEx.Theming.ThemeManager.Current.ChangeTheme(_app, LightTheme);
currentTheme = Theme.Light; currentTheme = Theme.Light;
ControlzEx.Theming.ThemeManager.Current.ChangeTheme(_app, LightTheme);
} }
else if (theme == Theme.Dark) else if (theme == Theme.Dark)
{ {
ControlzEx.Theming.ThemeManager.Current.ChangeTheme(_app, DarkTheme);
currentTheme = Theme.Dark; currentTheme = Theme.Dark;
} ControlzEx.Theming.ThemeManager.Current.ChangeTheme(_app, DarkTheme);
else
{
currentTheme = Theme.None;
} }
ThemeChanged?.Invoke(oldTheme, currentTheme); ThemeChanged?.Invoke(oldTheme, currentTheme);
if (forceSystem)
{
currentTheme = Theme.System;
}
} }
private void Current_ThemeChanged(object sender, ThemeChangedEventArgs e) private void Current_ThemeChanged(object sender, ControlzEx.Theming.ThemeChangedEventArgs e)
{ {
ResetTheme(); ResetTheme();
} }
@@ -175,15 +180,4 @@ namespace Wox.Plugin
} }
public delegate void ThemeChangedHandler(Theme oldTheme, Theme newTheme); public delegate void ThemeChangedHandler(Theme oldTheme, Theme newTheme);
public enum Theme
{
None,
Light,
Dark,
HighContrastOne,
HighContrastTwo,
HighContrastBlack,
HighContrastWhite,
}
} }

View File

@@ -78,6 +78,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\common\ManagedCommon\ManagedCommon.csproj" />
<ProjectReference Include="..\..\..\core\Microsoft.PowerToys.Settings.UI.Library\Microsoft.PowerToys.Settings.UI.Library.csproj" /> <ProjectReference Include="..\..\..\core\Microsoft.PowerToys.Settings.UI.Library\Microsoft.PowerToys.Settings.UI.Library.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>