From 37f15552b13be8257210954ea074fff3772a607c Mon Sep 17 00:00:00 2001 From: Nick Date: Thu, 4 May 2023 07:57:43 -0400 Subject: [PATCH] check for 0 maximum --- DoomLauncher/Controls/CProgressBar.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/DoomLauncher/Controls/CProgressBar.cs b/DoomLauncher/Controls/CProgressBar.cs index 5152d20b..02fc8354 100644 --- a/DoomLauncher/Controls/CProgressBar.cs +++ b/DoomLauncher/Controls/CProgressBar.cs @@ -13,12 +13,14 @@ public CProgressBar() protected override void OnPaint(PaintEventArgs e) { Rectangle rect = e.ClipRectangle; - DpiScale dpiScale = new DpiScale(e.Graphics); int padX = dpiScale.ScaleIntX(2); int padY = dpiScale.ScaleIntY(2); - rect.Width = (int)(rect.Width * ((double)Value / Maximum)) - (padX*2); + if (Maximum != 0) + rect.Width = (int)(rect.Width * ((double)Value / Maximum)); + rect.Width -= (padX * 2); + if (ProgressBarRenderer.IsSupported) ProgressBarRenderer.DrawHorizontalBar(e.Graphics, e.ClipRectangle); rect.Height -= padY * 2;