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
|
Sub Generer(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles Document.PrintPage
e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
e.Graphics.PageUnit = GraphicsUnit.Display
Dim X As Integer = e.MarginBounds.Left
Dim Y As Integer = e.MarginBounds.Top
Dim Total As Integer = Liste_Image.Items.Count - 1
Dim Image As Image
'rentre deguise en rectangle comme un renard dans le poulailler
Dim rect As Rectangle
While ((Y + rect.Height) <= e.MarginBounds.Bottom)
Image = Image.FromFile(Liste_Image.Items(Index))
'maj
rect= new Rectangle(0,0,Image.Width,Image.Height)
While (((X + rect.Width) <= e.MarginBounds.Right) And (Index < Total))
e.Graphics.DrawImage(Image, New Point(X, Y))
Index += 1
X += Image.Width
Image = Image.FromFile(Liste_Image.Items(Index))
'maj
rect= new Rectangle(0,0,Image.Width,Image.Height)
End While
Image = Image.FromFile(Liste_Image.Items(Index - 1))
'maj
rect= new Rectangle(0,0,Image.Width,Image.Height)
X = e.MarginBounds.Left
Y += Image.Height
End While
If (Index < Total) Then
e.HasMorePages = True
End If
End Sub |
Partager