From 8bb8851110ed86a9fa5d79ab3fda0227bb078752 Mon Sep 17 00:00:00 2001 From: AndrewBabbitt97 Date: Thu, 25 Jul 2024 09:00:00 -0600 Subject: [PATCH] fix: fullscreen state bug --- src/BlazorDesktop/Wpf/BlazorDesktopWindow.cs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/BlazorDesktop/Wpf/BlazorDesktopWindow.cs b/src/BlazorDesktop/Wpf/BlazorDesktopWindow.cs index 7ce587a..573989f 100644 --- a/src/BlazorDesktop/Wpf/BlazorDesktopWindow.cs +++ b/src/BlazorDesktop/Wpf/BlazorDesktopWindow.cs @@ -36,14 +36,13 @@ public partial class BlazorDesktopWindow : Window /// /// If the window is fullscreen. /// - public bool IsFullscreen => _fullscreen && WindowState == WindowState.Normal; + public bool IsFullscreen { get; private set; } /// /// Occurs when changes. /// public event EventHandler? OnFullscreenChanged; - private bool _fullscreen; private WindowState _fullscreenStoredState = WindowState.Normal; private readonly IServiceProvider _services; private readonly IConfiguration _config; @@ -95,10 +94,10 @@ public void ToggleFullScreen() { if (WindowStyle == WindowStyle.SingleBorderWindow) { - _fullscreen = true; + IsFullscreen = true; _fullscreenStoredState = WindowState; - UseFrame(_config.GetValue(WindowDefaults.Frame) ?? true, _fullscreen); + UseFrame(_config.GetValue(WindowDefaults.Frame) ?? true); WindowStyle = WindowStyle.None; if (WindowState == WindowState.Maximized) @@ -112,9 +111,9 @@ public void ToggleFullScreen() } else { - _fullscreen = false; + IsFullscreen = false; - UseFrame(_config.GetValue(WindowDefaults.Frame) ?? true, _fullscreen); + UseFrame(_config.GetValue(WindowDefaults.Frame) ?? true); WindowStyle = WindowStyle.SingleBorderWindow; WindowState = _fullscreenStoredState; @@ -240,7 +239,7 @@ private void InitializeWindow() MinWidth = minWidth; MaxHeight = maxHeight; MaxWidth = maxWidth; - UseFrame(useFrame, _fullscreen); + UseFrame(useFrame); ResizeMode = (_config.GetValue(WindowDefaults.Resizable) ?? true) ? ResizeMode.CanResize : ResizeMode.NoResize; UseIcon(_config.GetValue(WindowDefaults.Icon) ?? string.Empty); Content = WebViewBorder; @@ -312,7 +311,7 @@ private void UpdateWebViewBorderThickness() if (WindowState == WindowState.Maximized && !useFrame) { - if (_fullscreen) + if (IsFullscreen) { WebViewBorder.BorderThickness = new Thickness(7, 7, 7, 7); } @@ -345,11 +344,11 @@ private void UpdateTheme() } } - private void UseFrame(bool frame, bool fullscreen) + private void UseFrame(bool frame) { if (!frame) { - if (fullscreen) + if (IsFullscreen) { WindowChrome.SetWindowChrome(this, new() { NonClientFrameEdges = NonClientFrameEdges.None }); }