Skip to content

Commit

Permalink
check for 0 maximum
Browse files Browse the repository at this point in the history
  • Loading branch information
nstlaurent committed May 4, 2023
1 parent 10062da commit 37f1555
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions DoomLauncher/Controls/CProgressBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 37f1555

Please sign in to comment.