Gradient progress replacement

06-19-2006, 02:20 PM
I am using this

Private Sub ProgressTimerHandler(ByVal sender As System.Object, ByVal e As System.Timers.ElapsedEventArgs)
Static _Place As Double
Dim Rect As New Rectangle(CInt(_Place) - CInt((Progress.Width * 0.2)), Progress.Left - 9, CInt((Progress.Width * 0.2)), Progress.Height)
Dim Brush As New System.Drawing.Drawing2D.LinearGradientBrush(Rect, Color.LightBlue, Color.MidnightBlue, Drawing2D.LinearGradientMode.Horizontal)
Dim Painter As Graphics = Progress.CreateGraphics
Painter.FillRectangle(Brush, Rect)
If _Place > 0 Then
_Place -= 3
_Place = Progress.Width + (Progress.Width * 0.2)
End If
End Sub

To produce a progressbar type effect on a picturebox, "Progress"

It works fine, but I would love to be able to reverse the gradient and have the effect of it bouncing back and forth. Any Ideas on how to reverse the gradient?

06-20-2006, 10:06 AM
You might try reversing the rectangle that you pass to the FillRectangle call. Basically, set X to the far right-side edge and make the width negative (you should probably leave Y and Height alone. Not sure if the fillrect will work with such a rectangle, but it works for flipping images.

06-21-2006, 06:37 PM
Just swap the order of the colors.

Attached is a custom progress bar class:
Inherits control
Double buffered so all painting must be done in the paint event
Ivalidate(rectangle) fires the paint event.
By specifying only the area that needs updating, you can tweak performance.
It uses a symmetrical pattern for the brush, by using the setSigmaBlend thing.

It would perform better with horizontal stipes, that way you only need to update two very small strips at either end of the progress indicator portion of the bar (or one end if it is not a marquee style bar). As it is, it looks ok so long as it isn't going too fast. GDI+ is not good at high frame rates.

06-25-2006, 10:06 AM
Slightly different effect than I was going for, but I believe from looking at the code I can fix a few things in mine. Thanks.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum