Fix window restore maximize statate on secondary monitor.
This commit is contained in:
parent
5ec01913d5
commit
3f0e6b9ee5
@ -2,6 +2,7 @@
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using LibationFileManager;
|
||||
using Microsoft.EntityFrameworkCore.Query.SqlExpressions;
|
||||
|
||||
namespace LibationWinForms
|
||||
{
|
||||
@ -44,6 +45,17 @@ namespace LibationWinForms
|
||||
|
||||
var rect = new Rectangle(x, y, savedState.Width, savedState.Height);
|
||||
|
||||
if (savedState.IsMaximized)
|
||||
{
|
||||
//When a window is maximized, the client rectangle is not on a screen (y is negative).
|
||||
form.StartPosition = FormStartPosition.Manual;
|
||||
form.DesktopBounds = rect;
|
||||
|
||||
// FINAL: for Maximized: start normal state, set size and location, THEN set max state
|
||||
form.WindowState = FormWindowState.Maximized;
|
||||
}
|
||||
else
|
||||
{
|
||||
// is proposed rect on a screen?
|
||||
if (Screen.AllScreens.Any(screen => screen.WorkingArea.Contains(rect)))
|
||||
{
|
||||
@ -56,8 +68,8 @@ namespace LibationWinForms
|
||||
form.Size = rect.Size;
|
||||
}
|
||||
|
||||
// FINAL: for Maximized: start normal state, set size and location, THEN set max state
|
||||
form.WindowState = savedState.IsMaximized ? FormWindowState.Maximized : FormWindowState.Normal;
|
||||
form.WindowState = FormWindowState.Normal;
|
||||
}
|
||||
}
|
||||
|
||||
public static void SaveSizeAndLocation(this Form form, Configuration config)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user