From cb80ffe5b48938a27f0014ef122f7a094c69bbd0 Mon Sep 17 00:00:00 2001 From: not-nullptr Date: Wed, 18 Sep 2024 01:04:38 +0100 Subject: [PATCH] double click to close, fix window chrome fullscreen --- Aerochat/Controls/BasicTitlebar.cs | 27 +++++++++++++++++++++++++ Aerochat/Controls/NoDwmTitlebar.xaml | 4 +++- Aerochat/Controls/NoDwmTitlebar.xaml.cs | 6 ++++++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/Aerochat/Controls/BasicTitlebar.cs b/Aerochat/Controls/BasicTitlebar.cs index e9a4252f..cbe3db51 100644 --- a/Aerochat/Controls/BasicTitlebar.cs +++ b/Aerochat/Controls/BasicTitlebar.cs @@ -152,6 +152,33 @@ protected override void OnInitialized(EventArgs e) if (Window != null) { Window.SourceInitialized += Window_SourceInitialized; + Window.StateChanged += Window_StateChanged; + } + } + + private void Window_StateChanged(object? sender, EventArgs e) + { + if (IsDwmEnabled) return; + if (Window.WindowState == WindowState.Maximized) + { + Titlebar.Visibility = Visibility.Collapsed; + WindowChrome.SetWindowChrome(Window, null); + FirstBorder.BorderThickness = new Thickness(0); + SecondBorder.BorderThickness = new Thickness(0); + // set the grid's first row to 0 + Container.RowDefinitions[0].Height = new GridLength(0); + } + else + { + Titlebar.Visibility = Visibility.Visible; + WindowChrome chrome = new WindowChrome(); + chrome.CaptionHeight = 28; + chrome.CornerRadius = new CornerRadius(6, 6, 0, 0); + chrome.GlassFrameThickness = new Thickness(0); + WindowChrome.SetWindowChrome(Window, chrome); + FirstBorder.BorderThickness = new Thickness(1); + SecondBorder.BorderThickness = new Thickness(1); + Container.RowDefinitions[0].Height = new GridLength(28); } } diff --git a/Aerochat/Controls/NoDwmTitlebar.xaml b/Aerochat/Controls/NoDwmTitlebar.xaml index f4a2f481..83c9dde7 100644 --- a/Aerochat/Controls/NoDwmTitlebar.xaml +++ b/Aerochat/Controls/NoDwmTitlebar.xaml @@ -15,7 +15,9 @@ - +