Skip to content

Commit 048a2da

Browse files
authored
fix: recover StatsWindow position when it ends up off-screen (#4774)
1 parent d39b9e7 commit 048a2da

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

Hearthstone Deck Tracker/Windows/StatsWindow.xaml.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#region
22

33
using System.ComponentModel;
4+
using System.Linq;
45
using System.Windows;
6+
using System.Windows.Forms;
7+
using Point = System.Drawing.Point;
58

69
#endregion
710

@@ -24,6 +27,19 @@ public StatsWindow(MainWindow mainWindowParent)
2427
Left = Config.Instance.StatsWindowLeft.Value;
2528
if(Config.Instance.StatsWindowTop.HasValue)
2629
Top = Config.Instance.StatsWindowTop.Value;
30+
31+
var titleBarCorners = new[]
32+
{
33+
new Point((int)Left + 5, (int)Top + 5),
34+
new Point((int)(Left + Width) - 5, (int)Top + 5),
35+
new Point((int)Left + 5, (int)(Top + TitlebarHeight) - 5),
36+
new Point((int)(Left + Width) - 5, (int)(Top + TitlebarHeight) - 5)
37+
};
38+
if(!Screen.AllScreens.Any(s => titleBarCorners.Any(c => s.WorkingArea.Contains(c))))
39+
{
40+
Top = 100;
41+
Left = 100;
42+
}
2743
}
2844

2945
public Thickness TitleBarMargin => new Thickness(0, TitlebarHeight, 0, 0);

0 commit comments

Comments
 (0)