Option Strict Off
Option Explicit On
Friend Class Form1
	Inherits System.Windows.Forms.Form
#Region "Windows Form Designer generated code "
	Public Sub New()
		MyBase.New()
		If m_vb6FormDefInstance Is Nothing Then
			If m_InitializingDefInstance Then
				m_vb6FormDefInstance = Me
			Else
				Try 
					'For the start-up form, the first instance created is the default instance.
					If System.Reflection.Assembly.GetExecutingAssembly.EntryPoint.DeclaringType Is Me.GetType Then
						m_vb6FormDefInstance = Me
					End If
				Catch
				End Try
			End If
		End If
		'This call is required by the Windows Form Designer.
		InitializeComponent()
	End Sub
	'Form overrides dispose to clean up the component list.
	Protected Overloads Overrides Sub Dispose(ByVal Disposing As Boolean)
		If Disposing Then
			If Not components Is Nothing Then
				components.Dispose()
			End If
		End If
		MyBase.Dispose(Disposing)
	End Sub
	'Required by the Windows Form Designer
	Private components As System.ComponentModel.IContainer
    Public WithEvents Text1 As System.Windows.Forms.TextBox
	Public WithEvents ImageKit1 As AxIMAGEKIT7Lib.AxImageKit
	Public WithEvents Command3 As System.Windows.Forms.Button
	Public WithEvents Command2 As System.Windows.Forms.Button
	Public WithEvents Command1 As System.Windows.Forms.Button
	'NOTE: The following procedure is required by the Windows Form Designer
	'It can be modified using the Windows Form Designer.
	'Do not modify it using the code editor.
	<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))
        Me.Text1 = New System.Windows.Forms.TextBox
        Me.ImageKit1 = New AxIMAGEKIT7Lib.AxImageKit
        Me.Command3 = New System.Windows.Forms.Button
        Me.Command2 = New System.Windows.Forms.Button
        Me.Command1 = New System.Windows.Forms.Button
        CType(Me.ImageKit1, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'Text1
        '
        Me.Text1.AcceptsReturn = True
        Me.Text1.AutoSize = False
        Me.Text1.BackColor = System.Drawing.Color.FromArgb(CType(255, Byte), CType(255, Byte), CType(192, Byte))
        Me.Text1.Cursor = System.Windows.Forms.Cursors.IBeam
        Me.Text1.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Text1.ForeColor = System.Drawing.Color.FromArgb(CType(192, Byte), CType(64, Byte), CType(0, Byte))
        Me.Text1.Location = New System.Drawing.Point(8, 0)
        Me.Text1.MaxLength = 0
        Me.Text1.Multiline = True
        Me.Text1.Name = "Text1"
        Me.Text1.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Text1.Size = New System.Drawing.Size(537, 64)
        Me.Text1.TabIndex = 4
        Me.Text1.Text = "Many people ask how to print an image in ""actual size"". Because digital images ar" & _
        "e made up of pixels, whose size depends on the resolution of the output device, " & _
        "there is no actual size. Fortunately, digital images have a resolution property " & _
        "which, if set, tells the resolution of the input device at the time the image wa" & _
        "s created. This information can be used to output an image at the same size as t" & _
        "he original when it was captured."
        '
        'ImageKit1
        '
        Me.ImageKit1.Location = New System.Drawing.Point(8, 72)
        Me.ImageKit1.Name = "ImageKit1"
        Me.ImageKit1.OcxState = CType(resources.GetObject("ImageKit1.OcxState"), System.Windows.Forms.AxHost.State)
        Me.ImageKit1.Size = New System.Drawing.Size(449, 361)
        Me.ImageKit1.TabIndex = 3
        '
        'Command3
        '
        Me.Command3.BackColor = System.Drawing.SystemColors.Control
        Me.Command3.Cursor = System.Windows.Forms.Cursors.Default
        Me.Command3.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Command3.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Command3.Location = New System.Drawing.Point(464, 392)
        Me.Command3.Name = "Command3"
        Me.Command3.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Command3.Size = New System.Drawing.Size(81, 33)
        Me.Command3.TabIndex = 2
        Me.Command3.Text = "End"
        '
        'Command2
        '
        Me.Command2.BackColor = System.Drawing.SystemColors.Control
        Me.Command2.Cursor = System.Windows.Forms.Cursors.Default
        Me.Command2.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Command2.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Command2.Location = New System.Drawing.Point(464, 144)
        Me.Command2.Name = "Command2"
        Me.Command2.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Command2.Size = New System.Drawing.Size(81, 33)
        Me.Command2.TabIndex = 1
        Me.Command2.Text = "Print"
        '
        'Command1
        '
        Me.Command1.BackColor = System.Drawing.SystemColors.Control
        Me.Command1.Cursor = System.Windows.Forms.Cursors.Default
        Me.Command1.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Command1.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Command1.Location = New System.Drawing.Point(464, 80)
        Me.Command1.Name = "Command1"
        Me.Command1.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Command1.Size = New System.Drawing.Size(81, 33)
        Me.Command1.TabIndex = 0
        Me.Command1.Text = "Load"
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.BackColor = System.Drawing.SystemColors.Control
        Me.ClientSize = New System.Drawing.Size(548, 436)
        Me.Controls.Add(Me.Text1)
        Me.Controls.Add(Me.ImageKit1)
        Me.Controls.Add(Me.Command3)
        Me.Controls.Add(Me.Command2)
        Me.Controls.Add(Me.Command1)
        Me.Cursor = System.Windows.Forms.Cursors.Default
        Me.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Location = New System.Drawing.Point(4, 23)
        Me.Name = "Form1"
        Me.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Text = "Printing In Actual Size"
        CType(Me.ImageKit1, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub
#End Region 
#Region "Upgrade Support "
	Private Shared m_vb6FormDefInstance As Form1
	Private Shared m_InitializingDefInstance As Boolean
	Public Shared Property DefInstance() As Form1
		Get
			If m_vb6FormDefInstance Is Nothing OrElse m_vb6FormDefInstance.IsDisposed Then
				m_InitializingDefInstance = True
				m_vb6FormDefInstance = New Form1()
				m_InitializingDefInstance = False
			End If
			DefInstance = m_vb6FormDefInstance
		End Get
		Set
			m_vb6FormDefInstance = Value
		End Set
	End Property
#End Region 
	
	Private Sub Command1_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command1.Click
		
		'displays the 'Open File' dialog and allows you to select an image to load...
		If ImageKit1.File.OpenFileDialog = False Then
			Exit Sub
		End If
		
		'loads the image...
		ImageKit1.File.LoadFile(IMAGEKIT7Lib.LoadFileConstants.ikLoad)
		
		'displays the image in scale display mode...
		ImageKit1.Display(IMAGEKIT7Lib.DispModeConstants.ikScale)
		
	End Sub
	
	Private Sub Command2_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command2.Click
        Dim Ret As Boolean
		Dim ActualHeight As Integer
		Dim ActualWidth As Integer
        Dim intLeft As Integer
        Dim intTop As Integer
        Dim intRight As Integer
        Dim intBottom As Integer

        'Get the image's resolution...
        ImageKit1.GetDpi()

        If ImageKit1.Xdpi = 0 Or ImageKit1.Ydpi = 0 Then
            MsgBox("This image does not have a value set in its resolution property")
            Exit Sub
        End If

        'Get the image's information...
        ImageKit1.GetImageType()

        'Calculate the "actual size" of the image in inches...
        ActualHeight = ImageKit1.ImageHeight / ImageKit1.Xdpi
        ActualWidth = ImageKit1.ImageWidth / ImageKit1.Ydpi

        'convert this to 0.1 millimeters which is the unit size
        'that the print control uses....
        ActualHeight = ActualHeight * 254
        ActualWidth = ActualWidth * 254

        'calculate the left, top, right and bottom parameters
        'for the ImageOut method. I want the image to be centered in
        ' the printed page and have a maximum size of
        'left=100, top=100, right=1950, bottom=2600
        If ActualHeight > 2500 Then
            intTop = 100
            intBottom = 2600
        Else
            intTop = 1250 - (ActualHeight / 2)
            intBottom = 1250 + (ActualHeight / 2)
        End If

        If ActualWidth > 1850 Then
            intLeft = 100
            intRight = 1950
        Else
            intLeft = 925 - (ActualWidth / 2)
            intRight = 925 + (ActualWidth / 2)
        End If

        'display the "Print" dialog...
        Ret = ImageKit1.PrintDraw.PrintDialog()

        ' Print the displayed image in the center of the paper (portrait orientation)
        Ret = ImageKit1.PrintDraw.PrintStartDoc
        Ret = ImageKit1.PrintDraw.PrintStartPage
        If ImageKit1.ImageHandle <> 0 Then
            Ret = ImageKit1.PrintDraw.ImageOut(ImageKit1.PrintDraw.hDC, ImageKit1.ImageHandle, intLeft, intTop, intRight, intBottom, True, False, 1)
        End If
        ImageKit1.PrintDraw.PrintEndPage()
        ImageKit1.PrintDraw.PrintEndDoc()
	End Sub
	
	Private Sub Command3_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command3.Click
		Me.Close()
	End Sub

End Class