.net – Visual Basic循环进度条
发布时间:2020-12-17 00:08:32 所属栏目:大数据 来源:网络整理
导读:我正在尝试制作一个具有良好UI的软件,但我在VB中并不专业…… 我如何制作圆形进度条? 例如 如何使用GDI绘制自己的. 您可以稍后将其转换为您自己的用户控件,但这将帮助您入门.它应该是相当自我解释的: Private Sub Form2_Paint(sender As Object,e As Paint
我正在尝试制作一个具有良好UI的软件,但我在VB中并不专业……
我如何制作圆形进度条? 例如
如何使用GDI绘制自己的.
您可以稍后将其转换为您自己的用户控件,但这将帮助您入门.它应该是相当自我解释的: Private Sub Form2_Paint(sender As Object,e As PaintEventArgs) Handles Me.Paint DrawProgress(e.Graphics,New Rectangle(5,5,60,60),40) DrawProgress(e.Graphics,New Rectangle(80,80) DrawProgress(e.Graphics,New Rectangle(155,57) End Sub Private Sub DrawProgress(g As Graphics,rect As Rectangle,percentage As Single) 'work out the angles for each arc Dim progressAngle = CSng(360 / 100 * percentage) Dim remainderAngle = 360 - progressAngle 'create pens to use for the arcs Using progressPen As New Pen(Color.LightSeaGreen,2),remainderPen As New Pen(Color.LightGray,2) 'set the smoothing to high quality for better output g.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias 'draw the blue and white arcs g.DrawArc(progressPen,rect,-90,progressAngle) g.DrawArc(remainderPen,progressAngle - 90,remainderAngle) End Using 'draw the text in the centre by working out how big it is and adjusting the co-ordinates accordingly Using fnt As New Font(Me.Font.FontFamily,14) Dim text As String = percentage.ToString + "%" Dim textSize = g.MeasureString(text,fnt) Dim textPoint As New Point(CInt(rect.Left + (rect.Width / 2) - (textSize.Width / 2)),CInt(rect.Top + (rect.Height / 2) - (textSize.Height / 2))) 'now we have all the values draw the text g.DrawString(text,fnt,Brushes.Black,textPoint) End Using End Sub 产量 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |