|
1 | | -using System; |
| 1 | +using System; |
2 | 2 | using System.Collections.Generic; |
3 | 3 | using System.ComponentModel; |
4 | 4 | using System.Linq; |
5 | 5 | using System.Threading; |
6 | 6 | using System.Windows; |
7 | 7 | using System.Windows.Media; |
8 | 8 | using System.Windows.Threading; |
| 9 | +using EverythingToolbar.Helpers; |
9 | 10 | using NLog; |
10 | 11 | using Windows.UI.ViewManagement; |
11 | 12 | using Wpf.Ui.Appearance; |
@@ -166,7 +167,14 @@ private void ScheduleApply() |
166 | 167 |
|
167 | 168 | private void OnSettingsChanged(object? sender, PropertyChangedEventArgs e) |
168 | 169 | { |
169 | | - if (e.PropertyName is nameof(ISettings.ThemeOverride) or nameof(ISettings.ForceWin10Behavior)) |
| 170 | + if ( |
| 171 | + e.PropertyName |
| 172 | + is nameof(ISettings.ThemeOverride) |
| 173 | + or nameof(ISettings.ForceWin10Behavior) |
| 174 | + or nameof(ISettings.SearchWindowBackground) |
| 175 | + or nameof(ISettings.SearchWindowBackgroundAlpha) |
| 176 | + or nameof(ISettings.SearchWindowBackgroundBrightness) |
| 177 | + ) |
170 | 178 | { |
171 | 179 | ScheduleApply(); |
172 | 180 | } |
@@ -225,6 +233,8 @@ private void ApplyCustomLayers(Registration registration, FrameworkElement root, |
225 | 233 | AddResource(registration, root, $"Themes/{profile}/Controls.xaml"); |
226 | 234 |
|
227 | 235 | AddAccentColor(registration, root, systemTheme); |
| 236 | + |
| 237 | + AddSearchWindowBackground(registration, root, systemTheme, profile); |
228 | 238 | } |
229 | 239 |
|
230 | 240 | private static void AddWpfUiBase(Registration registration, FrameworkElement root, Theme theme) |
@@ -271,11 +281,50 @@ private void AddAccentColor(Registration registration, FrameworkElement root, Th |
271 | 281 | registration.AddedDictionaries.Add(resDict); |
272 | 282 | } |
273 | 283 |
|
274 | | - private static SolidColorBrush GetBrush(Color color) |
| 284 | + private static SolidColorBrush GetBrush(Color color) => |
| 285 | + ColorHelper.ToFrozenBrush(System.Windows.Media.Color.FromArgb(color.A, color.R, color.G, color.B)); |
| 286 | + |
| 287 | + private void AddSearchWindowBackground( |
| 288 | + Registration registration, |
| 289 | + FrameworkElement root, |
| 290 | + Theme systemTheme, |
| 291 | + string profile |
| 292 | + ) |
| 293 | + { |
| 294 | + var brush = GetSearchWindowBackgroundBrush(systemTheme, profile); |
| 295 | + var resDict = new ResourceDictionary |
| 296 | + { |
| 297 | + ["SearchWindowBackground"] = brush, |
| 298 | + ["SearchResultsViewHeader"] = brush, |
| 299 | + }; |
| 300 | + root.Resources.MergedDictionaries.Add(resDict); |
| 301 | + registration.AddedDictionaries.Add(resDict); |
| 302 | + } |
| 303 | + |
| 304 | + private static readonly SolidColorBrush Win11LightBackgroundBrush = ColorHelper.ToFrozenBrush(System.Windows.Media.Color.FromArgb(0xE0, 0xF5, 0xF5, 0xF5)); |
| 305 | + private static readonly SolidColorBrush Win10LightBackgroundBrush = ColorHelper.ToFrozenBrush(System.Windows.Media.Color.FromArgb(0xDD, 0xEE, 0xEE, 0xEE)); |
| 306 | + private static readonly SolidColorBrush Win11DarkBackgroundBrush = ColorHelper.ToFrozenBrush(System.Windows.Media.Color.FromArgb(0xDA, 0x25, 0x25, 0x25)); |
| 307 | + private static readonly SolidColorBrush Win10DarkBackgroundBrush = ColorHelper.ToFrozenBrush(System.Windows.Media.Color.FromArgb(0xF0, 0x25, 0x25, 0x25)); |
| 308 | + |
| 309 | + private SolidColorBrush GetSearchWindowBackgroundBrush(Theme systemTheme, string profile) |
275 | 310 | { |
276 | | - var brush = new SolidColorBrush(System.Windows.Media.Color.FromArgb(color.A, color.R, color.G, color.B)); |
277 | | - brush.Freeze(); |
278 | | - return brush; |
| 311 | + if (string.Equals(_settings.SearchWindowBackground, "Custom", StringComparison.OrdinalIgnoreCase)) |
| 312 | + { |
| 313 | + var color = ColorHelper.GetSearchWindowColor( |
| 314 | + _settings.SearchWindowBackgroundAlpha, |
| 315 | + _settings.SearchWindowBackgroundBrightness, |
| 316 | + systemTheme == Theme.Light |
| 317 | + ); |
| 318 | + return ColorHelper.ToFrozenBrush(color); |
| 319 | + } |
| 320 | + |
| 321 | + // Automatic |
| 322 | + if (systemTheme == Theme.Light) |
| 323 | + { |
| 324 | + return profile == "Win11" ? Win11LightBackgroundBrush : Win10LightBackgroundBrush; |
| 325 | + } |
| 326 | + |
| 327 | + return profile == "Win11" ? Win11DarkBackgroundBrush : Win10DarkBackgroundBrush; |
279 | 328 | } |
280 | 329 |
|
281 | 330 | public void Dispose() |
|
0 commit comments