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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
| Public Class Form1
Dim MouseIsDown As Boolean = False
Dim CursorImage As Image
Dim isDragging As Boolean = False
Dim CurrentX As Integer, CurrentY As Integer
Dim CaseEch(64) As ButtonBase
Dim aaa As String
Dim Pieces As String
Dim LocationX(64) As Integer
Dim LocationY(64) As Integer
Private Property mypic As Point
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
PictureBox1.AllowDrop = True
PictureBox2.AllowDrop = True
PictureBox3.AllowDrop = True
PictureBox4.AllowDrop = True
PictureBox5.AllowDrop = True
PictureBox6.AllowDrop = True
PictureBox7.AllowDrop = True
PictureBox8.AllowDrop = True
PictureBox9.AllowDrop = True
Public Sub RB_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles RB.MouseDown
MouseIsDown = True
End Sub
Public Sub RB_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles RB.MouseMove
If MouseIsDown Then
If RB.Image Is Nothing Then Exit Sub
RB.DoDragDrop(RB.Image, DragDropEffects.Move)
Else
MouseIsDown = False
End If
End Sub
Public Sub RB_GiveFeedback(ByVal sender As Object, _
ByVal e As System.Windows.Forms.GiveFeedbackEventArgs) Handles RB.GiveFeedback
e.UseDefaultCursors = False
Dim myPic As New Bitmap(CType(sender, PictureBox).Image)
CursorImage = myPic.GetThumbnailImage(32, 32, Nothing, IntPtr.Zero)
Cursor.Current = New Cursor(CType(CursorImage, System.Drawing.Bitmap).GetHicon())
Pieces = "RB"
End Sub
Public Sub RN_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles RN.MouseDown
MouseIsDown = True
End Sub
Public Sub RN_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles RN.MouseMove
If MouseIsDown Then
If RN.Image Is Nothing Then Exit Sub
RN.DoDragDrop(RN.Image, DragDropEffects.Move)
Else
MouseIsDown = False
End If
End Sub
Public Sub RN_GiveFeedback(ByVal sender As Object, _
ByVal e As System.Windows.Forms.GiveFeedbackEventArgs) Handles RN.GiveFeedback
e.UseDefaultCursors = False
Dim myPic As New Bitmap(CType(sender, PictureBox).Image)
CursorImage = myPic.GetThumbnailImage(32, 32, Nothing, IntPtr.Zero)
Cursor.Current = New Cursor(CType(CursorImage, System.Drawing.Bitmap).GetHicon())
Pieces = "RN"
End Sub
Public Sub PictureBox_DragDrop(ByVal sender As System.Object, _
ByVal e As System.Windows.Forms.DragEventArgs) Handles PictureBox1.DragDrop, PictureBox2.DragDrop, PictureBox3.DragDrop, PictureBox4.DragDrop, PictureBox5.DragDrop, PictureBox6.DragDrop, PictureBox7.DragDrop, PictureBox8.DragDrop
Dim clicked As PictureBox = CType(sender, PictureBox)
Tag = sender.tag
If Tag = 1 Then PictureBox1.Image = e.Data.GetData(DataFormats.Bitmap) : LocationX(Tag) = PictureBox1.Location.X : LocationY(Tag) = PictureBox1.Location.Y
If Tag = 2 Then PictureBox2.Image = e.Data.GetData(DataFormats.Bitmap) : LocationX(Tag) = PictureBox2.Location.X : LocationY(Tag) = PictureBox2.Location.Y
If Tag = 3 Then PictureBox3.Image = e.Data.GetData(DataFormats.Bitmap) : LocationX(Tag) = PictureBox3.Location.X : LocationY(Tag) = PictureBox3.Location.Y
If Tag = 4 Then PictureBox4.Image = e.Data.GetData(DataFormats.Bitmap) : LocationX(Tag) = PictureBox4.Location.X : LocationY(Tag) = PictureBox4.Location.Y
If Tag = 5 Then PictureBox5.Image = e.Data.GetData(DataFormats.Bitmap) : LocationX(Tag) = PictureBox5.Location.X : LocationY(Tag) = PictureBox5.Location.Y
If Tag = 6 Then PictureBox6.Image = e.Data.GetData(DataFormats.Bitmap) : LocationX(Tag) = PictureBox6.Location.X : LocationY(Tag) = PictureBox6.Location.Y
If Tag = 7 Then PictureBox7.Image = e.Data.GetData(DataFormats.Bitmap) : LocationX(Tag) = PictureBox7.Location.X : LocationY(Tag) = PictureBox7.Location.Y
If Tag = 8 Then PictureBox8.Image = e.Data.GetData(DataFormats.Bitmap) : LocationX(Tag) = PictureBox8.Location.X : LocationY(Tag) = PictureBox8.Location.Y
TextBox1.Text = "Tag: " + Tag.ToString + " Piece: " + Pieces + " Location X,Y : " + LocationX(Tag).ToString + " , " + LocationY(Tag).ToString
End Sub
End Class |
Partager