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 Command1 As System.Windows.Forms.Button
	Public WithEvents Command2 As System.Windows.Forms.Button
	Public WithEvents Command3 As System.Windows.Forms.Button
	Public WithEvents Command4 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.Command1 = New System.Windows.Forms.Button
        Me.Command2 = New System.Windows.Forms.Button
        Me.Command3 = New System.Windows.Forms.Button
        Me.Command4 = 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(0, 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(497, 80)
        Me.Text1.TabIndex = 5
        Me.Text1.Text = "This sample illustrates a number of PrintDraw methods relating to drawing shapes " & _
        "and text. The shapes and text are drawn to the Hdc (the screen or the printer) a" & _
        "nd not to the ImageHdc (the image data itself). For more information about drawi" & _
        "ng to the image data, please refer to the image editing samples. Also in this sa" & _
        "mple, the SavePrintInfo method is used to display the ""Print Setup"" dialog and p" & _
        "rinter settings are saved to the printer information file."
        '
        'ImageKit1
        '
        Me.ImageKit1.Location = New System.Drawing.Point(8, 88)
        Me.ImageKit1.Name = "ImageKit1"
        Me.ImageKit1.OcxState = CType(resources.GetObject("ImageKit1.OcxState"), System.Windows.Forms.AxHost.State)
        Me.ImageKit1.Size = New System.Drawing.Size(377, 321)
        Me.ImageKit1.TabIndex = 4
        '
        '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(392, 88)
        Me.Command1.Name = "Command1"
        Me.Command1.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Command1.Size = New System.Drawing.Size(113, 65)
        Me.Command1.TabIndex = 0
        Me.Command1.Text = "Load Image and Draw Objects to Hdc"
        '
        '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(392, 176)
        Me.Command2.Name = "Command2"
        Me.Command2.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Command2.Size = New System.Drawing.Size(113, 65)
        Me.Command2.TabIndex = 1
        Me.Command2.Text = "Set Print Properties"
        '
        '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(392, 264)
        Me.Command3.Name = "Command3"
        Me.Command3.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Command3.Size = New System.Drawing.Size(113, 65)
        Me.Command3.TabIndex = 2
        Me.Command3.Text = "Print"
        '
        'Command4
        '
        Me.Command4.BackColor = System.Drawing.SystemColors.Control
        Me.Command4.Cursor = System.Windows.Forms.Cursors.Default
        Me.Command4.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Command4.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Command4.Location = New System.Drawing.Point(392, 352)
        Me.Command4.Name = "Command4"
        Me.Command4.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Command4.Size = New System.Drawing.Size(113, 57)
        Me.Command4.TabIndex = 3
        Me.Command4.Text = "End"
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.BackColor = System.Drawing.SystemColors.Control
        Me.ClientSize = New System.Drawing.Size(510, 415)
        Me.Controls.Add(Me.Text1)
        Me.Controls.Add(Me.ImageKit1)
        Me.Controls.Add(Me.Command1)
        Me.Controls.Add(Me.Command2)
        Me.Controls.Add(Me.Command3)
        Me.Controls.Add(Me.Command4)
        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.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "Print"
        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
		
		'display the Open file dialog
		If ImageKit1.File.OpenFileDialog = False Then
			Exit Sub
		End If
		
		'load image
		ImageKit1.File.LoadFile(IMAGEKIT7Lib.LoadFileConstants.ikLoad)
		
		'display image
        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
		
		'create a print file
        ImageKit1.PrintDraw.PrintFileName = Application.StartupPath & "\IkPrn.Ik"
		Ret = ImageKit1.PrintDraw.SavePrinterInfo()
	End Sub
	
	Private Sub Command3_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command3.Click
		Dim Ret As Boolean
		Dim Ret2 As Boolean
		
		'create device context from print file
        ImageKit1.PrintDraw.PrintFileName = Application.StartupPath & "\IkPrn.Ik"
		Ret = ImageKit1.PrintDraw.PrintCreateDC(IMAGEKIT7Lib.PrintModeConstants.ikPrintFileName)
		
		'if print file doesn't exist then set some print properties
		If Ret = False Then
			ImageKit1.PrintDraw.Copies = 1
			ImageKit1.PrintDraw.Options = &H4s Or &H8s Or &H100000
			ImageKit1.PrintDraw.PrintToFile = False
			Ret2 = ImageKit1.PrintDraw.PrintDialog()
			If Ret2 = False Then Exit Sub
		End If
		ImageKit1.PrintDraw.DocName = "Print Out"
		
		'start printing document and page
		Ret = ImageKit1.PrintDraw.PrintStartDoc()
		Ret = ImageKit1.PrintDraw.PrintStartPage()
		
		'call the Disp function (see below)
		Disp(False, ImageKit1.PrintDraw.hDC)
		
		'once the Disp function has executed, end printing page and document
		Ret = ImageKit1.PrintDraw.PrintEndPage()
		Ret = ImageKit1.PrintDraw.PrintEndDoc()
		
		'delete the device context
		ImageKit1.PrintDraw.PrintDeleteDC()
	End Sub
	
	Private Sub Command4_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command4.Click
		Me.Close()
	End Sub
	
    Sub Disp(ByRef Screen As Boolean, ByRef hDC As Integer)
        Dim Ret As Boolean
        Dim r As Short
        Dim g As Short
        Dim b As Short
        Dim x(3) As Integer
        Dim y(3) As Integer
        Dim wd As Integer
        Dim ht As Integer
        Dim scl As Short
        Dim ImgHandle As Integer
        Dim DeviceMode As IMAGEKIT7Lib.OutPutDeviceModeConstants

        If Screen = True Then
            scl = 1
            DeviceMode = IMAGEKIT7Lib.OutPutDeviceModeConstants.ikScreen
        Else
            scl = 5
            DeviceMode = IMAGEKIT7Lib.OutPutDeviceModeConstants.ikPrinter
        End If

        ' ImageOut
        If DeviceMode = IMAGEKIT7Lib.OutPutDeviceModeConstants.ikPrinter Then
            Ret = ImageKit1.PrintDraw.ImageOut(hDC, ImageKit1.ImageHandle, 100, 100, 1000, 1000, True, True, DeviceMode)
        End If

        'DrawText
        ImageKit1.PrintDraw.ClearProperty()
        ImageKit1.PrintDraw.FontName = "arial"
        ImageKit1.PrintDraw.FontSize = 20
        ImageKit1.PrintDraw.CharAngle = 180
        ImageKit1.PrintDraw.Direction = 2
        ImageKit1.PrintDraw.HCentering = 1
        ImageKit1.PrintDraw.VCentering = 1
        ImageKit1.PrintDraw.FontBold = True
        ImageKit1.PrintDraw.FontItalic = True
        ImageKit1.PrintDraw.Transparent = True
        ImageKit1.PrintDraw.Text = "ImageKit"
        Ret = ImageKit1.PrintDraw.DrawText(hDC, 10 * scl, 10 * scl, 300 * scl, 200 * scl, True, True, DeviceMode)

        ImageKit1.PrintDraw.CharAngle = 0
        Ret = ImageKit1.PrintDraw.DrawText(hDC, 50 * scl, 50 * scl, 300 * scl, 200 * scl, True, True, DeviceMode)

        'Line
        ImageKit1.PrintDraw.ClearProperty()
        ImageKit1.PrintDraw.PenWidth = 1
        ImageKit1.PrintDraw.PenStyle = IMAGEKIT7Lib.PenStyleConstants.ikPenSolid
        Ret = ImageKit1.PrintDraw.Line(hDC, 10 * scl, 10 * scl, 145 * scl, 100 * scl, DeviceMode)

        'Rectangle
        ImageKit1.PrintDraw.ClearProperty()
        ImageKit1.PrintDraw.PenWidth = 1
        ImageKit1.PrintDraw.PenStyle = IMAGEKIT7Lib.PenStyleConstants.ikPenSolid
        Ret = ImageKit1.PrintDraw.Rectangle(hDC, 10 * scl, 10 * scl, 300 * scl, 200 * scl, DeviceMode)

        'Rectangle(fill)
        ImageKit1.PrintDraw.ClearProperty()
        ImageKit1.PrintDraw.PenWidth = 1
        ImageKit1.PrintDraw.PenStyle = IMAGEKIT7Lib.PenStyleConstants.ikPenSolid
        ImageKit1.PrintDraw.BrushStyle = IMAGEKIT7Lib.BrushStyleConstants.ikBrushSolid
        ImageKit1.PrintDraw.BrushColor = RGB(255, 0, 0)
        Ret = ImageKit1.PrintDraw.Rectangle(hDC, 300 * scl, 200 * scl, 350 * scl, 250 * scl, DeviceMode)

        'Ellipse
        ImageKit1.PrintDraw.ClearProperty()
        ImageKit1.PrintDraw.PenWidth = 2
        ImageKit1.PrintDraw.PenStyle = IMAGEKIT7Lib.PenStyleConstants.ikPenSolid
        Ret = ImageKit1.PrintDraw.Ellipse(hDC, 10 * scl, 10 * scl, 300 * scl, 200 * scl, DeviceMode)

        'SetPixel
        ImageKit1.PrintDraw.ClearProperty()
        Ret = ImageKit1.PrintDraw.SetPixel(hDC, 360 * scl, 260 * scl, RGB(255, 128, 64), DeviceMode)

        'GetPixel
        ImageKit1.PrintDraw.ClearProperty()
        Ret = ImageKit1.PrintDraw.GetPixel(hDC, 360 * scl, 260 * scl, r, g, b, DeviceMode)

        'Paint
        ImageKit1.PrintDraw.ClearProperty()
        Ret = ImageKit1.PrintDraw.Paint(hDC, 29 * scl, 198 * scl, RGB(255, 255, 255), RGB(255, 128, 64), IMAGEKIT7Lib.PaintModeConstants.ikSurface, DeviceMode)

        'Polygon
        ImageKit1.PrintDraw.ClearProperty()
        ImageKit1.PrintDraw.PenWidth = 1
        ImageKit1.PrintDraw.PenStyle = IMAGEKIT7Lib.PenStyleConstants.ikPenSolid
        ImageKit1.PrintDraw.PenColor = RGB(255, 0, 255)
        x(1) = 10 * scl : y(1) = 210 * scl
        x(2) = 30 * scl : y(2) = 220 * scl
        x(3) = 20 * scl : y(3) = 230 * scl
        Ret = ImageKit1.PrintDraw.Polygon(hDC, x(1), y(1), 3, DeviceMode)

        'Polyline
        ImageKit1.PrintDraw.ClearProperty()
        ImageKit1.PrintDraw.PenWidth = 1
        ImageKit1.PrintDraw.PenStyle = IMAGEKIT7Lib.PenStyleConstants.ikPenSolid
        ImageKit1.PrintDraw.PenColor = RGB(255, 0, 0)
        x(1) = 110 * scl : y(1) = 210 * scl
        x(2) = 130 * scl : y(2) = 220 * scl
        x(3) = 120 * scl : y(3) = 230 * scl
        Ret = ImageKit1.PrintDraw.Polyline(hDC, x(1), y(1), 3, DeviceMode)

        'TextOut
        ImageKit1.PrintDraw.ClearProperty()
        ImageKit1.PrintDraw.FontName = "Times New Roman"
        ImageKit1.PrintDraw.FontSize = 20
        ImageKit1.PrintDraw.HCentering = 1
        ImageKit1.PrintDraw.VCentering = 1
        ImageKit1.PrintDraw.CharExtra = 10 * scl
        ImageKit1.PrintDraw.FontItalic = True
        ImageKit1.PrintDraw.Transparent = True
        ImageKit1.PrintDraw.Text = "NEWTONE Inc"
        Ret = ImageKit1.PrintDraw.TextOut(hDC, 10, 250, DeviceMode)
        ImageKit1.PrintDraw.CharExtra = 0
        Ret = ImageKit1.PrintDraw.TextOut(hDC, 10, 270, DeviceMode)

        'Arc
        ImageKit1.PrintDraw.ClearProperty()
        ImageKit1.PrintDraw.PenWidth = 1
        ImageKit1.PrintDraw.PenStyle = IMAGEKIT7Lib.PenStyleConstants.ikPenSolid
        ImageKit1.PrintDraw.PenColor = RGB(0, 255, 0)
        Ret = ImageKit1.PrintDraw.Arc(hDC, 10 * scl, 300 * scl, 100 * scl, 350 * scl, 100 * scl, 320 * scl, 10 * scl, 320 * scl, DeviceMode)

        'Pie
        ImageKit1.PrintDraw.ClearProperty()
        ImageKit1.PrintDraw.PenWidth = 1
        ImageKit1.PrintDraw.PenStyle = IMAGEKIT7Lib.PenStyleConstants.ikPenSolid
        ImageKit1.PrintDraw.PenColor = RGB(0, 255, 255)
        Ret = ImageKit1.PrintDraw.Pie(hDC, 110 * scl, 300 * scl, 200 * scl, 350 * scl, 200 * scl, 320 * scl, 110 * scl, 320 * scl, DeviceMode)

        'Chord
        ImageKit1.PrintDraw.ClearProperty()
        ImageKit1.PrintDraw.PenWidth = 1
        ImageKit1.PrintDraw.PenStyle = IMAGEKIT7Lib.PenStyleConstants.ikPenSolid
        ImageKit1.PrintDraw.PenColor = RGB(64, 128, 255)
        Ret = ImageKit1.PrintDraw.Chord(hDC, 10 * scl, 350 * scl, 100 * scl, 400 * scl, 100 * scl, 370 * scl, 10 * scl, 370 * scl, DeviceMode)

        'RoundRect
        ImageKit1.PrintDraw.ClearProperty()
        ImageKit1.PrintDraw.PenWidth = 1
        ImageKit1.PrintDraw.PenStyle = IMAGEKIT7Lib.PenStyleConstants.ikPenSolid
        ImageKit1.PrintDraw.PenColor = RGB(64, 128, 255)
        Ret = ImageKit1.PrintDraw.RoundRect(hDC, 110 * scl, 350 * scl, 200 * scl, 400 * scl, 30 * scl, 30 * scl, DeviceMode)

        'FillRect
        ImageKit1.PrintDraw.ClearProperty()
        ImageKit1.PrintDraw.PenWidth = 1
        ImageKit1.PrintDraw.PenStyle = IMAGEKIT7Lib.PenStyleConstants.ikPenSolid
        ImageKit1.PrintDraw.BrushStyle = IMAGEKIT7Lib.BrushStyleConstants.ikBrushSolid
        ImageKit1.PrintDraw.BrushColor = RGB(255, 0, 0)
        Ret = ImageKit1.PrintDraw.FillRect(hDC, 250 * scl, 350 * scl, 300 * scl, 400 * scl, DeviceMode)
    End Sub

    Private Sub ImageKit1_EndDispImage(ByVal sender As Object, ByVal e As AxIMAGEKIT7Lib._IImageKitEvents_EndDispImageEvent) Handles ImageKit1.EndDispImage
        Disp(True, (ImageKit1.hDC))
    End Sub
End Class