Skip to content

Commit 7a97ab4

Browse files
committed
Make Form.ShowDialogOnScreen extension not throw
fixes cd7605d
1 parent ffdb5d6 commit 7a97ab4

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/BizHawk.Client.EmuHawk/Extensions/ControlExtensions.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,11 @@ public static DialogResult ShowDialogOnScreen(this Form form)
8787
var topLeft = new Point(
8888
Math.Max(0, form.Location.X),
8989
Math.Max(0, form.Location.Y));
90-
var screen = Screen.AllScreens.First(s => s.WorkingArea.Contains(topLeft));
91-
var w = screen.WorkingArea.Right - form.Bounds.Right;
92-
var h = screen.WorkingArea.Bottom - form.Bounds.Bottom;
90+
var screen = Screen.AllScreens.Select(static s => s.WorkingArea)
91+
.FirstOrNull(a => a.Contains(topLeft))
92+
?? default; //TODO is zeroed the correct fallback value? --yoshi
93+
var w = screen.Right - form.Bounds.Right;
94+
var h = screen.Bottom - form.Bounds.Bottom;
9395
if (h < 0) topLeft.Y += h;
9496
if (w < 0) topLeft.X += w;
9597
form.SetDesktopLocation(topLeft.X, topLeft.Y);

0 commit comments

Comments
 (0)