Better Win10 fallback woops

This commit is contained in:
Difegue 2021-10-14 16:06:41 +02:00
parent c1188a6d92
commit de1db3bc0a
5 changed files with 27 additions and 9 deletions

View File

@ -19,7 +19,7 @@ namespace Karen.Interop
[DllImport("dwmapi.dll")]
public static extern int DwmSetWindowAttribute(IntPtr hwnd, DwmWindowAttribute dwAttribute, ref int pvAttribute, int cbAttribute);
private static bool IsWin11 = Environment.OSVersion.Version >= new Version(10, 0, 22000, 0);
public static bool IsWin11 = Environment.OSVersion.Version >= new Version(10, 0, 22000, 0);
[Flags]
public enum DwmWindowAttribute : uint
@ -76,9 +76,9 @@ namespace Karen.Interop
else
{
if (darkThemeEnabled)
EnableBlur(hwnd, 0xFF202020);
EnableBlur(hwnd, 0xAA000000);
else
EnableBlur(hwnd, 0xFFF3F3F3);
EnableBlur(hwnd, 0x99FFFFFF);
}
}

View File

@ -12,7 +12,7 @@
Loaded="KarenPopup_Loaded"
mc:Ignorable="d">
<Border CornerRadius="6" BorderThickness="1" BorderBrush="{ui:ThemeResource SystemControlForegroundBaseLowBrush}">
<Border x:Name="Brd" BorderThickness="1" BorderBrush="{ui:ThemeResource SystemControlForegroundBaseLowBrush}">
<ui:SimpleStackPanel HorizontalAlignment="Center" Orientation="Vertical">
<Image

View File

@ -47,8 +47,13 @@ namespace Karen
UpdateStyleAttributes((HwndSource)sender);
// Round off corners for the popup
int value = 0x02;
DwmSetWindowAttribute(((HwndSource)sender).Handle, DwmWindowAttribute.DWMWA_WINDOW_CORNER_PREFERENCE, ref value, Marshal.SizeOf(typeof(int)));
if (IsWin11)
{
Brd.CornerRadius = new CornerRadius(6);
int value = 0x02;
DwmSetWindowAttribute(((HwndSource)sender).Handle, DwmWindowAttribute.DWMWA_WINDOW_CORNER_PREFERENCE, ref value, Marshal.SizeOf(typeof(int)));
}
ThemeManager.Current.ActualApplicationThemeChanged += (s, ev) =>
{

View File

@ -9,10 +9,12 @@
MinWidth="500" MinHeight="480"
Width="500" Height="680"
Loaded="Window_Loaded"
Background="Transparent"
Title="LANraragi Windows Settings"
Foreground="{DynamicResource SystemControlPageTextBaseHighBrush}"
Background="{DynamicResource SystemControlPageBackgroundAltHighBrush}"
ui:ThemeManager.IsThemeAware="True"
Closing="OnClosing">
<WindowChrome.WindowChrome>
<WindowChrome
CaptionHeight="32"

View File

@ -9,6 +9,7 @@ using System;
using Karen.Interop;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Shell;
namespace Karen
{
@ -91,8 +92,18 @@ namespace Karen
private void Window_ContentRendered(object sender, System.EventArgs e)
{
WCAUtils.UpdateStyleAttributes((HwndSource)sender);
ModernWpf.ThemeManager.Current.ActualApplicationThemeChanged += (s, ev) => WCAUtils.UpdateStyleAttributes((HwndSource)sender);
if (WCAUtils.IsWin11)
{
// Set a transparent background to let the mica brush come through
Background = new SolidColorBrush(Color.FromArgb(0, 255, 255, 255));
WCAUtils.UpdateStyleAttributes((HwndSource)sender);
ModernWpf.ThemeManager.Current.ActualApplicationThemeChanged += (s, ev) => WCAUtils.UpdateStyleAttributes((HwndSource)sender);
}
else
{
WindowChrome.SetWindowChrome(this, null);
}
}
private void Window_Loaded(object sender, RoutedEventArgs e)