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 ImageKit3 As AxIMAGEKIT7Lib.AxImageKit
	Public WithEvents ImageKit2 As AxIMAGEKIT7Lib.AxImageKit
	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
	Public WithEvents Command5 As System.Windows.Forms.Button
	Public WithEvents Label1 As System.Windows.Forms.Label
	'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.ImageKit3 = New AxIMAGEKIT7Lib.AxImageKit
        Me.ImageKit2 = New AxIMAGEKIT7Lib.AxImageKit
        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
        Me.Command5 = New System.Windows.Forms.Button
        Me.Label1 = New System.Windows.Forms.Label
        CType(Me.ImageKit3, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.ImageKit2, System.ComponentModel.ISupportInitialize).BeginInit()
        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(0, 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(561, 49)
        Me.Text1.TabIndex = 9
        Me.Text1.Text = "The Panorama method provides an easy way to attach two images into a panorama vie" & _
        "w. First load two images, one in each of the ImageKit Controls. Then set two att" & _
        "achment points on the left image and two attachment points on the right image. C" & _
        "lick the Execute Button."
        '
        'ImageKit3
        '
        Me.ImageKit3.Location = New System.Drawing.Point(16, 288)
        Me.ImageKit3.Name = "ImageKit3"
        Me.ImageKit3.OcxState = CType(resources.GetObject("ImageKit3.OcxState"), System.Windows.Forms.AxHost.State)
        Me.ImageKit3.Size = New System.Drawing.Size(433, 201)
        Me.ImageKit3.TabIndex = 8
        '
        'ImageKit2
        '
        Me.ImageKit2.Location = New System.Drawing.Point(280, 56)
        Me.ImageKit2.Name = "ImageKit2"
        Me.ImageKit2.OcxState = CType(resources.GetObject("ImageKit2.OcxState"), System.Windows.Forms.AxHost.State)
        Me.ImageKit2.Size = New System.Drawing.Size(249, 185)
        Me.ImageKit2.TabIndex = 7
        '
        'ImageKit1
        '
        Me.ImageKit1.Location = New System.Drawing.Point(16, 56)
        Me.ImageKit1.Name = "ImageKit1"
        Me.ImageKit1.OcxState = CType(resources.GetObject("ImageKit1.OcxState"), System.Windows.Forms.AxHost.State)
        Me.ImageKit1.Size = New System.Drawing.Size(249, 185)
        Me.ImageKit1.TabIndex = 6
        '
        '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(12, 248)
        Me.Command1.Name = "Command1"
        Me.Command1.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Command1.Size = New System.Drawing.Size(105, 33)
        Me.Command1.TabIndex = 0
        Me.Command1.Text = "Load Image"
        '
        '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(452, 248)
        Me.Command2.Name = "Command2"
        Me.Command2.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Command2.Size = New System.Drawing.Size(105, 33)
        Me.Command2.TabIndex = 1
        Me.Command2.Text = "Load Image"
        '
        '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, 304)
        Me.Command3.Name = "Command3"
        Me.Command3.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Command3.Size = New System.Drawing.Size(89, 41)
        Me.Command3.TabIndex = 2
        Me.Command3.Text = "Set Attachment Location"
        '
        '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(464, 360)
        Me.Command4.Name = "Command4"
        Me.Command4.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Command4.Size = New System.Drawing.Size(89, 41)
        Me.Command4.TabIndex = 3
        Me.Command4.Text = "Execute"
        '
        'Command5
        '
        Me.Command5.BackColor = System.Drawing.SystemColors.Control
        Me.Command5.Cursor = System.Windows.Forms.Cursors.Default
        Me.Command5.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Command5.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Command5.Location = New System.Drawing.Point(464, 416)
        Me.Command5.Name = "Command5"
        Me.Command5.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Command5.Size = New System.Drawing.Size(89, 41)
        Me.Command5.TabIndex = 4
        Me.Command5.Text = "End"
        '
        'Label1
        '
        Me.Label1.BackColor = System.Drawing.SystemColors.Control
        Me.Label1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
        Me.Label1.Cursor = System.Windows.Forms.Cursors.Default
        Me.Label1.Font = New System.Drawing.Font("Arial", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label1.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Label1.Location = New System.Drawing.Point(144, 256)
        Me.Label1.Name = "Label1"
        Me.Label1.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Label1.Size = New System.Drawing.Size(281, 25)
        Me.Label1.TabIndex = 5
        Me.Label1.TextAlign = System.Drawing.ContentAlignment.TopCenter
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.BackColor = System.Drawing.SystemColors.Control
        Me.ClientSize = New System.Drawing.Size(572, 496)
        Me.Controls.Add(Me.Text1)
        Me.Controls.Add(Me.ImageKit3)
        Me.Controls.Add(Me.ImageKit2)
        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.Controls.Add(Me.Command5)
        Me.Controls.Add(Me.Label1)
        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 = "Panorama"
        CType(Me.ImageKit3, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.ImageKit2, System.ComponentModel.ISupportInitialize).EndInit()
        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 
	Dim xL1 As Integer ' left image start point
	Dim yL1 As Integer
	Dim xL2 As Integer ' left image end point
	Dim yL2 As Integer
	Dim xR1 As Integer ' right image start point
	Dim yR1 As Integer
	Dim xR2 As Integer ' right image end point
	Dim yR2 As Integer
	Dim PointNum As Short
	
	
	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)
		
		'check to see if it is a raster image
		If ImageKit1.ImageKind <> IMAGEKIT7Lib.ImageKindConstants.ikRasterImage Then
			ImageKit1.FreeMemory(ImageKit1.ImageHandle)
		End If
		
		' 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
		
		'display the Open file dialog
		If ImageKit2.File.OpenFileDialog = False Then
			Exit Sub
		End If
		
		' load image
		ImageKit2.File.LoadFile(IMAGEKIT7Lib.LoadFileConstants.ikLoad)
		
		'check to see if it is a raster image
		If ImageKit2.ImageKind <> IMAGEKIT7Lib.ImageKindConstants.ikRasterImage Then
			ImageKit2.FreeMemory(ImageKit2.ImageHandle)
		End If
		
		' display image
		ImageKit2.Display(IMAGEKIT7Lib.DispModeConstants.ikScale)
	End Sub
	
	Private Sub Command3_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command3.Click
		ImageKit1.CtlRefresh()
        ImageKit2.CtlRefresh()
		xL1 = 0 : yL1 = 0
		xL2 = 0 : yL2 = 0
		xR1 = 0 : yR1 = 0
		xR2 = 0 : yR2 = 0
		PointNum = 0
		Disp()
	End Sub
	
	Private Sub Command4_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command4.Click
		Dim ret As Short
		
		Label1.Text = ""
		
		If ImageKit1.ImageHandle = 0 Then Exit Sub
		If ImageKit2.ImageHandle = 0 Then Exit Sub
		
		If xL1 = 0 And yL1 = 0 Then Exit Sub
		If xL2 = 0 And yL2 = 0 Then Exit Sub
		If xR1 = 0 And yR1 = 0 Then Exit Sub
		If xR2 = 0 And yR2 = 0 Then Exit Sub
		
		Form2.DefInstance.Show()
		ret = ImageKit3.Effect.Panorama(ImageKit1.ImageHandle, ImageKit2.ImageHandle, 1, xL1, yL1, xL2, yL2, xR1, yR1, xR2, yR2, 255, 255, 255)
		Form2.DefInstance.Close()
		If ret = False Then
			Exit Sub
		End If
		
		ImageKit3.Display(IMAGEKIT7Lib.DispModeConstants.ikStretch)
	End Sub
	
	Private Sub Command5_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command5.Click
		Me.Close()
	End Sub
	
	Private Sub ImageKit1_MouseDownEvent(ByVal eventSender As System.Object, ByVal eventArgs As AxIMAGEKIT7Lib._IImageKitEvents_MouseDownEvent) Handles ImageKit1.MouseDownEvent
		Dim ret As Short
		
		If ImageKit1.ImageHandle <> 0 Then
			ImageKit1.PrintDraw.ClearProperty()
			ImageKit1.PrintDraw.PenMode = IMAGEKIT7Lib.PenModeConstants.ikPenModeNotXorPen
			ImageKit1.PrintDraw.PenWidth = 2
			ImageKit1.PrintDraw.PenStyle = IMAGEKIT7Lib.PenStyleConstants.ikPenSolid
			ret = ImageKit1.PrintDraw.Ellipse(ImageKit1.hDC, eventArgs.x - 2, eventArgs.y - 2, eventArgs.x + 2, eventArgs.y + 2, IMAGEKIT7Lib.OutPutDeviceModeConstants.ikScreen)
		End If
	End Sub

	
	Private Sub ImageKit2_MouseDownEvent(ByVal eventSender As System.Object, ByVal eventArgs As AxIMAGEKIT7Lib._IImageKitEvents_MouseDownEvent) Handles ImageKit2.MouseDownEvent
		Dim ret As Short
		
		If ImageKit2.ImageHandle <> 0 Then
			ImageKit1.PrintDraw.ClearProperty()
			ImageKit1.PrintDraw.PenMode = IMAGEKIT7Lib.PenModeConstants.ikPenModeNotXorPen
			ImageKit1.PrintDraw.PenWidth = 2
			ImageKit1.PrintDraw.PenStyle = IMAGEKIT7Lib.PenStyleConstants.ikPenSolid
			ret = ImageKit1.PrintDraw.Ellipse(ImageKit2.hDC, eventArgs.x - 2, eventArgs.y - 2, eventArgs.x + 2, eventArgs.y + 2, IMAGEKIT7Lib.OutPutDeviceModeConstants.ikScreen)
		End If
	End Sub

	Sub Disp()
		If PointNum = 0 Then Label1.Text = "Set the start point on the left image."
		If PointNum = 1 Then Label1.Text = "Set the end point on the left image."
		If PointNum = 2 Then Label1.Text = "Set the start point on the right image."
		If PointNum = 3 Then Label1.Text = "Set the end point on the right image."
		If PointNum = 4 Then Label1.Text = "Click the Execute button"
	End Sub
	
	Private Sub ImageKit3_Progress(ByVal eventSender As System.Object, ByVal eventArgs As AxIMAGEKIT7Lib._IImageKitEvents_ProgressEvent) Handles ImageKit3.Progress
		Form2.DefInstance.Label1.Text = CStr(eventArgs.Percent)
		Form2.DefInstance.Label1.Refresh()
		System.Windows.Forms.Application.DoEvents()
	End Sub

    Private Sub ImageKit2_MouseDownImage1(ByVal sender As Object, ByVal e As AxIMAGEKIT7Lib._IImageKitEvents_MouseDownImageEvent) Handles ImageKit2.MouseDownImage
        Disp()
        If PointNum = 2 Then
            xR1 = e.x
            yR1 = e.y
        End If
        If PointNum = 3 Then
            xR2 = e.x
            yR2 = e.y
        End If

        PointNum = PointNum + 1
        Disp()
    End Sub

    Private Sub ImageKit1_MouseDownImage1(ByVal sender As Object, ByVal e As AxIMAGEKIT7Lib._IImageKitEvents_MouseDownImageEvent) Handles ImageKit1.MouseDownImage
        Disp()
        If PointNum = 0 Then
            xL1 = e.x
            yL1 = e.y
        End If
        If PointNum = 1 Then
            xL2 = e.x
            yL2 = e.y
        End If

        PointNum = PointNum + 1
        Disp()
    End Sub
End Class