Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruben2776 committed Feb 8, 2024
1 parent 3910e6a commit 61373e4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
9 changes: 3 additions & 6 deletions src/PicView.WPF/UILogic/Loading/StartLoading.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,15 @@ await startupWindow.Dispatcher.InvokeAsync(() =>
ConfigureWindows.GetMainWindow = mainWindow;
GetSpinWaiter = GetSpinWaiter;

if (SettingsHelper.Settings.WindowProperties.AutoFit == false)
{
SetLastWindowSize(mainWindow);
}

// Set min size to DPI scaling
mainWindow.MinWidth *= MonitorInfo.DpiScaling;
mainWindow.MinHeight *= MonitorInfo.DpiScaling;

SetWindowBehavior();
if (SettingsHelper.Settings.WindowProperties.AutoFit == false)
SetLastWindowSize(ConfigureWindows.GetMainWindow);
{
SetLastWindowSize(mainWindow);
}

mainWindow.Scroller.VerticalScrollBarVisibility = SettingsHelper.Settings.Zoom.ScrollEnabled
? ScrollBarVisibility.Auto
Expand Down
29 changes: 27 additions & 2 deletions src/PicView.WPF/UILogic/Sizing/WindowSizing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,33 @@ internal static void SetLastWindowSize(Window window)
{
window?.Dispatcher.Invoke(() =>
{
window.Top = SettingsHelper.Settings.WindowProperties.Top;
window.Left = SettingsHelper.Settings.WindowProperties.Left;
var top = SettingsHelper.Settings.WindowProperties.Top;
if (top < SystemParameters.VirtualScreenTop)
{
top = SystemParameters.VirtualScreenTop;
}
if (window.Top + window.Height > SystemParameters.VirtualScreenTop + SystemParameters.VirtualScreenHeight)
{
top = SystemParameters.VirtualScreenHeight + SystemParameters.VirtualScreenTop - window.Height;
}

var left = SettingsHelper.Settings.WindowProperties.Left;
if (left < 0)
{
left = MonitorInfo.WorkArea.Left;
}

if (left < SystemParameters.VirtualScreenLeft)
{
left = SystemParameters.VirtualScreenLeft;
}

if (left + window.Width > SystemParameters.VirtualScreenLeft + SystemParameters.VirtualScreenWidth)
{
left = SystemParameters.VirtualScreenWidth + SystemParameters.VirtualScreenLeft - window.Width;
}
window.Top = top;
window.Left = left;
window.Width = double.IsNaN(SettingsHelper.Settings.WindowProperties.Width) ? window.Width :
double.IsNaN(SettingsHelper.Settings.WindowProperties.Width) ? window.ActualWidth : SettingsHelper.Settings.WindowProperties.Width;
window.Height = double.IsNaN(SettingsHelper.Settings.WindowProperties.Height) ? window.Height :
Expand Down

0 comments on commit 61373e4

Please sign in to comment.