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 32 33 34
| Public Class Point_Graphique
Private w As Single = 5
Private h As Single = 5
Private Rect As Rectangle
Public Property Position As Point
Public Property ID As String = String.Empty
Public Property PosCursor As New Point(0, 0)
Public Property Information As String = "Information"
Private fnt As New Font("Arial", 12.0F)
Private br As New SolidBrush(Color.Red)
Public Sub New()
Rect = New Rectangle(0, 0, 5, 5)
End Sub
Public Sub New(ByVal pt As Point, ByVal pid As String)
Me.New()
Position = pt
ID = pid
Rect = New Rectangle(pt.X - w / 2, pt.Y - h / 2, w, h)
End Sub
Public Function IsHovered() As Boolean
If Rect.Contains(PosCursor) Then
Return True
End If
Return False
End Function
Public Sub Draw(ByVal gr As Graphics)
gr.DrawEllipse(Pens.Blue, Rect)
If Me.IsHovered() Then
gr.DrawString(ID, fnt, br, Me.Position)
End If
End Sub
End Class |
Partager