Click here to Skip to main content
15,911,142 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Sir,

Sir actually i m making a timer Progress control in vb.net in it i m not getting that how to make a circle for it and to fill it with color as time increase?
my project is:
1. Create a circle
2. Total dimension of circle is total time
3. When open the page start the Timer Progress Chart.
4. The time is continuing the circle will be Green particular part.
5. The duration of increment will be of 10 minutes interval.
6. So in one hour, there will be 6 increments.
7. Every Increment will be denoted by of green layer.
8. This means every 10 minutes a green layer will get incremented in the chart.
9. When Exam time is completed, the complete Circle becomes Green.
10. This system will also alert the user / Candidate 15 minutes before the Exam completion time.
11. This alert will be an inline alert and will continue end of the Exam.
12. After completion of the Exam time the system will automatically save the user data and move to the Exam completion page.
how to make this?
please help me sir.

Thank You.
Posted
Comments
SURBHI TYAGI 27-Jun-11 5:22am    
please reply sir.
Dave Kreskowiak 27-Jun-11 15:33pm    
It's extremely rude to demand replys to your questions. We volunteer our time here. We answer them when we can, not when you demand.
SURBHI TYAGI 27-Jun-11 6:08am    
Atleast tell me how to draw the circle in vb.net? because i am very new to vb.

Here is a very crude code i have knocked up this morning, it will help you get going. Now, I hadn't got a clue what i was doing either when i started, so answered this question as more of an learning for me more than anything! So apologies to anyone who thinks its rubbish!

first create a new form with the following controls (you can get the names from the code);
a textbox (for a duration in seconds)
a textbox (for the number of segments, note: this cannot exceed the number of seconds)
a button (to start the timer)
a button (to stop the timer)
a progress bar, just so you can see whats happening in between segment draws
a label, to hold the number of ticks also so you can see what is happening.

I started with 60 seconds and 10 segments, (so draws a new segment every 6 seconds), 60 and 60 works fine as well.


It is very crude, but functional, but you will need to do more bounds checking etc as i haven't bothered (hence the reason for the segments not being greater than number of seconds!).

VB
Imports System.Drawing
Imports System.Drawing.Drawing2D


Public Class Form1

    Private WithEvents theTimer As Timer = New Timer

    Private timerTickCount As Integer = 0
    Private timerTargetTicks As Integer = 0


    Private Sub ButtonStart_Click(sender As System.Object, e As System.EventArgs) Handles ButtonStart.Click
        theTimer.Interval = 1000

        timerTickCount = 0
        timerTargetTicks = CInt(TextBoxDuration.Text)

        ProgressTimer.Minimum = 0
        ProgressTimer.Value = 0
        ProgressTimer.Maximum = timerTargetTicks
        ProgressTimer.Step = 1

        DrawTimerSurface()

        theTimer.Start()

    End Sub

    Private Sub ButtonStop_Click(sender As System.Object, e As System.EventArgs) Handles ButtonStop.Click
        theTimer.Stop()

    End Sub

    Private Sub theTimer_Tick(sender As Object, e As System.EventArgs) Handles theTimer.Tick
        timerTickCount += 1

        updateProgress()

    End Sub

    Private Sub updateProgress()
        LabelTicks.Text = timerTickCount.ToString

        ProgressTimer.Increment(1)

        'Draw the timer Segments (we only need the int, not the remainder) hence \
        drawSegment(timerTickCount \ (timerTargetTicks / CInt(TextBoxSegments.Text)))


        'Check if finished
        If timerTickCount >= timerTargetTicks Then
            theTimer.Stop()
            MsgBox("Finished!")
        End If

    End Sub


    Private Sub DrawTimerSurface()

        'Clear the previous drawing if it exists
        Dim timer_brush_background As Brush = Brushes.White
        Me.CreateGraphics.FillPie(timer_brush_background, 15, 125, 250, 250, 0, 360)

        'Draw the outer circle
        Dim pen As New Drawing.Pen(System.Drawing.Color.Green, 1)
        Me.CreateGraphics.DrawEllipse(pen, 15, 125, 250, 250)

    End Sub

    Private Sub drawSegment(segmentNumber As Integer)

        'Can't draw No segments so just exit sub
        If segmentNumber = 0 Then Exit Sub

        'Set the brush color for the segment
        Dim pie_brush As Brush = Brushes.Green

        Dim segmentCount As Integer = CInt(TextBoxSegments.Text)
        Dim segmentAngle As Integer = 360 / segmentCount

        ' Note: 0 is on the horizontal so we also need to offset by -90Degrees
        Dim startAngle As Integer = ((segmentAngle * segmentNumber) - segmentAngle) - 90

        'Draw the segment
        Me.CreateGraphics.FillPie(pie_brush, 15, 125, 250, 250, startAngle, segmentAngle)

    End Sub
 
Share this answer
 
v3
A Couple of Codeproject articles for you to have a look at. They are in C# but it shouldn't be hard to convert

Sql 2005 Circular Progress bar[^]

Circular Progress Bar[^]

Just incase a link to a C# to VB.net Converter [^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900