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 Command9 As System.Windows.Forms.Button
	Public WithEvents Command8 As System.Windows.Forms.Button
	Public WithEvents Command7 As System.Windows.Forms.Button
	Public WithEvents Command6 As System.Windows.Forms.Button
	Public WithEvents Command5 As System.Windows.Forms.Button
	Public WithEvents Command4 As System.Windows.Forms.Button
	Public WithEvents Command3 As System.Windows.Forms.Button
	Public WithEvents Command2 As System.Windows.Forms.Button
	Public WithEvents Command1 As System.Windows.Forms.Button
	Public WithEvents ImageKit1 As AxIMAGEKIT7Lib.AxImageKit
	Public WithEvents Frame1 As System.Windows.Forms.GroupBox
	Public WithEvents Frame2 As System.Windows.Forms.GroupBox
	Public WithEvents Frame3 As System.Windows.Forms.GroupBox
	'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.Command9 = New System.Windows.Forms.Button
        Me.Command8 = New System.Windows.Forms.Button
        Me.Command7 = New System.Windows.Forms.Button
        Me.Command6 = New System.Windows.Forms.Button
        Me.Command5 = New System.Windows.Forms.Button
        Me.Command4 = New System.Windows.Forms.Button
        Me.Command3 = New System.Windows.Forms.Button
        Me.Command2 = New System.Windows.Forms.Button
        Me.Command1 = New System.Windows.Forms.Button
        Me.ImageKit1 = New AxIMAGEKIT7Lib.AxImageKit
        Me.Frame1 = New System.Windows.Forms.GroupBox
        Me.Frame2 = New System.Windows.Forms.GroupBox
        Me.Frame3 = New System.Windows.Forms.GroupBox
        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(473, 80)
        Me.Text1.TabIndex = 13
        Me.Text1.Text = "A lot of people have asked if the editing toolbar functions can be used programat" & _
        "ically. Unfortunately, the image editing toolbars must be displayed for their ed" & _
        "it functions to be enabled. This sample illustrates a work around where the tool" & _
        "bar is hidden from view and the edit functions are used programatically. In this" & _
        " sample we set just a few properties for the pen and also for drawing text and e" & _
        "llipse. This sample includes a readme text."
        '
        'Command9
        '
        Me.Command9.BackColor = System.Drawing.SystemColors.Control
        Me.Command9.Cursor = System.Windows.Forms.Cursors.Default
        Me.Command9.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Command9.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Command9.Location = New System.Drawing.Point(504, 368)
        Me.Command9.Name = "Command9"
        Me.Command9.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Command9.Size = New System.Drawing.Size(97, 37)
        Me.Command9.TabIndex = 11
        Me.Command9.Text = "Save Image to File"
        '
        'Command8
        '
        Me.Command8.BackColor = System.Drawing.SystemColors.Control
        Me.Command8.Cursor = System.Windows.Forms.Cursors.Default
        Me.Command8.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Command8.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Command8.Location = New System.Drawing.Point(504, 328)
        Me.Command8.Name = "Command8"
        Me.Command8.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Command8.Size = New System.Drawing.Size(97, 33)
        Me.Command8.TabIndex = 10
        Me.Command8.Text = "Modify Image Data"
        '
        'Command7
        '
        Me.Command7.BackColor = System.Drawing.SystemColors.Control
        Me.Command7.Cursor = System.Windows.Forms.Cursors.Default
        Me.Command7.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Command7.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Command7.Location = New System.Drawing.Point(504, 264)
        Me.Command7.Name = "Command7"
        Me.Command7.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Command7.Size = New System.Drawing.Size(97, 33)
        Me.Command7.TabIndex = 7
        Me.Command7.Text = "Draw Ellipse"
        '
        'Command6
        '
        Me.Command6.BackColor = System.Drawing.SystemColors.Control
        Me.Command6.Cursor = System.Windows.Forms.Cursors.Default
        Me.Command6.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Command6.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Command6.Location = New System.Drawing.Point(504, 224)
        Me.Command6.Name = "Command6"
        Me.Command6.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Command6.Size = New System.Drawing.Size(97, 33)
        Me.Command6.TabIndex = 6
        Me.Command6.Text = "Draw Text"
        '
        '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(504, 184)
        Me.Command5.Name = "Command5"
        Me.Command5.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Command5.Size = New System.Drawing.Size(97, 33)
        Me.Command5.TabIndex = 5
        Me.Command5.Text = "Use Pen"
        '
        '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(504, 104)
        Me.Command4.Name = "Command4"
        Me.Command4.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Command4.Size = New System.Drawing.Size(97, 33)
        Me.Command4.TabIndex = 4
        Me.Command4.Text = "Redisplay Toolbar"
        '
        '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(504, 64)
        Me.Command3.Name = "Command3"
        Me.Command3.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Command3.Size = New System.Drawing.Size(97, 33)
        Me.Command3.TabIndex = 3
        Me.Command3.Text = "Hide Toolbar"
        '
        '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(488, 424)
        Me.Command2.Name = "Command2"
        Me.Command2.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Command2.Size = New System.Drawing.Size(129, 33)
        Me.Command2.TabIndex = 2
        Me.Command2.Text = "End"
        '
        '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(488, 8)
        Me.Command1.Name = "Command1"
        Me.Command1.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Command1.Size = New System.Drawing.Size(129, 33)
        Me.Command1.TabIndex = 1
        Me.Command1.Text = "Load Image from 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(472, 376)
        Me.ImageKit1.TabIndex = 0
        '
        'Frame1
        '
        Me.Frame1.BackColor = System.Drawing.SystemColors.Control
        Me.Frame1.Font = New System.Drawing.Font("Arial", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Frame1.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Frame1.Location = New System.Drawing.Point(488, 152)
        Me.Frame1.Name = "Frame1"
        Me.Frame1.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Frame1.Size = New System.Drawing.Size(129, 152)
        Me.Frame1.TabIndex = 8
        Me.Frame1.TabStop = False
        Me.Frame1.Text = "Some Edit Functions"
        '
        'Frame2
        '
        Me.Frame2.BackColor = System.Drawing.SystemColors.Control
        Me.Frame2.Font = New System.Drawing.Font("Arial", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Frame2.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Frame2.Location = New System.Drawing.Point(488, 48)
        Me.Frame2.Name = "Frame2"
        Me.Frame2.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Frame2.Size = New System.Drawing.Size(129, 97)
        Me.Frame2.TabIndex = 9
        Me.Frame2.TabStop = False
        Me.Frame2.Text = "Displaying Toolbar"
        '
        'Frame3
        '
        Me.Frame3.BackColor = System.Drawing.SystemColors.Control
        Me.Frame3.Font = New System.Drawing.Font("Arial", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Frame3.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Frame3.Location = New System.Drawing.Point(488, 312)
        Me.Frame3.Name = "Frame3"
        Me.Frame3.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Frame3.Size = New System.Drawing.Size(129, 105)
        Me.Frame3.TabIndex = 12
        Me.Frame3.TabStop = False
        Me.Frame3.Text = "Saving Changes"
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.BackColor = System.Drawing.SystemColors.Control
        Me.ClientSize = New System.Drawing.Size(621, 470)
        Me.Controls.Add(Me.Text1)
        Me.Controls.Add(Me.Command9)
        Me.Controls.Add(Me.Command8)
        Me.Controls.Add(Me.Command7)
        Me.Controls.Add(Me.Command6)
        Me.Controls.Add(Me.Command5)
        Me.Controls.Add(Me.Command4)
        Me.Controls.Add(Me.Command3)
        Me.Controls.Add(Me.Command2)
        Me.Controls.Add(Me.Command1)
        Me.Controls.Add(Me.ImageKit1)
        Me.Controls.Add(Me.Frame1)
        Me.Controls.Add(Me.Frame2)
        Me.Controls.Add(Me.Frame3)
        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 = "Hiding the Image Editing Toolbars"
        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 the image file...
		ImageKit1.File.LoadFile(IMAGEKIT7Lib.LoadFileConstants.ikLoad)
		
		'Just to simplify things I am making sure a raster image is loaded...
		If ImageKit1.ImageKind <> 1 Then
			MsgBox("Please load a raster image.")
			Exit Sub
		End If
		
        ImageKit1.ScrollBar = True
        ImageKit1.Display(IMAGEKIT7Lib.DispModeConstants.ikActualSize)
	End Sub
	
	Private Sub Command2_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command2.Click
		Me.Close()
	End Sub
	
	Private Sub Command3_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command3.Click
		ImageKit1.Edit.ToolBarLeft = -1000
	End Sub
	
	Private Sub Command4_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command4.Click
		ImageKit1.Edit.ToolBarLeft = 50
	End Sub
	
	Private Sub Command5_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command5.Click
		'set the pen size...
		ImageKit1.Edit.PenSize = IMAGEKIT7Lib.PenSizeConstants.ikPenSize1
		ImageKit1.Edit.PenSize3 = 50
		
		'set the edit action to the pen...
		ImageKit1.Edit.Action = IMAGEKIT7Lib.SelEditFuncConstants.ikPen
	End Sub
	
	Private Sub Command6_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command6.Click
		'set some text properties...
		ImageKit1.Edit.FontName = "Arial"
		ImageKit1.Edit.FontBold = False
		ImageKit1.Edit.FontItalic = False
		ImageKit1.Edit.FontSize = 16
		
		'set the action to the text tool...
		ImageKit1.Edit.Action = IMAGEKIT7Lib.SelEditFuncConstants.ikText
		
		'clear the edit's text property...
		ImageKit1.Edit.Text = ""
	End Sub
	
	Private Sub Command7_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command7.Click
		'set the pen size...
		ImageKit1.Edit.PenSize = IMAGEKIT7Lib.PenSizeConstants.ikPenSize3
		ImageKit1.Edit.PenSize3 = 5
		
		'set the edit action to the ellipse...
		ImageKit1.Edit.Action = IMAGEKIT7Lib.SelEditFuncConstants.ikEllipse
	End Sub
	
	Private Sub Command8_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command8.Click
		ImageKit1.Edit.Modify()
	End Sub
	
	Private Sub Command9_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command9.Click
		
		'exit if there is no image loaded...
		If ImageKit1.ImageHandle = 0 Then
			Exit Sub
		End If
		
		'set the file extensions that are displayed in the "Save" file dialog.
		ImageKit1.File.FileExt = "*;BMP;JPG;GIF;"
		'---------------------------------------------------------------------------
		' IMPORTANT: The asterik "*" in the FileExt property removes the "All Files"
		' option from the "Save" file dialog. THIS IS NECESSARY WHEN SAVING FILES
		' using the SaveFileDlgFileType property because it returns 0 if "All Files"
		' is selected...
		'---------------------------------------------------------------------------
		
		'display the "Save" file dialog...
		If ImageKit1.File.SaveFileDialog = False Then
			Exit Sub
		End If
		
		'use the value of the SaveFileDlgFileType to determine the SaveFile method...
		Select Case ImageKit1.File.SaveFileDlgFileType
			
			Case 1
				'save as uncompressed bmp...
				ImageKit1.File.SaveFile(IMAGEKIT7Lib.SaveFileConstants.ikSaveBMP, 0)
				
			Case 2
				'save as jpeg. Must check the bitcount and don't forget the JpegQuality!
				If ImageKit1.BitCount = 24 Then
					ImageKit1.File.JpegQuality = 70
					ImageKit1.File.SaveFile(IMAGEKIT7Lib.SaveFileConstants.ikSaveJPEG, 0)
				ElseIf ImageKit1.BitCount = 8 And ImageKit1.Gray <> False Then 
					ImageKit1.File.JpegQuality = 70
					ImageKit1.File.SaveFile(IMAGEKIT7Lib.SaveFileConstants.ikSaveJPEG, 0)
				Else
					MsgBox("Jpeg images must be 24 bit color or 8 bit grayscale")
					Exit Sub
				End If
				
			Case 3
				'save as gif. Must check the bitcount!
				If ImageKit1.BitCount > 8 Then
					MsgBox("Gif images must be 256 colors or less")
					Exit Sub
				End If
				ImageKit1.File.SaveFile(IMAGEKIT7Lib.SaveFileConstants.ikSaveGIF, 0)
			Case Else ' do not save
				MsgBox("Unable to save the image")
		End Select
		
	End Sub
	
	Private Sub Form1_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
		Dim BlankImageHandle As Integer
		
		'create an image when the form loads so that the tools can be used without having to load any other images...
		
		BlankImageHandle = ImageKit1.CreateImage(480, 400, 24, 255, 255, 255)
		ImageKit1.ImageHandle = BlankImageHandle
        ImageKit1.ScrollBar = True
        ImageKit1.Display(IMAGEKIT7Lib.DispModeConstants.ikActualSize)
		
		'enable and display the raster image editing toolbar...
		ImageKit1.Edit.EditEnable = True
		ImageKit1.Edit.ToolBarCloseBox = True
		ImageKit1.Edit.ToolBarCaption = "Edit"
		ImageKit1.Edit.ToolBarLeft = 50
		ImageKit1.Edit.ToolBarTop = 50
		ImageKit1.Edit.ShowToolBar(IMAGEKIT7Lib.EditToolBarModeConstants.ikRaster)
	End Sub
	
	Private Sub ImageKit1_SelEditFunc(ByVal eventSender As System.Object, ByVal eventArgs As AxIMAGEKIT7Lib._IImageKitEvents_SelEditFuncEvent) Handles ImageKit1.SelEditFunc
		'set the cursors for each editing function...
		If eventArgs.SelFunction = IMAGEKIT7Lib.SelEditFuncConstants.ikPen Then
            ImageKit1.MouseCursorFile = Application.StartupPath & "\..\PENCIL.CUR"
			ImageKit1.MouseCursorType = IMAGEKIT7Lib.CursorTypeConstants.ikCursorCustom
			
		ElseIf eventArgs.SelFunction = IMAGEKIT7Lib.SelEditFuncConstants.ikEllipse Then 
            ImageKit1.MouseCursorFile = Application.StartupPath & "\..\DRAGMOVE.CUR"
			ImageKit1.MouseCursorType = IMAGEKIT7Lib.CursorTypeConstants.ikCursorCustom
			
		ElseIf eventArgs.SelFunction = IMAGEKIT7Lib.SelEditFuncConstants.ikText Then 
            ImageKit1.MouseCursorFile = Application.StartupPath & "\..\H_POINT.CUR"
			ImageKit1.MouseCursorType = IMAGEKIT7Lib.CursorTypeConstants.ikCursorCustom
			
		Else
			ImageKit1.MouseCursorType = IMAGEKIT7Lib.CursorTypeConstants.ikCursorARROW
			
		End If
	End Sub
End Class