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 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
| Imports System.Windows.Forms
Public Class Dialog3
Dim lNumI As Long
Dim lPsM As Long
Dim pPt As Point
Dim PictureBox1 As New PictureBox()
Dim ImgColl As System.Collections.ObjectModel.ReadOnlyCollection(Of String)
Private Sub AffIm(ByRef NumIm As Long)
Dim dRat As Double
ClearPicture()
Dim ISource As System.Drawing.Bitmap = New System.Drawing.Bitmap(ImgColl.ElementAt(NumIm))
dRat = ISource.Height / ISource.Width
Dim IDest As New Bitmap(CInt(PictureBox1.Width), CInt(PictureBox1.Width * dRat))
Dim GrDest As Graphics = Graphics.FromImage(IDest)
GrDest.DrawImage(ISource, 0, 0, IDest.Width + 1, IDest.Height + 1)
PictureBox1.Image = IDest
Me.AutoScrollPosition = pPt
Panel1.Location = New Size(Me.PictureBox1.Size.Width - 30, 0)
PictureBox1.Refresh()
End Sub
Private Sub Dialog3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim sDir As String = ListeFichier.sPrm
Dim i As Long = 0
pPt.X = 0
pPt.Y = 0
lNumI = 0
lPsM = 4 ' PictureBoxSizeMode.Zoom
Me.WindowState = FormWindowState.Maximized
Me.Controls.Add(PictureBox1)
Me.PictureBox1.Size = New System.Drawing.Size(10, 10)
Me.PictureBox1.SizeMode = PictureBoxSizeMode.Zoom
Me.AutoScroll = True
Panel1.Location = New Size(Me.PictureBox1.Size.Width - 30, Me.Height - 120)
PictureBox1.Size = New Size(Me.Size.Width - 40, Me.Size.Height * 2)
PictureBox1.MaximumSize = New Size(Me.Size.Width - 40, Me.Size.Height * 2)
PictureBox1.Location = New Point(5, 0)
PictureBox1.SizeMode = lPsM
PictureBox1.Refresh()
ImgColl = My.Computer.FileSystem.GetFiles(sDir, FileIO.SearchOption.SearchTopLevelOnly, "*.jpg", "*.gif", "*.png")
AffIm(lNumI)
End Sub
Private Sub Dialog3_Scroll(ByVal sender As Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles Me.Scroll
Dim lAsP As Long
lAsP = 0 - Me.AutoScrollPosition.Y
If lAsP < (Me.Size.Height / 2) Then
Panel1.Location = New Size(Me.PictureBox1.Size.Width - 30, lAsP)
Else
Panel1.Location = New Size(Me.PictureBox1.Size.Width - 30, lAsP - Panel1.Height)
End If
End Sub
Private Sub ClearPicture()
Dim img As Image = PictureBox1.Image
PictureBox1.Image = Nothing
If Not (img Is Nothing) Then
img.Dispose()
End If
End Sub
Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Me.DialogResult = System.Windows.Forms.DialogResult.OK
Me.Close()
End Sub
Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
Me.Close()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'Précédent
lNumI = lNumI - 1
If lNumI < 0 Then lNumI = ImgColl.Count - 1
AffIm(lNumI)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click 'Suivant
lNumI = lNumI + 1
If lNumI > ImgColl.Count - 1 Then lNumI = 0
AffIm(lNumI)
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
ClearPicture()
Me.Controls.Remove(PictureBox1)
Me.Controls.Add(PictureBox1)
Me.PictureBox1.Size = New Size(Me.Size.Width - 40, Me.Size.Height * 2)
Me.PictureBox1.MaximumSize = New Size(Me.Size.Width - 40, Me.Size.Height * 2)
PictureBox1.Location = New Point(5, 0)
lPsM = lPsM + 1
If lPsM > 4 Then lPsM = 0
PictureBox1.SizeMode = lPsM
AffIm(lNumI)
End Sub
End Class |
Partager