Circle Progress Bar

Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
14 posts Page 1 of 2
User avatar
Bogoh67
VIP - Site Partner
VIP - Site Partner
Posts: 656
Joined: Sun Apr 18, 2010 8:20 pm

Circle Progress Bar
Bogoh67
i got this from http://www.leetcoders.org/showthread.php?tid=3251
add new class delete all code and write this
Code: Select all
Imports System.Drawing.Drawing2D
Public Class Circle_Pro_Bar : Inherits Control

    Sub New()
        Size = New Size(100, 100)
        Font = New Font(Font.FontFamily, 20)
    End Sub

    'Notice in our properties, in the set routine we call 'Invalidate()' this will cause the
    'control to redraw anytime the values are changed.

    Private _Value As Long
    Public Property Value() As Long
        Get
            Return _Value
        End Get
        Set(ByVal v As Long)
            If v > _Maximum Then v = _Maximum
            _Value = v : Invalidate()
        End Set
    End Property

    Private _Maximum As Long = 100
    Public Property Maximum() As Long
        Get
            Return _Maximum
        End Get
        Set(ByVal v As Long)
            If v < 1 Then v = 1
            _Maximum = v : Invalidate()
        End Set
    End Property

    Private _Thickness As Integer = 14
    Public Property Thickness() As Integer
        Get
            Return _Thickness
        End Get
        Set(ByVal v As Integer)
            _Thickness = v : Invalidate()
        End Set
    End Property

    'Handle PaintBackground to prevent flicker
    Protected Overrides Sub OnPaintBackground(ByVal p As PaintEventArgs)
    End Sub

    Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
        MyBase.OnPaint(e)

        'Create image buffer
        Using B As New Bitmap(Width, Height)
            Using G = Graphics.FromImage(B)
                'Enable anti-aliasing to prevent rough edges
                G.SmoothingMode = 2

                'Fill background color
                G.Clear(BackColor)

                'Draw progress background
                Using T As New LinearGradientBrush(ClientRectangle, Color.Blue, Color.DarkBlue, LinearGradientMode.Vertical)
                    Using P As New Pen(T, Thickness)
                        G.DrawArc(P, CInt(Thickness / 2), CInt(Thickness / 2), Width - Thickness - 1, Height - Thickness - 1, 0, 360)
                    End Using
                End Using

                'Draw progress
                Using T As New LinearGradientBrush(ClientRectangle, Color.LightBlue, Color.Blue, LinearGradientMode.Vertical)
                    Using P As New Pen(T, Thickness)
                        P.StartCap = 2 : P.EndCap = 2
                        G.DrawArc(P, CInt(Thickness / 2), CInt(Thickness / 2), Width - Thickness - 1, Height - Thickness - 1, -90, CInt((360 / _Maximum) * _Value))
                    End Using
                End Using

                'Draw center
                Using T As New LinearGradientBrush(ClientRectangle, Color.Blue, Color.LightBlue, LinearGradientMode.Vertical)
                    G.FillEllipse(T, Thickness, Thickness, Width - Thickness * 2 - 1, Height - Thickness * 2 - 1)
                End Using

                'Draw progress string
                Dim S = G.MeasureString(CInt((100 / _Maximum) * _Value), Font)
                G.DrawString(CInt((100 / _Maximum) * _Value), Font, Brushes.DarkBlue, Width / 2 - S.Width / 2, Height / 2 - S.Height / 2)

                'Draw outter border
                G.DrawEllipse(Pens.DarkBlue, 0, 0, Width - 1, Height - 1)

                'Draw inner border
                G.DrawEllipse(Pens.DarkBlue, Thickness, Thickness, Width - Thickness * 2 - 1, Height - Thickness * 2 - 1)

                'Output the buffered image
                e.Graphics.DrawImage(B.Clone, 0, 0)
            End Using
        End Using

    End Sub

End Class

then debug
stop debugging go back to your from look at toolbox
User avatar
Kieken72
VIP - Donator
VIP - Donator
Posts: 231
Joined: Sun May 02, 2010 10:38 am

Re: Circle Progress Bar
Kieken72
Can u make a dll of it ?
User avatar
Codex
Coding God
Coding God
Posts: 2028
Joined: Wed Mar 31, 2010 5:50 pm

Re: Circle Progress Bar
Codex
Maybe post a screenshot ? the one on the site is small and you need to be a member to see it.
We shall let the revolution begin.. the revolution for freedom, freedom against censorship. We shall fight in the fields and in the streets, we shall fight in the hills; we shall never surrender
User avatar
XTechVB
VIP - Site Partner
VIP - Site Partner
Posts: 727
Joined: Thu May 20, 2010 10:32 am

Re: Circle Progress Bar
XTechVB
CodexVideos wrote:
Maybe post a screenshot ? the one on the site is small and you need to be a member to see it.
Capture.PNG
I'm making a dll with custom controls that i find most useful, and i will include this. with credits to the author of the original post
You do not have the required permissions to view the files attached to this post.
You can find me on Facebook or on Skype mihai_92b
User avatar
jtlusco
VIP - Donator
VIP - Donator
Posts: 138
Joined: Mon Jul 12, 2010 11:28 pm

Re: Circle Progress Bar
jtlusco
Aeonhack is a awsome coder i started watching his tuts when i first started codeing
Have you been scripted today
Image
User avatar
mikethedj4
VIP - Site Partner
VIP - Site Partner
Posts: 2592
Joined: Thu Mar 25, 2010 4:36 am

Re: Circle Progress Bar
mikethedj4
That's pretty cool
User avatar
Bogoh67
VIP - Site Partner
VIP - Site Partner
Posts: 656
Joined: Sun Apr 18, 2010 8:20 pm

Re: Circle Progress Bar
Bogoh67
ohhh thanks mtech dont forget to post it for us to see. and can i get some reputation points people?
User avatar
zachman61
VIP - Donator
VIP - Donator
Posts: 1892
Joined: Wed Dec 16, 2009 9:56 pm

Re: Circle Progress Bar
zachman61
nice find bogoh67 i would rep but have very little if it takes away so i cannot even try to
Nailing my feet to the floor is easier than using my own muscles to balance, but you don't see me doing that :)
User avatar
Bogoh67
VIP - Site Partner
VIP - Site Partner
Posts: 656
Joined: Sun Apr 18, 2010 8:20 pm

Re: Circle Progress Bar
Bogoh67
fine with me :)
User avatar
Proprogrammer
VIP - Donator
VIP - Donator
Posts: 415
Joined: Sun Oct 03, 2010 11:14 pm

Re: Circle Progress Bar
Proprogrammer
Great job!
------------------------------------------------------------------------------
Proprogrammer, not just a Programmer.
14 posts Page 1 of 2
Return to “Tutorials”