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
|
Public Class Form1
Private MesImages As New List(Of MonImage)
Private ListImages As List(Of String)
Private ChibiBmp As New Bitmap(600, 600)
Dim item As ListViewItem
Private Sub btnLoadImages_Click(sender As System.Object, e As System.EventArgs) Handles btnLoadImages.Click
ListBox1.SelectionMode = SelectionMode.One
ListImages = GetImages()
If ListImages.Count > 0 Then
For Each fileName In ListImages
ListBox1.Items.Add(fileName)
MesImages.Add(New MonImage(fileName, Image.FromFile(fileName)))
Next
End If
End Sub
Private Sub ListBox1_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
If ListBox1.SelectedIndex < 0 Then Return
Dim ndx As Integer = ListBox1.SelectedIndex
selectedMonImage = MesImages.Item(ListBox1.SelectedIndex)
End Sub
Private selectedMonImage As MonImage
Private positionImage As Point
Private Sub PictureBox1_MouseClick(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseClick
If selectedMonImage IsNot Nothing Then
PictureBox1.Cursor = Cursors.Cross
positionImage = e.Location
Using grChibi As Graphics = Graphics.FromImage(ChibiBmp)
grChibi.DrawImage(selectedMonImage.Image, positionImage)
End Using
PictureBox1.Image = ChibiBmp
selectedMonImage = Nothing
End If
End Sub
Private Function GetImages() As List(Of String)
OpenFileDialog1.Multiselect = True
OpenFileDialog1.Filter = "images(*.png)|*.png"
Dim l() As String = New String() {}
If OpenFileDialog1.ShowDialog Then
l = OpenFileDialog1.FileNames
End If
Return l.ToList()
End Function
End Class |
Partager