Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    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

    '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.
    Public WithEvents Text1 As System.Windows.Forms.TextBox
    Friend WithEvents ImageKit1 As AxIMAGEKIT7Lib.AxImageKit
    Friend WithEvents ImageKitThumb1 As AxIMAGEKIT7THUMBLib.AxImageKitThumb
    <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.ImageKitThumb1 = New AxIMAGEKIT7THUMBLib.AxImageKitThumb
        CType(Me.ImageKit1, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.ImageKitThumb1, 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(617, 49)
        Me.Text1.TabIndex = 4
        Me.Text1.Text = "The Thumbnail Control can display multipage image files too. In this sample, each" & _
        " page of a multipage Tiff file is displayed seperately in the Thumbnail Control." & _
        " When a thumbnail image is selected, the SelectFile event returns the image path" & _
        " and filename along with a page index allowing that page of the multipage file t" & _
        "o be loaded into the ImageKit Control. "
        '
        'ImageKit1
        '
        Me.ImageKit1.Location = New System.Drawing.Point(8, 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(361, 313)
        Me.ImageKit1.TabIndex = 5
        '
        'ImageKitThumb1
        '
        Me.ImageKitThumb1.Location = New System.Drawing.Point(376, 56)
        Me.ImageKitThumb1.Name = "ImageKitThumb1"
        Me.ImageKitThumb1.OcxState = CType(resources.GetObject("ImageKitThumb1.OcxState"), System.Windows.Forms.AxHost.State)
        Me.ImageKitThumb1.Size = New System.Drawing.Size(249, 313)
        Me.ImageKitThumb1.TabIndex = 6
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(629, 373)
        Me.Controls.Add(Me.ImageKitThumb1)
        Me.Controls.Add(Me.ImageKit1)
        Me.Controls.Add(Me.Text1)
        Me.Name = "Form1"
        Me.Text = "Multipage Files and Thumbnails"
        CType(Me.ImageKit1, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.ImageKitThumb1, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'set the types of images that can be loaded into the thumbnail control...
        ImageKitThumb1.FileExt = "TIF"

        'set the read mode so that multi-page images are loaded...
        ImageKitThumb1.ReadMode = IMAGEKIT7THUMBLib.ThumbnailReadModeConstants.ikThumbRdDspMultiImg

        '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_SelectFile(ByVal sender As Object, ByVal e As AxIMAGEKIT7THUMBLib._IImageKitThumbEvents_SelectFileEvent) Handles ImageKitThumb1.SelectFile
        'get the index of a multi-page image file...
        'Here we are loading only one multi-page file 
        'so the index will be the ImageNumber - 1
        Dim ImgIndex As Integer

        ImgIndex = e.imageNumber - 1

        'reconstruct the filename of the multi-page image file so that there is no index number at the end...
        'If there is no index then use the value returned in the Filename argument,
        'otherwise remove the index from the value returned in the FileName argument.
        Dim ImgFileName As String

        If ImgIndex <> 0 Then
            ImgFileName = e.fileName.Substring(0, e.fileName.Length - ImgIndex.ToString().Length)
        Else
            ImgFileName = e.fileName
        End If

        'set this index into the LoadPage property...
        ImageKit1.File.LoadPage = ImgIndex

        'display the image whose thumbnail has been selected...
        ImageKit1.File.FileName = e.pathName + ImgFileName

        '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
End Class
