Skip to content

Commit 66a87e9

Browse files
committed
Adjust windowsize if it exceeds the screen resolution
1 parent 15ad192 commit 66a87e9

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/Privatezilla/MainWindow.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,18 @@ public void Globalization()
9191
State.Text = Locale.columnState; // State column
9292
}
9393

94+
private void AutoAdjustScreensize()
95+
{
96+
var screen = Screen.FromControl(this);
97+
var screenSize = screen.Bounds.Size;
98+
99+
if (Width > screenSize.Width)
100+
Width = screenSize.Width;
101+
102+
if (Height > screenSize.Height)
103+
Height = screenSize.Height - 30; //Height -30 because of the Windows Task bar
104+
}
105+
94106
public MainWindow()
95107
{
96108
// Uncomment lower line and add lang code to run localization test
@@ -109,6 +121,9 @@ public MainWindow()
109121

110122
// GUI localization
111123
Globalization();
124+
125+
//Adjust to current screensize if window is too big
126+
AutoAdjustScreensize();
112127
}
113128

114129
public void InitializeSettings()

0 commit comments

Comments
 (0)