|
| 1 | +using Microsoft.UI; |
1 | 2 | using Microsoft.UI.Composition; |
2 | 3 | using Microsoft.UI.Composition.SystemBackdrops; |
3 | 4 | using Microsoft.UI.Xaml; |
@@ -26,41 +27,65 @@ public MainWindow() |
26 | 27 | ExtendsContentIntoTitleBar = true; |
27 | 28 | AppWindow.TitleBar.ButtonHoverBackgroundColor = Color.FromArgb(32, 128, 128, 128); |
28 | 29 | AppWindow.TitleBar.ButtonPressedBackgroundColor = Color.FromArgb(16, 128, 128, 128); |
29 | | - |
| 30 | +#if DEBUG |
| 31 | + if (false) |
| 32 | +#else |
30 | 33 | if (MicaController.IsSupported()) |
| 34 | +#endif |
31 | 35 | { |
32 | 36 | SystemBackdrop = new MicaBackdrop { Kind = MicaKind.BaseAlt }; |
33 | 37 | } |
34 | 38 | else if (DesktopAcrylicController.IsSupported()) |
35 | 39 | { |
36 | | - systemBackdropConfiguration = new SystemBackdropConfiguration(); |
37 | | - desktopAcrylicController = new DesktopAcrylicController |
38 | | - { |
39 | | - Kind = DesktopAcrylicKind.Thin, |
40 | | - LuminosityOpacity = 0.5f |
41 | | - }; |
42 | | - desktopAcrylicController.AddSystemBackdropTarget(this.As<ICompositionSupportsSystemBackdrop>()); |
43 | | - desktopAcrylicController.SetSystemBackdropConfiguration(systemBackdropConfiguration); |
| 40 | + //systemBackdropConfiguration = new SystemBackdropConfiguration(); |
| 41 | + //desktopAcrylicController = new DesktopAcrylicController |
| 42 | + //{ |
| 43 | + // Kind = DesktopAcrylicKind.Thin, |
| 44 | + // LuminosityOpacity = 0.5f |
| 45 | + //}; |
| 46 | + //desktopAcrylicController.AddSystemBackdropTarget(this.As<ICompositionSupportsSystemBackdrop>()); |
| 47 | + //desktopAcrylicController.SetSystemBackdropConfiguration(systemBackdropConfiguration); |
44 | 48 | Activated += (o, e) => |
45 | 49 | { |
46 | | - systemBackdropConfiguration.IsInputActive = e.WindowActivationState != WindowActivationState.Deactivated; |
| 50 | + //systemBackdropConfiguration.IsInputActive = e.WindowActivationState != WindowActivationState.Deactivated; |
| 51 | + if (e.WindowActivationState == WindowActivationState.Deactivated) |
| 52 | + { |
| 53 | + CurrentBackground = InactiveBackground; |
| 54 | + } |
| 55 | + else |
| 56 | + { |
| 57 | + CurrentBackground = ActiveBackground; |
| 58 | + } |
47 | 59 | }; |
| 60 | + SystemBackdrop = new DesktopAcrylicBackdrop(); |
48 | 61 | Color themeColor = new UISettings().GetColorValue(UIColorType.Accent); |
49 | | - themeColor.A = 32; |
50 | | - Background = new SolidColorBrush(themeColor); |
| 62 | + themeColor.A = 48; |
| 63 | + ActiveBackground = new SolidColorBrush(themeColor); |
51 | 64 | } |
52 | 65 | else |
53 | 66 | { |
54 | 67 | Color themeColor = new UISettings().GetColorValue(UIColorType.Accent); |
55 | | - themeColor.A = 32; |
56 | | - Background = new SolidColorBrush(themeColor); |
| 68 | + themeColor.A = 48; |
| 69 | + ActiveBackground = new SolidColorBrush(themeColor); |
57 | 70 | } |
58 | 71 |
|
59 | 72 | hWnd = WinRT.Interop.WindowNative.GetWindowHandle(this); |
60 | 73 | MaterialController = new(this); |
61 | 74 | } |
62 | 75 |
|
63 | | - public Brush Background |
| 76 | + public Brush? ActiveBackground |
| 77 | + { |
| 78 | + get => field; |
| 79 | + set => field = value; |
| 80 | + } |
| 81 | + |
| 82 | + public Brush? InactiveBackground |
| 83 | + { |
| 84 | + get => field; |
| 85 | + set => field = value; |
| 86 | + } |
| 87 | + |
| 88 | + private Brush? CurrentBackground |
64 | 89 | { |
65 | 90 | get => ContentFrame.Background; |
66 | 91 | set => ContentFrame.Background = value; |
|
0 commit comments