1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| rotected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)
MyBase.OnPaint(e)
Dim rect As New Rectangle(0, 0, Me.Width, Me.Height)
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias
Dim heightH As Integer = CInt((rect.Height - 8) / (Maximum - Minimum) * Value)
Dim points As New List(Of Point)
Dim _intX As Integer = LeftX
Dim y_offset As Integer = CInt((rect.Height - 15) - heightH)
points.Add(New Point(_intX, rect.Height - 1))
Dim x_scale As Single = CSng(_waveHeight * Math.PI / (_intX - _waveWidth))
For x As Integer = 0 To rect.Width - 1
Dim y As Single = CSng((y_offset + _waveHeight * Math.Sin(x * x_scale - _intX)))
points.Add(New Point(x, y))
Next
points.Add(New Point(rect.Width - 3, rect.Height - 3))
Using gp As New GraphicsPath(FillMode.Winding)
gp.AddEllipse(New Rectangle(rect.X + 1, rect.Y + 1, rect.Width - 3, rect.Height - 3))
gp.CloseFigure()
e.Graphics.FillPath(New SolidBrush(_ColorFill), gp)
gp.Reset()
gp.AddEllipse(New Rectangle(rect.X + 1, rect.Y + 1, rect.Width - 3, rect.Height - 3))
gp.CloseFigure()
e.Graphics.DrawPath(New Pen(New SolidBrush(_ColorBorder), 2), gp)
e.Graphics.SetClip(gp)
gp.Reset()
gp.AddPolygon(points.ToArray)
gp.CloseFigure()
e.Graphics.FillPath(New SolidBrush(_waveColor), gp)
End Using
e.Graphics.DrawString(Value & " %", _MyFont, New SolidBrush(Me.ForeColor), rect, New StringFormat With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
End Sub |
Partager