mirror of
https://github.com/2dust/v2rayN.git
synced 2026-11-11 06:54:58 +03:00
Revert "fix: 在窗口初始化前设置保存的尺寸,消除启动时偏右下偏移 (#9498)"
This reverts commit 8147b39723.
https://github.com/2dust/v2rayN/issues/9740
This commit is contained in:
@@ -4,7 +4,6 @@ public class WindowBase<TViewModel> : ReactiveWindow<TViewModel> where TViewMode
|
|||||||
{
|
{
|
||||||
public WindowBase()
|
public WindowBase()
|
||||||
{
|
{
|
||||||
Initialized += OnWindowInitialized;
|
|
||||||
Loaded += OnLoaded;
|
Loaded += OnLoaded;
|
||||||
Loaded += (s, e) =>
|
Loaded += (s, e) =>
|
||||||
{
|
{
|
||||||
@@ -20,7 +19,7 @@ public class WindowBase<TViewModel> : ReactiveWindow<TViewModel> where TViewMode
|
|||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnWindowInitialized(object? sender, EventArgs e)
|
protected virtual void OnLoaded(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -30,23 +29,22 @@ public class WindowBase<TViewModel> : ReactiveWindow<TViewModel> where TViewMode
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sizeItem.Width > 0 && !Width.Equals(sizeItem.Width))
|
var screen = Screens.ScreenFromWindow(this) ?? Screens.Primary;
|
||||||
{
|
var scaling = screen.Scaling > 0 ? screen.Scaling : 1.0;
|
||||||
Width = sizeItem.Width;
|
var workingArea = screen.WorkingArea;
|
||||||
}
|
|
||||||
|
|
||||||
if (sizeItem.Height > 0 && !Height.Equals(sizeItem.Height))
|
var width = Math.Min(sizeItem.Width, workingArea.Width / scaling);
|
||||||
{
|
var height = Math.Min(sizeItem.Height, workingArea.Height / scaling);
|
||||||
Height = sizeItem.Height;
|
var x = workingArea.X + ((workingArea.Width - (width * scaling)) / 2);
|
||||||
}
|
var y = workingArea.Y + ((workingArea.Height - (height * scaling)) / 2);
|
||||||
|
|
||||||
|
Width = width;
|
||||||
|
Height = height;
|
||||||
|
Position = new PixelPoint((int)x, (int)y);
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void OnLoaded(object? sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnClosed(EventArgs e)
|
protected override void OnClosed(EventArgs e)
|
||||||
{
|
{
|
||||||
base.OnClosed(e);
|
base.OnClosed(e);
|
||||||
|
|||||||
Reference in New Issue
Block a user