I am about to create a application to put many images to a canvas area. I want to put the images there and move them around, by dragging with the mouse.
But I struggle with the implementation of a specific frame around the images where I can resize them by clicking the four corners.
Here is the basic code, only for placing the images and moving them around. Now I want to get the function of resize the images with a four corner frame around each image. Any idea is much appreciated.
Imports System.IO
Imports System.Drawing.Printing
Imports CtlResize
Public Class Form1
Dim WithEvents pbxNewPicturebox As New PictureBox
Dim ArrayOfPicturebox(10) As PictureBox
Dim index As Integer
Private Sub DynamicMouseMove(ByVal sender As Object, ByVal e As MouseEventArgs)
Dim pbxPicturebox As Picturebox = DirectCast(sender, Picturebox)
Static mousePos As Point
If e.Button = Windows.Forms.MouseButtons.None Then
mousePos.X = e.X
mousePos.Y = e.Y
Else
pbxPicturebox.Left = pbxPicturebox.Left + (e.X - mousePos.X)
pbxPicturebox.Top = pbxPicturebox.Top + (e.Y - mousePos.Y)
End If
End Sub
Private Sub ToolStripButton1_Click(sender As Object, e As EventArgs) Handles ToolStripButton1.Click
OpenFileDialog1.ShowDialog()
If OpenFileDialog1.FileName = "" Then Exit Sub
ArrayOfPicturebox(index) = New Picturebox
Controls.Add(ArrayOfPicturebox(index))
ArrayOfPicturebox(index).Parent = PictureBox1
ArrayOfPicturebox(index).Image = Image.FromFile(OpenFileDialog1.FileName)
ArrayOfPicturebox(index).Visible = True
ArrayOfPicturebox(index).SizeMode = PictureBoxSizeMode.AutoSize
ArrayOfPicturebox(index).Refresh()
ArrayOfPicturebox(index).Name = CStr(index)
AddHandler ArrayOfPicturebox(index).MouseMove, AddressOf DynamicMouseMove
index = index + 1
End Sub
End Class
Aucun commentaire:
Enregistrer un commentaire