Skip to content

Commit

Permalink
Shift to ControlzEx HC code (#6880)
Browse files Browse the repository at this point in the history
* Use high contrast detection from controlzex

* Allow multiple theme changes
  • Loading branch information
dsrivastavv committed Oct 1, 2020
1 parent fd32a6f commit 55fd874
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions src/modules/launcher/Wox.Plugin/ThemeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.

using System;
using System.Diagnostics;
using System.Linq;
using System.Windows;
using ControlzEx.Theming;
Expand Down Expand Up @@ -63,17 +64,8 @@ public ThemeManager(Application app)
MahAppsLibraryThemeProvider.DefaultInstance));

ResetTheme();
ControlzEx.Theming.ThemeManager.Current.ThemeSyncMode = ThemeSyncMode.SyncWithAppMode;
ControlzEx.Theming.ThemeManager.Current.ThemeSyncMode = ThemeSyncMode.SyncAll;
ControlzEx.Theming.ThemeManager.Current.ThemeChanged += Current_ThemeChanged;
SystemParameters.StaticPropertyChanged += SystemParameters_StaticPropertyChanged;
}

private void SystemParameters_StaticPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(SystemParameters.HighContrast))
{
ResetTheme();
}
}

public Theme GetCurrentTheme()
Expand Down Expand Up @@ -104,7 +96,7 @@ private static Theme GetHighContrastBaseType()

private void ResetTheme()
{
if (SystemParameters.HighContrast)
if (WindowsThemeHelper.IsHighContrastEnabled())
{
Theme highContrastBaseType = GetHighContrastBaseType();
ChangeTheme(highContrastBaseType);
Expand All @@ -119,10 +111,6 @@ private void ResetTheme()
private void ChangeTheme(Theme theme)
{
Theme oldTheme = currentTheme;
if (theme == currentTheme)
{
return;
}

if (theme == Theme.HighContrastOne)
{
Expand Down Expand Up @@ -174,7 +162,6 @@ protected virtual void Dispose(bool disposing)
if (disposing)
{
ControlzEx.Theming.ThemeManager.Current.ThemeChanged -= Current_ThemeChanged;
SystemParameters.StaticPropertyChanged -= SystemParameters_StaticPropertyChanged;
_disposed = true;
}
}
Expand Down

0 comments on commit 55fd874

Please sign in to comment.