|
23 | 23 | using Wox.Infrastructure.UserSettings; |
24 | 24 | using Wox.Plugin; |
25 | 25 | using Wox.Plugin.Logger; |
| 26 | +using Wpf.Ui.Appearance; |
26 | 27 | using Stopwatch = Wox.Infrastructure.Stopwatch; |
27 | 28 |
|
28 | 29 | namespace PowerLauncher |
@@ -152,6 +153,9 @@ private void OnStartup(object sender, StartupEventArgs e) |
152 | 153 | _settingsReader.ReadSettingsOnChange(); |
153 | 154 |
|
154 | 155 | _themeManager.ThemeChanged += OnThemeChanged; |
| 156 | + |
| 157 | + OnThemeChanged(_settings.Theme, _settings.Theme); |
| 158 | + |
155 | 159 | textToLog.AppendLine("End PowerToys Run startup ---------------------------------------------------- "); |
156 | 160 |
|
157 | 161 | bootTime.Stop(); |
@@ -217,6 +221,37 @@ private void RegisterExitEvents() |
217 | 221 | /// <param name="newTheme">Current Theme</param> |
218 | 222 | private void OnThemeChanged(Theme oldTheme, Theme newTheme) |
219 | 223 | { |
| 224 | + // If OS theme is high contrast, don't change theme. |
| 225 | + if (SystemParameters.HighContrast) |
| 226 | + { |
| 227 | + return; |
| 228 | + } |
| 229 | + |
| 230 | + ApplicationTheme theme = ApplicationTheme.Unknown; |
| 231 | + |
| 232 | + switch (newTheme) |
| 233 | + { |
| 234 | + case Theme.Dark: |
| 235 | + theme = ApplicationTheme.Dark; break; |
| 236 | + case Theme.Light: |
| 237 | + theme = ApplicationTheme.Light; break; |
| 238 | + case Theme.HighContrastWhite: |
| 239 | + case Theme.HighContrastBlack: |
| 240 | + case Theme.HighContrastOne: |
| 241 | + case Theme.HighContrastTwo: |
| 242 | + theme = ApplicationTheme.HighContrast; break; |
| 243 | + default: |
| 244 | + break; |
| 245 | + } |
| 246 | + |
| 247 | + _mainWindow?.Dispatcher.Invoke(() => |
| 248 | + { |
| 249 | + if (theme != ApplicationTheme.Unknown) |
| 250 | + { |
| 251 | + ApplicationThemeManager.Apply(theme); |
| 252 | + } |
| 253 | + }); |
| 254 | + |
220 | 255 | ImageLoader.UpdateIconPath(newTheme); |
221 | 256 | _mainVM.Query(); |
222 | 257 | } |
|
0 commit comments