-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Panel will now recentre on main screen if it is not visible. Quick Ob…
…servation window changed to centre on panel just like all other EAACP dialogs.
- Loading branch information
Showing
6 changed files
with
55 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Drawing; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Forms; | ||
|
||
namespace EAACP | ||
{ | ||
internal class WindowHelper | ||
{ | ||
public static void EnsureWindowVisible(Form form, Form parent = null) | ||
{ | ||
bool isVisible = false; | ||
|
||
// Check if the window is at least partially visible on any screen | ||
foreach (Screen screen in Screen.AllScreens) | ||
{ | ||
if (screen.WorkingArea.IntersectsWith(form.Bounds)) | ||
{ | ||
isVisible = true; | ||
return; | ||
} | ||
} | ||
|
||
// If the window is not visible on any screen, center it on the primary screen | ||
if (!isVisible) | ||
{ | ||
if (parent != null) | ||
{ | ||
form.StartPosition = FormStartPosition.CenterParent; | ||
return; | ||
} | ||
|
||
var primary = Screen.PrimaryScreen; | ||
var primaryWorkingArea = primary.WorkingArea; | ||
int primaryCenterX = (primaryWorkingArea.Right - form.Width) / 2; | ||
int primaryCenterY = (primaryWorkingArea.Bottom - form.Height) / 2; | ||
form.Location = new Point(primaryCenterX, primaryCenterY); | ||
} | ||
} | ||
} | ||
} |