|
PictureBox + VScrollBar + HScrollBarを使って
そこにプレビューイメージを表示してしまえばいろいろ可能だと思います。
その分PrintPreviewControlに実装されている機能の実装が必要になりますが。
簡易的に表示する部分のみです。
Private pics() As Image = Nothing
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim conbak = PrintDocument1.PrintController
Dim con as New PreviewPrintController
PrintDocument1.PrintController = con
PrintDocument1.Print()
PrintDocument1.PrintController = conbak
pics = (From pginf In con.GetPreviewPageInfo Select pginf.Image).ToArray
PictureBox1.Refresh()
End Sub
Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
e.Graphics.Clear(Color.DimGray)
If pics Is Nothing Then Exit Sub
e.Graphics.FillRectangle(Brushes.White, 10, 10, e.ClipRectangle.Width - 20, e.ClipRectangle.Height - 20)
Dim destrect = New Rectangle(10, 10, e.ClipRectangle.Width - 20, e.ClipRectangle.Height - 20)
e.Graphics.DrawImage(pics(0), New Rectangle(10, 10, e.ClipRectangle.Width - 20, e.ClipRectangle.Height - 20),
New Rectangle(HScrollBar1.Value, VScrollBar1.Value, destrect.Width, destrect.Height), GraphicsUnit.Pixel)
e.Graphics.DrawRectangle(Pens.Black, 10, 10, e.ClipRectangle.Width - 20, e.ClipRectangle.Height - 20)
End Sub
Private Sub VScrollBar1_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles VScrollBar1.ValueChanged
PictureBox1.Refresh()
End Sub
Private Sub HScrollBar1_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles HScrollBar1.ValueChanged
PictureBox1.Refresh()
End Sub
|