进入全屏前的窗口状态记录 改为监听 WindowStateChanged
This commit is contained in:
@@ -40,6 +40,8 @@ public class CaptionButtons: Avalonia.Controls.Chrome.CaptionButtons
|
|||||||
Button.ClickEvent.AddHandler((o, args) => OnRestore(), _restoreButton);
|
Button.ClickEvent.AddHandler((o, args) => OnRestore(), _restoreButton);
|
||||||
Button.ClickEvent.AddHandler((o, args) => OnMinimize(), _minimizeButton);
|
Button.ClickEvent.AddHandler((o, args) => OnMinimize(), _minimizeButton);
|
||||||
Button.ClickEvent.AddHandler((o, args) => OnToggleFullScreen(), _fullScreenButton);
|
Button.ClickEvent.AddHandler((o, args) => OnToggleFullScreen(), _fullScreenButton);
|
||||||
|
|
||||||
|
Window.WindowStateProperty.Changed.Subscribe(WindowStateChanged);
|
||||||
if (this.HostWindow is not null && !HostWindow.CanResize)
|
if (this.HostWindow is not null && !HostWindow.CanResize)
|
||||||
{
|
{
|
||||||
_restoreButton.IsEnabled = false;
|
_restoreButton.IsEnabled = false;
|
||||||
@@ -47,13 +49,20 @@ public class CaptionButtons: Avalonia.Controls.Chrome.CaptionButtons
|
|||||||
UpdateVisibility();
|
UpdateVisibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void WindowStateChanged(AvaloniaPropertyChangedEventArgs<WindowState> e)
|
||||||
|
{
|
||||||
|
if (e.NewValue.Value == WindowState.FullScreen)
|
||||||
|
{
|
||||||
|
_oldWindowState = e.OldValue.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected override void OnToggleFullScreen()
|
protected override void OnToggleFullScreen()
|
||||||
{
|
{
|
||||||
if (HostWindow != null)
|
if (HostWindow != null)
|
||||||
{
|
{
|
||||||
if (HostWindow.WindowState != WindowState.FullScreen)
|
if (HostWindow.WindowState != WindowState.FullScreen)
|
||||||
{
|
{
|
||||||
_oldWindowState = HostWindow.WindowState;
|
|
||||||
HostWindow.WindowState = WindowState.FullScreen;
|
HostWindow.WindowState = WindowState.FullScreen;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user