Skip to content

Commit

Permalink
Adjust windowsize if it exceeds the screen resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
erxbout committed May 26, 2022
1 parent 93a9ac4 commit ab36b33
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Privatezilla/MainWindow.cs
Expand Up @@ -91,6 +91,18 @@ public void Globalization()
State.Text = Locale.columnState; // State column
}

private void AutoAdjustScreensize()
{
var screen = Screen.FromControl(this);
var screenSize = screen.Bounds.Size;

if (Width > screenSize.Width)
Width = screenSize.Width;

if (Height > screenSize.Height)
Height = screenSize.Height - 30; //Height -30 because of the Windows Task bar
}

public MainWindow()
{
// Uncomment lower line and add lang code to run localization test
Expand All @@ -109,6 +121,9 @@ public MainWindow()

// GUI localization
Globalization();

//Adjust to current screensize if window is too big
AutoAdjustScreensize();
}

public void InitializeSettings()
Expand Down

0 comments on commit ab36b33

Please sign in to comment.