|
Imports System.Drawing
Imports System.Drawing.Imaging
Imports System.IO
''' <summary>
''' Class the represents the properties of a single page of the printed document
''' </summary>
''' <remarks>
''' </remarks>
Public Class EMFPage
#Region "Private properties"
Private _Header As EMFMETAHEADER
Private _Thumbnail As Image
Private _Scale As Int32 = 20
Private _Records As New Generic.List(Of EMFRecord)
Private _emfFile As Metafile
#End Region
#Region "Public interface"
''' <summary>
''' The header information for this printed page
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public ReadOnly Property Header() As EMFMETAHEADER
Get
Return _Header
End Get
End Property
''' <summary>
''' A thumbnail image of the printed page
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks>
''' The size of this thumbnail is controlled by the _Scale private constant
''' </remarks>
Public ReadOnly Property Thumbnail() As Image
Get
Return _emfFile.GetThumbnailImage(CInt(_Header.FrameRect.Width / _Scale), CInt(_Header.FrameRect.Height / _Scale), AddressOf AbortThumbnail, IntPtr.Zero)
End Get
End Property
Public ReadOnly Property Metafile As Metafile
Get
Return _emfFile
End Get
End Property
Public Property Scale As Integer
Get
Return _Scale
End Get
Set(value As Integer)
If (value < 10) Then
_Scale = 10
ElseIf (value > 200) Then
_Scale = 200
Else
_Scale = value
End If
End Set
End Property
#End Region
#Region "Public constructors"
''' <summary>
''' Creates a new EMF page record from an open file stream which is proitioned at the
''' start of the EMF record
''' </summary>
''' <param name="FileReader">The open file stream</param>
''' <remarks></remarks>
Public Sub New(ByVal FileReader As System.IO.BinaryReader)
If EMFSpoolfileReader.ApplicationTracing.TraceVerbose Then
Trace.WriteLine("New page: " & _Header.RecordCount.ToString & " EMF records")
End If
'\\ Get the EMF page header
Dim oldPos As Long = FileReader.BaseStream.Position
_Header = New EMFMETAHEADER(FileReader)
FileReader.BaseStream.Seek(oldPos, IO.SeekOrigin.Begin)
If EMFSpoolfileReader.ApplicationTracing.TraceVerbose Then
Trace.WriteLine("Generating thumbnail")
End If
_emfFile = New System.Drawing.Imaging.Metafile(FileReader.BaseStream)
FileReader.BaseStream.Seek(oldPos + _Header.Size, IO.SeekOrigin.Begin)
Dim Record As Integer
For Record = 1 To _Header.RecordCount
Dim emfRecord As New EMFRecord(FileReader)
_Records.Add(emfRecord)
If EMFSpoolfileReader.ApplicationTracing.TraceVerbose Then
Debug.WriteLine(emfRecord.Type.ToString & " :: " & emfRecord.Size - 8)
End If
FileReader.BaseStream.Seek(emfRecord.Seek + emfRecord.Size, IO.SeekOrigin.Begin)
Next
End Sub
#End Region
#Region "Private members"
Private Function AbortThumbnail() As Boolean
Return False
End Function
#End Region
End Class
#Region "EMFPages"
''' <summary>
''' A type-safe collection of <see cref="EMFPage">EMFPage</see> objects representing the
''' pages of this print job
''' </summary>
''' <remarks>
''' </remarks>
Public Class EMFPages
Inherits Generic.List(Of EMFPage)
End Class
#End Region
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.