Skip to content

Commit

Permalink
Prevent crashes in MainWindow.OnDpiChanged
Browse files Browse the repository at this point in the history
  • Loading branch information
Klocman committed May 15, 2023
1 parent be01b5d commit 7c007af
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions source/BulkCrapUninstaller/Forms/Windows/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,19 @@ protected override void OnDpiChanged(DpiChangedEventArgs e)
{
base.OnDpiChanged(e);

var scaleChange = e.DeviceDpiNew / (double)e.DeviceDpiOld;
try
{
var scaleChange = e.DeviceDpiNew / (double)e.DeviceDpiOld;

toolStripLabelSize.Width = (int)Math.Round(toolStripLabelSize.Width * scaleChange);
toolStripLabelTotal.Width = (int)Math.Round(toolStripLabelTotal.Width * scaleChange);
if (toolStripLabelSize != null)
toolStripLabelSize.Width = (int)Math.Round(toolStripLabelSize.Width * scaleChange);
if (toolStripLabelTotal != null)
toolStripLabelTotal.Width = (int)Math.Round(toolStripLabelTotal.Width * scaleChange);
}
catch (SystemException exception)
{
Console.WriteLine(exception);
}
}

protected override void OnFormClosed(FormClosedEventArgs e)
Expand Down

0 comments on commit 7c007af

Please sign in to comment.