Fix window position on macOS
This commit is contained in:
parent
8caed1f4d2
commit
c345223fdc
@ -3,6 +3,7 @@ using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Media.Imaging;
|
||||
using Avalonia.Platform;
|
||||
|
||||
@ -20,6 +21,17 @@ namespace AvaloniaCoreRTDemo
|
||||
return new Bitmap(assetStream);
|
||||
}
|
||||
|
||||
public static PixelPoint GetWindowPosition(Window window)
|
||||
{
|
||||
if (!IsOSX || !window.FrameSize.HasValue)
|
||||
return window.Position;
|
||||
else
|
||||
{
|
||||
Int32 yOffset = (Int32)(window.FrameSize.Value.Height - window.ClientSize.Height);
|
||||
return new(window.Position.X, window.Position.Y + yOffset);
|
||||
}
|
||||
}
|
||||
|
||||
public static Bitmap GetImageFromFile(String path)
|
||||
{
|
||||
try
|
||||
|
@ -25,7 +25,7 @@ namespace AvaloniaCoreRTDemo.Windows
|
||||
|
||||
IThemeSwitch IMainWindow.ThemeSwitch => (IThemeSwitch)this._app!;
|
||||
IMainWindowState IMainWindow.Model => (IMainWindowState)this.MainControl.DataContext!;
|
||||
PixelPoint IMainWindow.Position => this.Position;
|
||||
PixelPoint IMainWindow.Position => Utilities.GetWindowPosition(this);
|
||||
Size IMainWindow.ClientSize => this.ClientSize;
|
||||
Size? IMainWindow.FrameSize => this.FrameSize;
|
||||
WindowState IMainWindow.State => this.WindowState;
|
||||
|
Loading…
x
Reference in New Issue
Block a user