Skip to content

Commit

Permalink
Draw progress bar when ProgresBarRenderer.IsSupported is false
Browse files Browse the repository at this point in the history
  • Loading branch information
HebaruSan committed Nov 30, 2024
1 parent 5b6c18d commit 6d44e16
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions GUI/Controls/LabeledProgressBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,31 @@ public LabeledProgressBar()

protected override void OnPaint(PaintEventArgs e)
{
ProgressBarRenderer.DrawHorizontalBar(e.Graphics, ClientRectangle);
ProgressBarRenderer.DrawHorizontalChunks(e.Graphics,
new Rectangle(ClientRectangle.X,
ClientRectangle.Y,
ClientRectangle.Width
* (Value - Minimum)
if (ProgressBarRenderer.IsSupported)
{
ProgressBarRenderer.DrawHorizontalBar(e.Graphics, ClientRectangle);
ProgressBarRenderer.DrawHorizontalChunks(e.Graphics,
new Rectangle(ClientRectangle.X,
ClientRectangle.Y,
ClientRectangle.Width * (Value - Minimum)
/ (Maximum - Minimum),
ClientRectangle.Height));
}
else
{
const int borderWidth = 1;
var innerRect = Rectangle.Inflate(ClientRectangle, -2 * borderWidth,
-2 * borderWidth);
innerRect.Offset(borderWidth, borderWidth);
e.Graphics.DrawRectangle(SystemPens.ControlDark, ClientRectangle);
e.Graphics.FillRectangle(SystemBrushes.Control, innerRect);
e.Graphics.FillRectangle(SystemBrushes.Highlight,
new Rectangle(innerRect.X,
innerRect.Y,
innerRect.Width * (Value - Minimum)
/ (Maximum - Minimum),
ClientRectangle.Height));
innerRect.Height));
}
TextRenderer.DrawText(e.Graphics, Text, Font,
new Point((Width - textSize.Width) / 2,
(Height - textSize.Height) / 2),
Expand Down

0 comments on commit 6d44e16

Please sign in to comment.