diff --git a/Mica Discord/MainWindow.xaml.cs b/Mica Discord/MainWindow.xaml.cs index d9e5684..8d5d9dd 100644 --- a/Mica Discord/MainWindow.xaml.cs +++ b/Mica Discord/MainWindow.xaml.cs @@ -36,6 +36,9 @@ public partial class MainWindow : Window { #if WINDOWS10_0_17763_0_OR_GREATER static UISettings UISettings { get; } = new(); + public static bool IsNewTitleBarSupported => AppWindowTitleBar.IsCustomizationSupported(); +#else + public static bool IsNewTitleBarSupported => false; #endif public static string DefinedCSS #if DEBUG @@ -52,8 +55,8 @@ public static string DefinedJavascript public static bool NotSupportedBuild => Environment.OSVersion.Version.Build < 22523; public static bool IsWin11 => Environment.OSVersion.Version.Build > 22000; public static bool IsWin7 => Environment.OSVersion.Version.Major < 8 && Environment.OSVersion.Version.Major >= 7; + bool DiscordEffectApplied = false; - bool NewSDKTitleBar = false; bool _Dark = true; Action? ThemeChanged = null; bool Dark @@ -68,11 +71,10 @@ bool Dark void OnLoaded(object sender, RoutedEventArgs e) { - NewSDKTitleBar = false; ThemeChanged += () => (Resources["Color"] as SolidColorBrush ?? throw new NullReferenceException()).Color = Dark ? Colors.White : Colors.Black; #if WINDOWS10_0_17763_0_OR_GREATER Dark = IsDarkBackground(UISettings.GetColorValue(UIColorType.Background)); - if (IsWin11) + if (IsNewTitleBarSupported) { AppWindow = AppWindow.GetFromWindowId(WindowId); var AppTitleBar = AppWindow.TitleBar; @@ -145,7 +147,6 @@ void UpdateDragRectangles() UpdateDragRectangles(); }; UpdateDragRectangles(); - NewSDKTitleBar = true; goto SetWindowChromeComplete; } #endif @@ -174,20 +175,20 @@ void RefreshFrame() goto End; } #endif - if (!IsWin7) + if (!IsNewTitleBarSupported) { WindowChrome.GlassFrameThickness = new Thickness(0); WindowChrome.UseAeroCaptionButtons = false; mainWindowSrc.CompositionTarget.BackgroundColor = Dark ? Color.FromArgb(255, 52, 52, 52) : Color.FromArgb(255, 250, 250, 250); } - + WindowChrome.CaptionHeight = 32; goto End; End: ; } - + SizeChanged += (_, _) => RefreshFrame(); IsVisibleChanged += (_, _) => RefreshFrame(); @@ -207,15 +208,14 @@ static bool IsDarkBackground(WinUIColor color) //RefreshDarkMode(dark: Dark); SetBackdrop((CustomPInvoke.BackdropType)Enum.Parse(typeof(CustomPInvoke.BackdropType), Settings.Default.BackdropType, ignoreCase: true)); #else - - if (!IsWin7) + ThemeChanged += RefreshFrame; +#endif + if (!IsNewTitleBarSupported) { TitleBarCaptionButtons.Visibility = Visibility.Visible; foreach (var child in TitleBarCaptionButtons.Children) WindowChrome.SetIsHitTestVisibleInChrome(child as IInputElement, true); } - ThemeChanged += RefreshFrame; -#endif // Just to make everything updated again var d = Dark; Dark = d; @@ -453,7 +453,7 @@ private void Minimize(object sender, RoutedEventArgs e) private void Maximize(object sender, RoutedEventArgs e) { - WindowState = WindowState.Maximized; + WindowState = WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized; } private void Close(object sender, RoutedEventArgs e) @@ -505,14 +505,13 @@ public MainWindow() { if (WebView.CanGoForward) WebView.GoForward(); }; - SizeChanged += (_, _) => + if (!IsNewTitleBarSupported) + SizeChanged += (_, _) => { - if (!NewSDKTitleBar) - { - var a = WindowState == WindowState.Maximized ? 7.5 : 0; - TitleBar.Margin = new Thickness(a, a, 0, 0); - WebView.Margin = new Thickness(7.5, 0, 7.5, 7.5); - } + var a = WindowState == WindowState.Maximized ? 7.5 : 0; + TitleBar.Margin = new Thickness(a, a, 0, 0); + TitleBarCaptionButtons.Margin = new Thickness(0, 0, 7.5, 0); + WebView.Margin = new Thickness(7.5, 0, 7.5, 7.5); }; } WindowChrome WindowChrome { get; } = new WindowChrome diff --git a/Mica Discord/Mica Discord WPF.csproj.user b/Mica Discord/Mica Discord WPF.csproj.user index c89ffda..f33152f 100644 --- a/Mica Discord/Mica Discord WPF.csproj.user +++ b/Mica Discord/Mica Discord WPF.csproj.user @@ -1,8 +1,8 @@  - <_LastSelectedProfileId>D:\Programming\VS\Mica Discord\Mica Discord\Properties\PublishProfiles\ClickOnce Windows 7.pubxml - net6.0-windows10.0.22000.0 + <_LastSelectedProfileId>D:\Programming\VS\Mica Discord\Mica Discord\Properties\PublishProfiles\ClickONce Windows 10.pubxml + net6.0-windows10.0.17763.0 diff --git a/Mica Discord/Properties/PublishProfiles/ClickONce Windows 10.pubxml b/Mica Discord/Properties/PublishProfiles/ClickONce Windows 10.pubxml index a732878..64fd9ae 100644 --- a/Mica Discord/Properties/PublishProfiles/ClickONce Windows 10.pubxml +++ b/Mica Discord/Properties/PublishProfiles/ClickONce Windows 10.pubxml @@ -4,8 +4,8 @@ https://go.microsoft.com/fwlink/?LinkID=208121. --> - 3 - 1.10.0.* + 1 + 1.10.1.* True Release False @@ -25,11 +25,10 @@ https://go.microsoft.com/fwlink/?LinkID=208121. False (none) False - net6.0-windows7.0 + net6.0-windows10.0.17763.0 False Foreground False Publish.html - True|2022-05-09T02:55:14.4291313Z;True|2022-05-09T09:54:02.4047097+07:00; \ No newline at end of file diff --git a/Mica Discord/Properties/PublishProfiles/ClickONce Windows 10.pubxml.user b/Mica Discord/Properties/PublishProfiles/ClickONce Windows 10.pubxml.user index f931370..a74d353 100644 --- a/Mica Discord/Properties/PublishProfiles/ClickONce Windows 10.pubxml.user +++ b/Mica Discord/Properties/PublishProfiles/ClickONce Windows 10.pubxml.user @@ -4,6 +4,6 @@ https://go.microsoft.com/fwlink/?LinkID=208121. --> - True|2022-05-09T03:01:31.8714154Z;True|2022-05-09T09:55:14.4291313+07:00;True|2022-05-09T09:54:02.4047097+07:00; + True|2022-05-09T03:33:01.9180060Z; \ No newline at end of file diff --git a/Mica Discord/Properties/PublishProfiles/ClickOnce Windows 7.pubxml b/Mica Discord/Properties/PublishProfiles/ClickOnce Windows 7.pubxml index 09679fd..3947eaf 100644 --- a/Mica Discord/Properties/PublishProfiles/ClickOnce Windows 7.pubxml +++ b/Mica Discord/Properties/PublishProfiles/ClickOnce Windows 7.pubxml @@ -4,15 +4,15 @@ https://go.microsoft.com/fwlink/?LinkID=208121. --> - 2 - 1.10.0.* + 0 + 1.10.1.0 True Release False True True Disk - True + False False True False @@ -30,6 +30,5 @@ https://go.microsoft.com/fwlink/?LinkID=208121. Foreground False Publish.html - True|2022-05-09T02:55:00.7361137Z; \ No newline at end of file diff --git a/Mica Discord/Properties/PublishProfiles/ClickOnce Windows 7.pubxml.user b/Mica Discord/Properties/PublishProfiles/ClickOnce Windows 7.pubxml.user index b5f2ff5..cee5ab8 100644 --- a/Mica Discord/Properties/PublishProfiles/ClickOnce Windows 7.pubxml.user +++ b/Mica Discord/Properties/PublishProfiles/ClickOnce Windows 7.pubxml.user @@ -4,6 +4,6 @@ https://go.microsoft.com/fwlink/?LinkID=208121. --> - True|2022-05-09T03:02:10.1784420Z;True|2022-05-09T09:55:00.7361137+07:00; + True|2022-05-09T03:32:26.4535440Z; \ No newline at end of file