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 Text2 As System.Windows.Forms.TextBox
	Public WithEvents ImageKitThumb1 As AxIMAGEKIT7THUMBLib.AxImageKitThumb
	Public WithEvents ImageKit1 As AxIMAGEKIT7Lib.AxImageKit
	Public WithEvents Command3 As System.Windows.Forms.Button
	Public WithEvents Text1 As System.Windows.Forms.TextBox
	Public WithEvents Command2 As System.Windows.Forms.Button
	Public WithEvents Command1 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.Text2 = New System.Windows.Forms.TextBox
        Me.ImageKitThumb1 = New AxIMAGEKIT7THUMBLib.AxImageKitThumb
        Me.ImageKit1 = New AxIMAGEKIT7Lib.AxImageKit
        Me.Command3 = New System.Windows.Forms.Button
        Me.Text1 = New System.Windows.Forms.TextBox
        Me.Command2 = New System.Windows.Forms.Button
        Me.Command1 = New System.Windows.Forms.Button
        Me.Label1 = New System.Windows.Forms.Label
        CType(Me.ImageKitThumb1, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.ImageKit1, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'Text2
        '
        Me.Text2.AcceptsReturn = True
        Me.Text2.AutoSize = False
        Me.Text2.BackColor = System.Drawing.Color.FromArgb(CType(255, Byte), CType(255, Byte), CType(192, Byte))
        Me.Text2.Cursor = System.Windows.Forms.Cursors.IBeam
        Me.Text2.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Text2.ForeColor = System.Drawing.Color.FromArgb(CType(192, Byte), CType(0, Byte), CType(0, Byte))
        Me.Text2.Location = New System.Drawing.Point(8, 8)
        Me.Text2.MaxLength = 0
        Me.Text2.Multiline = True
        Me.Text2.Name = "Text2"
        Me.Text2.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Text2.Size = New System.Drawing.Size(561, 49)
        Me.Text2.TabIndex = 7
        Me.Text2.Text = "Thumbnail images can be selected by clicking them with the mouse or by specifying" & _
        " their image number. This sample shows how to scroll the thumbnail control to di" & _
        "splay the thumbnail image that has been selected. The image is then displayed in" & _
        " the ImageKit Control."
        '
        'ImageKitThumb1
        '
        Me.ImageKitThumb1.Location = New System.Drawing.Point(328, 64)
        Me.ImageKitThumb1.Name = "ImageKitThumb1"
        Me.ImageKitThumb1.OcxState = CType(resources.GetObject("ImageKitThumb1.OcxState"), System.Windows.Forms.AxHost.State)
        Me.ImageKitThumb1.Size = New System.Drawing.Size(241, 249)
        Me.ImageKitThumb1.TabIndex = 6
        '
        'ImageKit1
        '
        Me.ImageKit1.Location = New System.Drawing.Point(8, 64)
        Me.ImageKit1.Name = "ImageKit1"
        Me.ImageKit1.OcxState = CType(resources.GetObject("ImageKit1.OcxState"), System.Windows.Forms.AxHost.State)
        Me.ImageKit1.Size = New System.Drawing.Size(313, 337)
        Me.ImageKit1.TabIndex = 5
        '
        '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, 320)
        Me.Command3.Name = "Command3"
        Me.Command3.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Command3.Size = New System.Drawing.Size(104, 33)
        Me.Command3.TabIndex = 4
        Me.Command3.Text = "Get Image by Image Number"
        '
        'Text1
        '
        Me.Text1.AcceptsReturn = True
        Me.Text1.AutoSize = False
        Me.Text1.BackColor = System.Drawing.SystemColors.Window
        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.SystemColors.WindowText
        Me.Text1.Location = New System.Drawing.Point(408, 320)
        Me.Text1.MaxLength = 0
        Me.Text1.Name = "Text1"
        Me.Text1.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Text1.Size = New System.Drawing.Size(41, 25)
        Me.Text1.TabIndex = 3
        Me.Text1.Text = "6"
        '
        '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(472, 368)
        Me.Command2.Name = "Command2"
        Me.Command2.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Command2.Size = New System.Drawing.Size(96, 33)
        Me.Command2.TabIndex = 1
        Me.Command2.Text = "Get Last Image"
        '
        '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(328, 368)
        Me.Command1.Name = "Command1"
        Me.Command1.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Command1.Size = New System.Drawing.Size(96, 33)
        Me.Command1.TabIndex = 0
        Me.Command1.Text = "Get First Image"
        '
        'Label1
        '
        Me.Label1.BackColor = System.Drawing.SystemColors.Control
        Me.Label1.Cursor = System.Windows.Forms.Cursors.Default
        Me.Label1.Font = New System.Drawing.Font("Arial", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label1.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Label1.Location = New System.Drawing.Point(328, 320)
        Me.Label1.Name = "Label1"
        Me.Label1.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Label1.Size = New System.Drawing.Size(73, 25)
        Me.Label1.TabIndex = 2
        Me.Label1.Text = "Image No:"
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.BackColor = System.Drawing.SystemColors.Control
        Me.ClientSize = New System.Drawing.Size(575, 412)
        Me.Controls.Add(Me.Text2)
        Me.Controls.Add(Me.ImageKitThumb1)
        Me.Controls.Add(Me.ImageKit1)
        Me.Controls.Add(Me.Command3)
        Me.Controls.Add(Me.Text1)
        Me.Controls.Add(Me.Command2)
        Me.Controls.Add(Me.Command1)
        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, 30)
        Me.Name = "Form1"
        Me.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Text = "Select a Thumbnail and Scroll "
        CType(Me.ImageKitThumb1, 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 
	'declare some variables...
	Dim LastImage As Short
	'this array will store the filenames of the thumbnail images...
	Dim ImageName(20) As String
	
	Private Sub Command1_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command1.Click
		'Scroll to and Select the first thumbnail image...
		
		'set the scroll direction...
		ImageKitThumb1.ScrollVH = IMAGEKIT7THUMBLib.ThumbnailScrollConstants.ikThumbVertical
		
		'determine how far to scroll...
		Dim TopLeftImageNo As Short
		Dim scrolllength As Short
		
		'the StartNum property returns the image number of the
		'thumbnail currently displayed in the top left corner of the thumbnail control.
		'by subtracting the image number of the first thumbnail image, in this case 1,
		'from the StartNum and then dividing by the number of images in each row,
		'we can calculate how many rows we need to scroll in a negative directin to reach
		'the start image.
		
		'the StartNum property starts from 0 whereas the
		'imagenumber retrieved elsewhere start from 1. We need to equate the two imagenumbers...
		TopLeftImageNo = ImageKitThumb1.StartNum + 1
		
		scrolllength = (TopLeftImageNo - 1) / ImageKitThumb1.RowCount
		
		'set the scrollstep (in a negative direction)...
		ImageKitThumb1.ScrollStep = -1 * scrolllength
		
		'scroll...
		ImageKitThumb1.Scroll()
		
		'select the first thumbnail image...
		ImageKitThumb1.SelectImage(1)
	End Sub
	
	Private Sub Command2_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command2.Click
		'Scroll to and Select the last thumbnail image...
		
		'set the scroll direction...
		ImageKitThumb1.ScrollVH = IMAGEKIT7THUMBLib.ThumbnailScrollConstants.ikThumbVertical
		
		'determine how far to scroll...
		Dim TopLeftImageNo As Short
		Dim scrolllength As Short
		
		'the StartNum property returns the image number of the
		'thumbnail currently displayed in the top left corner of the thumbnail control.
		'by subtracting the StartNum from the image number of the last thumbnail image'
		'and then dividing by the number of images in each row,
		'we can calculate how many rows we need to sroll in a positive directin to reach
		'the last image.
		
		'the StartNum property starts from 0 whereas the
		'imagenumber retrieved elsewhere start from 1. We need to equate the two imagenumbers...
		TopLeftImageNo = ImageKitThumb1.StartNum + 1
		
		scrolllength = (LastImage - TopLeftImageNo) / ImageKitThumb1.RowCount
		
		'set the scrollstep...
		ImageKitThumb1.ScrollStep = scrolllength
		
		'scroll...
		ImageKitThumb1.Scroll()
		
		'select the last thumbnail image...
		ImageKitThumb1.SelectImage(LastImage) 'see the ShowThumbImage event...
	End Sub
	
	Private Sub Command3_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command3.Click
		'Scroll to and Select the thumbnail image specified in the textbox...
		
		'set the scroll direction...
		ImageKitThumb1.ScrollVH = IMAGEKIT7THUMBLib.ThumbnailScrollConstants.ikThumbVertical
		
		'determine how far to scroll...
		Dim TopLeftImageNo As Short
		Dim scrolllength As Short
		
		'the StartNum property returns the image number of the
		'thumbnail currently displayed in the top left corner of the thumbnail control.
		'by finding the difference between the StartNum and the image number of the
		'thumbnail image we want to scroll to, and then dividing by the number of
		'images in each row, we can calculate how many rows we need to scroll to
		'reach the image.
		
		'if the startnum is greater than the image number then we need to scroll in a
		'negative direction...
		
		'the StartNum property starts from 0 whereas the
		'imagenumber retrieved elsewhere start from 1. We need to equate the two imagenumbers...
		TopLeftImageNo = ImageKitThumb1.StartNum + 1
		
		If TopLeftImageNo > Val(Text1.Text) Then
			'the image to scroll to is currently not displayed in the thumbnail control.
			'we must scroll a minimum of 1 step
			scrolllength = -1 * ((TopLeftImageNo - Val(Text1.Text)) / ImageKitThumb1.RowCount)
			If scrolllength = 0 Then
				scrolllength = -1
			End If
		Else
			'if the image is currently displayed but in a different row then we will not scroll...
			scrolllength = (Val(Text1.Text) - TopLeftImageNo) / ImageKitThumb1.RowCount
			If scrolllength < 3 Then
				scrolllength = 0
			End If
			
		End If
		
		'set the scrollstep...
		ImageKitThumb1.ScrollStep = scrolllength
		
		'scroll...
		ImageKitThumb1.Scroll()
		
		'select the thumbnail image by image number...
		ImageKitThumb1.SelectImage(Val(Text1.Text))
	End Sub
	
	
	Private Sub Form1_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
		'set the types of images that can be loaded into the thumbnail control...
		ImageKitThumb1.FileExt = "JPG"
		
		'set the path to the images...
        ImageKitThumb1.FilePath = Application.StartupPath & "\..\..\..\..\..\..\Images\ForSamples\Thumbnails\"
		
		'display the images in the thumbnail control...
		ImageKitThumb1.GetFiles()
	End Sub
	
	Private Sub ImageKitThumb1_EndLoadFile(ByVal eventSender As System.Object, ByVal eventArgs As AxIMAGEKIT7THUMBLib._IImageKitThumbEvents_EndLoadFileEvent) Handles ImageKitThumb1.EndLoadFile
		'set all of the thumbnail filenames into an array...
		'These will be used to select a thumbnail from the filename...
		ImageName(eventArgs.ImageNumber) = eventArgs.FileName
	End Sub

    Private Sub ImageKitThumb1_SelectFile1(ByVal sender As Object, ByVal e As AxIMAGEKIT7THUMBLib._IImageKitThumbEvents_SelectFileEvent) Handles ImageKitThumb1.SelectFile
        'display the image whose thumbnail has been selected...
        ImageKit1.File.FileName = e.pathName & e.fileName

        'load the image file...
        ImageKit1.File.LoadFile(IMAGEKIT7Lib.LoadFileConstants.ikLoad)

        'display the image in actual sized display mode...
        ImageKit1.ScrollBar = True
        ImageKit1.Display(IMAGEKIT7Lib.DispModeConstants.ikActualSize)
    End Sub

    Private Sub ImageKitThumb1_ShowThumbImage1(ByVal sender As Object, ByVal e As AxIMAGEKIT7THUMBLib._IImageKitThumbEvents_ShowThumbImageEvent) Handles ImageKitThumb1.ShowThumbImage
        'set the image number of the last image into a variable...
        LastImage = e.maxImage
    End Sub
End Class