From 66a87e99818871a6c4ae79715fba4d325ce27ce6 Mon Sep 17 00:00:00 2001 From: ErXBout Date: Thu, 26 May 2022 12:53:52 +0200 Subject: [PATCH] Adjust windowsize if it exceeds the screen resolution --- src/Privatezilla/MainWindow.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Privatezilla/MainWindow.cs b/src/Privatezilla/MainWindow.cs index c9bc47a..9ef8977 100644 --- a/src/Privatezilla/MainWindow.cs +++ b/src/Privatezilla/MainWindow.cs @@ -91,6 +91,18 @@ namespace Privatezilla 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 @@ -109,6 +121,9 @@ namespace Privatezilla // GUI localization Globalization(); + + //Adjust to current screensize if window is too big + AutoAdjustScreensize(); } public void InitializeSettings()