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 39 40 41 42 43 44 45 46 47 48 49
| Imports System.Drawing
Public Class controller
Inherits System.Windows.Forms.Form
Private TextMove As Boolean
Dim MonRect1 As New Rectangle(0, 0, 0, 0)
Dim GestGraph As Graphics
Private Sub TextBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TextBox1.MouseDown
TextMove = True
Me.TextBox1.Hide()
MonRect1.Size = TextBox1.Size
MonRect1.Location = Me.PointToClient(Control.MousePosition)
GestGraph = Me.CreateGraphics
End Sub
Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove, TextBox1.MouseMove
Dim pinceau As New SolidBrush(TextBox1.BackColor)
Dim stylo As New Pen(Color.Black, 1)
If TextMove AndAlso e.Button = Windows.Forms.MouseButtons.Left Then
GestGraph.Clear(Me.BackColor)
MonRect1.Location = Me.PointToClient(Control.MousePosition)
GestGraph.DrawRectangle(stylo, MonRect1)
GestGraph.FillRectangle(pinceau, MonRect1)
x_l.Text = MonRect1.Location.X
y_l.Text = MonRect1.Location.Y
End If
End Sub
Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseUp, TextBox1.MouseUp
If TextMove Then
If MonRect1.IntersectsWith(New Rectangle(image_pb.Location, image_pb.Size)) Then
Me.TextBox1.Location = Me.PointToClient(Control.MousePosition)
Else
MsgBox("Restez sur l'image!!")
End If
TextMove = False
GestGraph.Clear(Me.BackColor)
Me.TextBox1.Show()
GestGraph.Dispose()
End If
End Sub |
Partager