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
| Private Sub Panel1_DragDrop(sender As Object, e As System.Windows.Forms.DragEventArgs) Handles Panel1.DragDrop
If e.Data.GetDataPresent(DataFormats.Bitmap) Then
If e.Data.GetData(DataFormats.Bitmap).ToString = My.Resources.light.ToString Then
TextBox1.Text = e.Data.GetData(DataFormats.Bitmap).ToString()
Dim Pb As New HmiObjButton
Pb.Image = e.Data.GetData(DataFormats.Bitmap)
Pb.Name = "Pb" & GetObjQuantityInConfigurationFile(My.Settings.ConfigurationFilePath, "HmiObject")
Pb.Size = New Point(50, 50)
Pb.SizeMode = PictureBoxSizeMode.Zoom
Pb.Location = New Point(Panel1.PointToClient(Cursor.Position).X - (Pb.Width / 2), Panel1.PointToClient(Cursor.Position).Y - (Pb.Height / 2))
Pb.EventValue = 1
Pb.Tag = TextBox1.Text
Pb.BackColor = Color.Transparent
AddHandler Pb.Click, AddressOf PbClick
AddHandler Pb.MouseDown, AddressOf PbMouseDown
AddHandler Pb.MouseMove, AddressOf PbMouseMove
AddHandler Pb.MouseUp, AddressOf PbMouseUp
Me.Panel1.Controls.Add(Pb)
AddElementInConfigurationFile(My.Settings.ConfigurationFilePath, Pb.Name, New Size(50, 50), New Point(Panel1.PointToClient(Cursor.Position).X - (Pb.Width / 2), Panel1.PointToClient(Cursor.Position).Y - (Pb.Height / 2)))
ElseIf e.Data.GetData(DataFormats.Bitmap).ToString = My.Resources.switch.ToString Then
Dim Pb As New HmiObjButton
Pb.Image = e.Data.GetData(DataFormats.Bitmap)
Pb.Name = "Pb" & GetObjQuantityInConfigurationFile(My.Settings.ConfigurationFilePath, "HmiObject")
Pb.Size = New Point(50, 50)
Pb.SizeMode = PictureBoxSizeMode.Zoom
Pb.Location = New Point(Panel1.PointToClient(Cursor.Position).X - (Pb.Width / 2), Panel1.PointToClient(Cursor.Position).Y - (Pb.Height / 2))
Pb.EventValue = 1
Pb.Tag = TextBox1.Text
Pb.BackColor = Color.Transparent
AddHandler Pb.Click, AddressOf PbClick
AddHandler Pb.MouseDown, AddressOf PbMouseDown
AddHandler Pb.MouseMove, AddressOf PbMouseMove
AddHandler Pb.MouseUp, AddressOf PbMouseUp
Me.Panel1.Controls.Add(Pb)
AddElementInConfigurationFile(My.Settings.ConfigurationFilePath, Pb.Name, New Size(50, 50), New Point(Panel1.PointToClient(Cursor.Position).X - (Pb.Width / 2), Panel1.PointToClient(Cursor.Position).Y - (Pb.Height / 2)))
End If
End If
End Sub |
Partager