Fix Window Size

This commit is contained in:
RMBGAME
2021-11-02 15:37:28 +08:00
parent 6a6a3ec8d8
commit 85d464709e
3 changed files with 21 additions and 3 deletions
@@ -127,6 +127,11 @@ namespace System.Application.Services.Implementation
newSize.right -= 8;
newSize.bottom -= 8;
//if (_owner.IsNewSizeWindow)
//{
// _owner.Resized(new Size(ncParams.rgrc[1].Width, ncParams.rgrc[1].Height), PlatformResizeReason.Layout);
//}
_owner.IsNewSizeWindow = true;
}
@@ -124,7 +124,7 @@ namespace Avalonia.Controls
vm.SizePosition.Y = e.Point.Y;
}
}
bool _isFirstOpenWindow = true;
protected virtual void FluentWindow_Opened(object? sender, EventArgs e)
{
if (DataContext is WindowViewModel vm)
@@ -166,17 +166,22 @@ namespace Avalonia.Controls
vm.SizePosition.Width = x.Width;
vm.SizePosition.Height = x.Height;
});
this.GetObservable(WindowStateProperty)
.Subscribe(x =>
{
if (x == WindowState.Normal)
if (!_isFirstOpenWindow)
{
HandleResized(new Size(Width + (IsNewSizeWindow ? 32 : 0), Height + (IsNewSizeWindow ? 16 : 0)), PlatformResizeReason.Application);
if (x == WindowState.Normal)
{
HandleResized(new Size(Width + (IsNewSizeWindow ? 32 : 0), Height + (IsNewSizeWindow ? 16 : 0)), PlatformResizeReason.Application);
}
}
});
}
}
_isFirstOpenWindow = false;
IsHideWindow = false;
}
@@ -207,6 +212,11 @@ namespace Avalonia.Controls
#region CoreWindow
public void Resized(Size clientSize, PlatformResizeReason reason)
{
HandleResized(clientSize, reason);
}
Window ICoreWindow.Window => this;
MinMaxCloseControl? ICoreWindow.SystemCaptionButtons => _systemCaptionButtons;
@@ -1,5 +1,6 @@
using Avalonia.Input;
using Avalonia.Layout;
using Avalonia.Platform;
using Avalonia.Rendering;
using Avalonia.Styling;
using Avalonia.VisualTree;
@@ -24,6 +25,8 @@ namespace Avalonia.Controls
MinMaxCloseControl? SystemCaptionButtons { get; }
public void Resized(Size clientSize, PlatformResizeReason reason);
bool HitTestTitleBarRegion(APoint windowPoint)
{
return SystemCaptionButtons?.HitTestCustom(windowPoint) ?? false;