Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
Cicular Progressbar
Author:
Michel Renaud
E-mail:
Click to e-mail author
Submitted:
5/13/2012
Version:
VB 2010
Compatibility:
VB 2010
Category:
Graphics
Views:
11662
The easy way for drawing on a bitmap with graphicPath this is an example.
Declarations:
'none
Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.CenterToParent() Me.SetStyle(ControlStyles.ResizeRedraw, True) Me.SetStyle(ControlStyles.DoubleBuffer, True) Me.SetStyle(ControlStyles.AllPaintingInWmPaint, True) End Sub Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint Static i As Integer i += 1 If i = 360 Then i = 0 End If Me.BackgroundImage = DrawProgressBar(e.Graphics, i) End Sub Private Function DrawProgressBar(ByVal g As Graphics, ByVal angle As Integer) As Bitmap Dim bmp As New Bitmap(Me.ClientRectangle.Width, Me.ClientRectangle.Height) g = Graphics.FromImage(bmp) Dim percent As Double percent = Math.Round(angle * 100 / 360, 1) Dim gp As New GraphicsPath Dim rect As Rectangle = New Rectangle(0, 0, bmp.Width, bmp.Height) Dim sf As New StringFormat sf.Alignment = StringAlignment.Center sf.LineAlignment = StringAlignment.Center g.DrawString(percent & " %", New Font("Arial", 20, FontStyle.Regular), Brushes.Black, New Point(rect.Width / 2, rect.Height / 2), sf) g.DrawEllipse(Pens.Black, rect) gp.AddPie(rect, 180, angle) Dim holeRect As Rectangle = New Rectangle(rect.X + 15, rect.Y + 15, rect.Width - 30, rect.Height - 30) g.DrawEllipse(Pens.Black, holeRect) g.Clip = (New Region(gp)) gp.AddPie(holeRect, 180, angle) Dim gb As New LinearGradientBrush(rect, Color.Red, Color.Blue, 45) g.FillPath(gb, gp) Invalidate(rect) Return bmp End Function
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2024 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement