fix: Fixed the problem that the AvaloniaRider plugin on Windows cannot display the live preview for Avalonia XAML

This commit is contained in:
Gadfly 2024-04-12 01:23:08 +08:00
parent f3f39ac593
commit c0b13bdc8c
No known key found for this signature in database
GPG key ID: 9128145F93CFC69C

View file

@ -73,26 +73,21 @@ namespace SourceGit.Native
v.dwOSVersionInfoSize = (uint)Marshal.SizeOf<RTL_OSVERSIONINFOEX>(); v.dwOSVersionInfoSize = (uint)Marshal.SizeOf<RTL_OSVERSIONINFOEX>();
if (RtlGetVersion(ref v) == 0 && (v.dwMajorVersion < 10 || v.dwBuildNumber < 22000)) if (RtlGetVersion(ref v) == 0 && (v.dwMajorVersion < 10 || v.dwBuildNumber < 22000))
{ {
Window.WindowStateProperty.Changed.AddClassHandler<Window>((w, e) => Window.WindowStateProperty.Changed.AddClassHandler<Window>((w, e) => ExtendWindowFrame(w));
{ Window.LoadedEvent.AddClassHandler<Window>((w, e) => ExtendWindowFrame(w));
if (w.WindowState != WindowState.Maximized)
{
var margins = new MARGINS { cxLeftWidth = 1, cxRightWidth = 1, cyTopHeight = 1, cyBottomHeight = 1 };
DwmExtendFrameIntoClientArea(w.TryGetPlatformHandle().Handle, ref margins);
}
});
Window.LoadedEvent.AddClassHandler<Window>((w, e) =>
{
if (w.WindowState != WindowState.Maximized)
{
var margins = new MARGINS { cxLeftWidth = 1, cxRightWidth = 1, cyTopHeight = 1, cyBottomHeight = 1 };
DwmExtendFrameIntoClientArea(w.TryGetPlatformHandle().Handle, ref margins);
}
});
} }
} }
private void ExtendWindowFrame(Window w)
{
var platformHandle = w.TryGetPlatformHandle();
if (platformHandle == null)
return;
var margins = new MARGINS { cxLeftWidth = 1, cxRightWidth = 1, cyTopHeight = 1, cyBottomHeight = 1 };
DwmExtendFrameIntoClientArea(platformHandle.Handle, ref margins);
}
public string FindGitExecutable() public string FindGitExecutable()
{ {
var reg = Microsoft.Win32.RegistryKey.OpenBaseKey( var reg = Microsoft.Win32.RegistryKey.OpenBaseKey(