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 35 36 37 38
|
Public Class Form2
Private startPoint As Point = Point.Empty
Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
startPoint = e.Location
End Sub
Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
Me.PictureBox1.Invalidate()
End Sub
Private Sub PictureBox1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
Dim pt As Point = Me.PictureBox1.PointToClient(Control.MousePosition)
Dim rect As New Rectangle(pt.X, pt.Y, 50, 50) ' rectangle englobant de ton Ellipse ou Cercle
e.Graphics.DrawEllipse(Pens.Yellow, rect) 'dessine ton Ellipse ou Cercle
e.Graphics.DrawRectangle(Pens.Red, rect) 'dessine son rectangle englobant
Dim centerEllipse As New Point(pt.X + 25, pt.Y + 25) 'center de ton Ellipse ou Cercle
'le rectangle englobant de ton centre sous forme d'Ellipse
Dim rectCenter As New Rectangle(centerEllipse.X - 5, centerEllipse.Y - 5, 2 * 5, 2 * 5)
'crayon pointillé
Dim penLine As New Pen(Brushes.Magenta, 1.0)
penLine.DashStyle = Drawing2D.DashStyle.Dash
'dessine le centre du cercle sous forme d'ellipse
e.Graphics.DrawEllipse(penLine, rectCenter)
'dessine la ligne "traceuse"
e.Graphics.DrawLine(penLine, startPoint, centerEllipse)
End Sub
End Class |
Partager