Bonjour
J'utilise un form pour afficher les vignettes d'un répertoire
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
Imports System.IO
Imports System.Drawing.Imaging
Imports System.Text
 
 
Public Class PhotoActeurs
    Private _ImageArrayList As ArrayList
    Private ipath As String = "c:\PhotoActeur"
 
    Private Sub PhotoActeurs_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If Not BackgroundWorker1.IsBusy Then
            Me._ImageArrayList = New ArrayList()
            Me.BackgroundWorker1.RunWorkerAsync()
        End If
    End Sub
    Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
        Dim PictureFiles() As String = Directory.GetFiles(ipath, "B*.*", SearchOption.TopDirectoryOnly)
        Dim imageCount As Integer = 0
 
        For Each f In PictureFiles
            If isCorrectMIMEType(f, Imaging.ImageFormat.Jpeg) Then
                _ImageArrayList.Add(f)
            End If
        Next
        If Not _ImageArrayList.Count = 0 Then
            imageCount = _ImageArrayList.Count
            Dim icount As Integer = 0
            For Each f In _ImageArrayList
                icount += 1
                Dim items() As String = New String(4) {}
                Dim img As Image = Image.FromFile(f)
                Dim txtActeur As String = Microsoft.VisualBasic.Mid(f, 16)
                Dim LongueurActeur As Integer
                LongueurActeur = Len(txtActeur)
                f = Microsoft.VisualBasic.Left(txtActeur, LongueurActeur - 4)
                items(0) = f
                Dim w As Double = img.Width / 5
                Dim h As Double = img.Height / 5
                Dim lvi As New ListViewItem(items)
                Dim thumbnail As Image = img.GetThumbnailImage(w, h, Nothing, IntPtr.Zero)
                Dim progressPercent As Integer = icount / imageCount * 100
                Dim objList As Object = New Object() {lvi, thumbnail, progressPercent}
                If Me.InvokeRequired Then
                    Me.Invoke(New UpdateListViewSubItemDelegate(AddressOf Me.updateprogress), objList)
                End If
            Next
        End If
    End Sub
    Private Delegate Sub UpdateListViewSubItemDelegate(ByVal listObj As Object)
    Private Sub updateprogress(ByVal listObj As Object)
        Try
            Dim lvi As ListViewItem = TryCast(listObj(0), ListViewItem)
            Dim Img As Image = TryCast(listObj(1), Image)
            If Not Img Is Nothing Then
                Me.ImgLst.Images.Add(Img)
                lvi.ImageIndex = Me.ImgLst.Images.Count - 1
            End If
            Me.LstvItem.Items.AddRange(New ListViewItem() {lvi})
            If Not listObj(2) > 100 Then
                ProgressBar1.Value = listObj(2)
            End If
        Catch ex As Exception
        End Try
    End Sub
    Private Sub BackgroundWorker1_RunWorkerCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BackgroundWorker1.RunWorkerCompleted
        MsgBox("Chargement terminé !", MsgBoxStyle.Information, "Collection de DVD")
        ProgressBar1.Visible = False
    End Sub
 
End Class
Je désire en cliquant sur une vignette afficher la photo en grand dans une picturebox se trouvant sur le même formulaire
Pouvez-vous m'aider ?
merci