ArcObjects Library Reference  

InkSketchCommit

About the Committing ink sketches using the controls ink commands Sample

[C#]

InkSketchCommit.cs

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Runtime.InteropServices;

using ESRI.ArcGIS.Controls;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.SystemUI;
using ESRI.ArcGIS.ADF;
using ESRI.ArcGIS;


namespace InkSketchCommit
{
	/// <summary>
	/// Summary description for Form1.
	/// </summary>
	public class Form1 : System.Windows.Forms.Form
	{
		private System.Windows.Forms.GroupBox gpbInkSketch;
		private System.Windows.Forms.GroupBox gpbReport;
		private System.Windows.Forms.Label lblInfo;
		private System.Windows.Forms.RadioButton radManual;
		private System.Windows.Forms.RadioButton radAutoGraphic;
		private System.Windows.Forms.RadioButton radAutoText;
		private System.Windows.Forms.Label lbl1sec;
		private System.Windows.Forms.Label lbl10sec;
		private System.Windows.Forms.Label lblAutoComplete;
		private System.Windows.Forms.Label lblCollectingStatus;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.TextBox tbxNumber;
		/// <summary>
		/// Required designer variable.
		/// </summary>
        private System.ComponentModel.Container components = null;
        private System.Windows.Forms.TrackBar tbrAutoComplete;
		private IMap m_pMap;
		private ESRI.ArcGIS.Controls.IEngineInkEnvironment m_EngineInkEnvironment;
		private IEngineInkEnvironmentEvents_OnStartEventHandler m_startInkE;
		private IEngineInkEnvironmentEvents_OnStopEventHandler m_stopInkE;
        private IEngineInkEnvironmentEvents_OnGestureEventHandler m_gestureInkE;
        private TableLayoutPanel tableLayoutPanel1;
        private AxToolbarControl axToolbarControl1;
        private AxMapControl axMapControl1;
        private AxLicenseControl axLicenseControl1;

		///Tablet PC system metric value used by GetSystemMetrics to identify whether the application
		///is running on a Tablet PC.

		private const int SM_TABLETPC = 86;
		/// <summary>
		/// The GetSystemMetrics function retrieves system metrics and system configuration settings.
		/// </summary>
		
		public Form1()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
            ESRI.ArcGIS.ADF.COMSupport.AOUninitialize.Shutdown();
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
            this.gpbInkSketch = new System.Windows.Forms.GroupBox();
            this.lblAutoComplete = new System.Windows.Forms.Label();
            this.lbl10sec = new System.Windows.Forms.Label();
            this.lbl1sec = new System.Windows.Forms.Label();
            this.tbrAutoComplete = new System.Windows.Forms.TrackBar();
            this.radAutoText = new System.Windows.Forms.RadioButton();
            this.radAutoGraphic = new System.Windows.Forms.RadioButton();
            this.radManual = new System.Windows.Forms.RadioButton();
            this.lblInfo = new System.Windows.Forms.Label();
            this.gpbReport = new System.Windows.Forms.GroupBox();
            this.tbxNumber = new System.Windows.Forms.TextBox();
            this.label1 = new System.Windows.Forms.Label();
            this.lblCollectingStatus = new System.Windows.Forms.Label();
            this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
            this.axToolbarControl1 = new ESRI.ArcGIS.Controls.AxToolbarControl();
            this.axMapControl1 = new ESRI.ArcGIS.Controls.AxMapControl();
            this.axLicenseControl1 = new ESRI.ArcGIS.Controls.AxLicenseControl();
            this.gpbInkSketch.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.tbrAutoComplete)).BeginInit();
            this.gpbReport.SuspendLayout();
            this.tableLayoutPanel1.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.axToolbarControl1)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.axMapControl1)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.axLicenseControl1)).BeginInit();
            this.SuspendLayout();
            // 
            // gpbInkSketch
            // 
            this.gpbInkSketch.Controls.Add(this.lblAutoComplete);
            this.gpbInkSketch.Controls.Add(this.lbl10sec);
            this.gpbInkSketch.Controls.Add(this.lbl1sec);
            this.gpbInkSketch.Controls.Add(this.tbrAutoComplete);
            this.gpbInkSketch.Controls.Add(this.radAutoText);
            this.gpbInkSketch.Controls.Add(this.radAutoGraphic);
            this.gpbInkSketch.Controls.Add(this.radManual);
            this.gpbInkSketch.Controls.Add(this.lblInfo);
            this.gpbInkSketch.Location = new System.Drawing.Point(433, 51);
            this.gpbInkSketch.Name = "gpbInkSketch";
            this.gpbInkSketch.Size = new System.Drawing.Size(296, 352);
            this.gpbInkSketch.TabIndex = 3;
            this.gpbInkSketch.TabStop = false;
            this.gpbInkSketch.Text = "Ink Sketch Commit Options";
            // 
            // lblAutoComplete
            // 
            this.lblAutoComplete.Location = new System.Drawing.Point(24, 240);
            this.lblAutoComplete.Name = "lblAutoComplete";
            this.lblAutoComplete.Size = new System.Drawing.Size(263, 23);
            this.lblAutoComplete.TabIndex = 7;
            this.lblAutoComplete.Text = "Automatically Commit the Ink Sketch after:";
            // 
            // lbl10sec
            // 
            this.lbl10sec.Location = new System.Drawing.Point(216, 303);
            this.lbl10sec.Name = "lbl10sec";
            this.lbl10sec.Size = new System.Drawing.Size(64, 24);
            this.lbl10sec.TabIndex = 6;
            this.lbl10sec.Text = "(10 sec)";
            // 
            // lbl1sec
            // 
            this.lbl1sec.Location = new System.Drawing.Point(8, 303);
            this.lbl1sec.Name = "lbl1sec";
            this.lbl1sec.Size = new System.Drawing.Size(65, 24);
            this.lbl1sec.TabIndex = 5;
            this.lbl1sec.Text = "(1 sec)";
            // 
            // tbrAutoComplete
            // 
            this.tbrAutoComplete.Location = new System.Drawing.Point(8, 264);
            this.tbrAutoComplete.Minimum = 1;
            this.tbrAutoComplete.Name = "tbrAutoComplete";
            this.tbrAutoComplete.Size = new System.Drawing.Size(264, 56);
            this.tbrAutoComplete.TabIndex = 4;
            this.tbrAutoComplete.Value = 1;
            this.tbrAutoComplete.MouseUp += new System.Windows.Forms.MouseEventHandler(this.tbrAutoComplete_MouseUp);
            // 
            // radAutoText
            // 
            this.radAutoText.Location = new System.Drawing.Point(16, 167);
            this.radAutoText.Name = "radAutoText";
            this.radAutoText.Size = new System.Drawing.Size(272, 54);
            this.radAutoText.TabIndex = 3;
            this.radAutoText.Text = "Automatically Committed and Recognized as Text (Tablet PC only)";
            this.radAutoText.CheckedChanged += new System.EventHandler(this.radAutoText_CheckedChanged);
            // 
            // radAutoGraphic
            // 
            this.radAutoGraphic.Location = new System.Drawing.Point(16, 144);
            this.radAutoGraphic.Name = "radAutoGraphic";
            this.radAutoGraphic.Size = new System.Drawing.Size(271, 24);
            this.radAutoGraphic.TabIndex = 2;
            this.radAutoGraphic.Text = "Automatically Committed to Graphic";
            this.radAutoGraphic.CheckedChanged += new System.EventHandler(this.radAutoGraphic_CheckedChanged);
            // 
            // radManual
            // 
            this.radManual.Location = new System.Drawing.Point(16, 112);
            this.radManual.Name = "radManual";
            this.radManual.Size = new System.Drawing.Size(160, 24);
            this.radManual.TabIndex = 1;
            this.radManual.Text = "Manually Committed";
            this.radManual.CheckedChanged += new System.EventHandler(this.radManual_CheckedChanged);
            // 
            // lblInfo
            // 
            this.lblInfo.Location = new System.Drawing.Point(16, 40);
            this.lblInfo.Name = "lblInfo";
            this.lblInfo.Size = new System.Drawing.Size(264, 56);
            this.lblInfo.TabIndex = 0;
            this.lblInfo.Text = "Ink sketches can be committed manually or automatically. Click on the buttons belo" +
                "w to change the commit method.";
            // 
            // gpbReport
            // 
            this.gpbReport.Controls.Add(this.tbxNumber);
            this.gpbReport.Controls.Add(this.label1);
            this.gpbReport.Controls.Add(this.lblCollectingStatus);
            this.gpbReport.Location = new System.Drawing.Point(433, 409);
            this.gpbReport.Name = "gpbReport";
            this.gpbReport.Size = new System.Drawing.Size(296, 112);
            this.gpbReport.TabIndex = 4;
            this.gpbReport.TabStop = false;
            this.gpbReport.Text = "Sketch Report";
            // 
            // tbxNumber
            // 
            this.tbxNumber.BackColor = System.Drawing.SystemColors.Control;
            this.tbxNumber.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.tbxNumber.Location = new System.Drawing.Point(176, 32);
            this.tbxNumber.Name = "tbxNumber";
            this.tbxNumber.Size = new System.Drawing.Size(100, 15);
            this.tbxNumber.TabIndex = 2;
            this.tbxNumber.Text = "0";
            // 
            // label1
            // 
            this.label1.Location = new System.Drawing.Point(8, 32);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(168, 23);
            this.label1.TabIndex = 1;
            this.label1.Text = "Number of Ink Sketches = ";
            // 
            // lblCollectingStatus
            // 
            this.lblCollectingStatus.Location = new System.Drawing.Point(8, 80);
            this.lblCollectingStatus.Name = "lblCollectingStatus";
            this.lblCollectingStatus.Size = new System.Drawing.Size(272, 16);
            this.lblCollectingStatus.TabIndex = 0;
            // 
            // tableLayoutPanel1
            // 
            this.tableLayoutPanel1.ColumnCount = 2;
            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 58.46906F));
            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 41.53094F));
            this.tableLayoutPanel1.Controls.Add(this.gpbInkSketch, 1, 1);
            this.tableLayoutPanel1.Controls.Add(this.axToolbarControl1, 0, 0);
            this.tableLayoutPanel1.Controls.Add(this.axMapControl1, 0, 1);
            this.tableLayoutPanel1.Controls.Add(this.gpbReport, 1, 2);
            this.tableLayoutPanel1.Controls.Add(this.axLicenseControl1, 0, 2);
            this.tableLayoutPanel1.Location = new System.Drawing.Point(14, 8);
            this.tableLayoutPanel1.Name = "tableLayoutPanel1";
            this.tableLayoutPanel1.RowCount = 3;
            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 11.88406F));
            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 88.11594F));
            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 120F));
            this.tableLayoutPanel1.Size = new System.Drawing.Size(737, 527);
            this.tableLayoutPanel1.TabIndex = 5;
            // 
            // axToolbarControl1
            // 
            this.tableLayoutPanel1.SetColumnSpan(this.axToolbarControl1, 2);
            this.axToolbarControl1.Location = new System.Drawing.Point(3, 3);
            this.axToolbarControl1.Name = "axToolbarControl1";
            this.axToolbarControl1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axToolbarControl1.OcxState")));
            this.axToolbarControl1.Size = new System.Drawing.Size(729, 28);
            this.axToolbarControl1.TabIndex = 5;
            // 
            // axMapControl1
            // 
            this.axMapControl1.Location = new System.Drawing.Point(3, 51);
            this.axMapControl1.Name = "axMapControl1";
            this.axMapControl1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axMapControl1.OcxState")));
            this.axMapControl1.Size = new System.Drawing.Size(423, 352);
            this.axMapControl1.TabIndex = 6;
            this.axMapControl1.OnAfterScreenDraw += new ESRI.ArcGIS.Controls.IMapControlEvents2_Ax_OnAfterScreenDrawEventHandler(this.axMapControl1_OnAfterScreenDraw);
            // 
            // axLicenseControl1
            // 
            this.axLicenseControl1.Enabled = true;
            this.axLicenseControl1.Location = new System.Drawing.Point(3, 409);
            this.axLicenseControl1.Name = "axLicenseControl1";
            this.axLicenseControl1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axLicenseControl1.OcxState")));
            this.axLicenseControl1.Size = new System.Drawing.Size(32, 32);
            this.axLicenseControl1.TabIndex = 7;
            // 
            // Form1
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
            this.ClientSize = new System.Drawing.Size(767, 540);
            this.Controls.Add(this.tableLayoutPanel1);
            this.MaximumSize = new System.Drawing.Size(775, 580);
            this.MinimumSize = new System.Drawing.Size(775, 580);
            this.Name = "Form1";
            this.Text = "Ink Sketch Commit";
            this.Load += new System.EventHandler(this.Form1_Load);
            this.gpbInkSketch.ResumeLayout(false);
            this.gpbInkSketch.PerformLayout();
            ((System.ComponentModel.ISupportInitialize)(this.tbrAutoComplete)).EndInit();
            this.gpbReport.ResumeLayout(false);
            this.gpbReport.PerformLayout();
            this.tableLayoutPanel1.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.axToolbarControl1)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.axMapControl1)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.axLicenseControl1)).EndInit();
            this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main() 
		{
            
            if (!RuntimeManager.Bind(ProductCode.Engine))
            {
                if (!RuntimeManager.Bind(ProductCode.Desktop))
                {
                    MessageBox.Show("Unable to bind to ArcGIS runtime. Application will be shut down.");
                    return;
                }
            }

            Application.Run(new Form1());
		}

		private void Form1_Load(object sender, System.EventArgs e)
		{
	        //Set buddy control 
			axToolbarControl1.SetBuddyControl(axMapControl1);

			//Add items to the ToolbarControl
			axToolbarControl1.AddItem("esriControls.ControlsOpenDocCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
			axToolbarControl1.AddItem("esriControls.ControlsSaveAsDocCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
			axToolbarControl1.AddItem("esriControls.ControlsInkToolbar", 0, -1, true, 0, esriCommandStyles.esriCommandStyleIconOnly);
			axToolbarControl1.AddItem("esriControls.ControlsMapZoomInTool", 0, -1, true, 0, esriCommandStyles.esriCommandStyleIconOnly);
			axToolbarControl1.AddItem("esriControls.ControlsMapZoomOutTool", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
			axToolbarControl1.AddItem("esriControls.ControlsMapFullExtentCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
			axToolbarControl1.AddItem("esriControls.ControlsSelectTool", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);

			//Set the EngineInkEnviroment Singleton
			m_EngineInkEnvironment = new EngineInkEnvironmentClass();

			//Set the Ink Tool commit type to be manual
			m_EngineInkEnvironment.ToolCommitType = esriEngineInkToolCommitType.esriEngineInkToolCommitTypeManual;

			//Set the Form Controls 
			tbrAutoComplete.Enabled = false;
			tbrAutoComplete.Minimum = 1;
			tbrAutoComplete.Maximum = 10;
			tbrAutoComplete.TickFrequency = 1;
			tbrAutoComplete.TickStyle = TickStyle.BottomRight;
			lblAutoComplete.Enabled = false;
			lbl1sec.Enabled = false;
			lbl10sec.Enabled = false;
			lblCollectingStatus.Text = "Not Collecting Ink";
			tbxNumber.Text = "0";
			radManual.Checked = true;

	        //The radAutoText Radio button is only available on a Tablet PC.
		    //Converting ink to text requires a Recognizer which can only 
			//run on Windows XP Tablet PC Edition.		

			if (IsRunningOnTabletPC())
				{
				radAutoText.Enabled = true;
				}
			else
				{
				radAutoText.Enabled = false;
				}

			//Set the EngineInkEnvironment OnStart events 
			m_startInkE = new IEngineInkEnvironmentEvents_OnStartEventHandler(OnStartInk);
			((IEngineInkEnvironmentEvents_Event)m_EngineInkEnvironment).OnStart += m_startInkE;

			//Set the EngineInkEnvironment OnStop events 
			m_stopInkE = new IEngineInkEnvironmentEvents_OnStopEventHandler(OnStopInk);
			((IEngineInkEnvironmentEvents_Event)m_EngineInkEnvironment).OnStop += m_stopInkE;

			//Set the EngineInkEnvironment OnGesture events 
			m_gestureInkE = new IEngineInkEnvironmentEvents_OnGestureEventHandler(OnGestureInk);
			((IEngineInkEnvironmentEvents_Event)m_EngineInkEnvironment).OnGesture += m_gestureInkE;
		}

		private void OnStartInk()
		{
            //Report to the user the mode of the Ink Collector
            lblCollectingStatus.Text = "Collecting Ink Sketch";
		}

		private void OnStopInk()
		{
            //Report to the user the mode of the Ink Collector
            lblCollectingStatus.Text = "Not Collecting Ink Sketch";
		}

        private void OnGestureInk(esriEngineInkGesture p_gesture, object p_point)
		{
            //Report to the user that a Gesture has been made
            lblCollectingStatus.Text = "Gesture Made Sketch";
		}

		private bool IsRunningOnTabletPC()
		{
			// Check to see if the application is running on a Tablet PC
			// MSDN Help GetSystemMetrics(86) 
			// Nonzero if the current operating system is the Windows XP Tablet PC edition,
			// 0 (zero) if not.

			if (Win32.GetSystemMetrics(SM_TABLETPC) != 0)
				return true;
			else
				return false;
		}



		private void radManual_CheckedChanged(object sender, System.EventArgs e)
		{
			//Manually committed ink sketch
			if (radManual.Checked)
			{
				tbrAutoComplete.Enabled = false;
				lblAutoComplete.Enabled = false;
				lbl1sec.Enabled = false;
				lbl10sec.Enabled = false;
				m_EngineInkEnvironment.ToolCommitType = esriEngineInkToolCommitType.esriEngineInkToolCommitTypeManual;
			}
		}

		private void radAutoGraphic_CheckedChanged(object sender, System.EventArgs e)
		{
			//Automatically commit and save as ink graphic
			if (radAutoGraphic.Checked)
			{
				tbrAutoComplete.Enabled = true;
				lblAutoComplete.Enabled = true;
				lbl1sec.Enabled = true;
				lbl10sec.Enabled = true;
				m_EngineInkEnvironment.ToolCommitType = esriEngineInkToolCommitType.esriEngineInkToolCommitTypeAutoGraphic;
				m_EngineInkEnvironment.ToolCommitDelay = tbrAutoComplete.Value;

			}
		}

		private void radAutoText_CheckedChanged(object sender, System.EventArgs e)
		{
            //Automatically commit and recognize as ink text
			//This is only available on a Tablet PC
			if (radAutoText.Checked)
			{            
				tbrAutoComplete.Enabled = true;
				lblAutoComplete.Enabled = true;
				lbl1sec.Enabled = true;
				lbl10sec.Enabled = true;
				m_EngineInkEnvironment.ToolCommitType = esriEngineInkToolCommitType.esriEngineInkToolCommitTypeAutoText;
				m_EngineInkEnvironment.ToolCommitDelay = tbrAutoComplete.Value;
			}
		}

        private void axMapControl1_OnAfterScreenDraw(object sender, IMapControlEvents2_OnAfterScreenDrawEvent e)
        {
            //Report to the user the number of Ink Sketches that are present

            IElement pElement;
            IGraphicsContainer pContainer;
            int i = 0;

            m_pMap = axMapControl1.Map;
            pContainer = (IGraphicsContainer)m_pMap;
            pContainer.Reset();
            pElement = pContainer.Next();

            while (pElement != null)
            {
                if (pElement is InkGraphic)
                    i = i + 1;
                pElement = pContainer.Next();
            }
            tbxNumber.Text = i.ToString();	
        }

        private void tbrAutoComplete_MouseUp(object sender, MouseEventArgs e)
        {
            //Set the ToolCommitDelay using the value of the TrackBar
            m_EngineInkEnvironment.ToolCommitDelay = tbrAutoComplete.Value;
        }

	}

	public class Win32 
	{
		[DllImport("user32.dll",EntryPoint="GetSystemMetrics")]
		public static extern int GetSystemMetrics(int abc);
	}
}

[Visual Basic .NET]

InkSketchCommit.vb

Imports ESRI.ArcGIS.Controls
Imports ESRI.ArcGIS.SystemUI
Imports ESRI.ArcGIS.ADF
Imports ESRI.ArcGIS.Geometry
Imports ESRI.ArcGIS.Carto
Imports ESRI.ArcGIS


Public Class Form1
    Inherits System.Windows.Forms.Form

    'Tablet PC system metric value used by GetSystemMetrics to identify whether the application
    'is running on a Tablet PC.
    Private Const SM_TABLETPC As Integer = 86
    'The GetSystemMetrics function retrieves system metrics and system configuration settings.
    Declare Function GetSystemMetrics Lib "user32" Alias "GetSystemMetrics" (ByVal nIndex As Integer) As Integer
    <STAThread()> _
Shared Sub Main()

        'Load runtime 
        If Not RuntimeManager.Bind(ProductCode.Engine) Then
            If Not RuntimeManager.Bind(ProductCode.Desktop) Then
                MessageBox.Show("Unable to bind to ArcGIS runtime. Application will be shut down.")
                System.Environment.Exit(1) ' Force exit or other indication in the application
            End If
        End If

        Application.Run(New Form1())
    End Sub

#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)
        ESRI.ArcGIS.ADF.COMSupport.AOUninitialize.Shutdown()
        m_EngineInkEnvironment = Nothing
        m_EngineInkEnvironmentEvents = Nothing
        m_Map = Nothing

        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.
  Friend WithEvents gpbInkSketch As System.Windows.Forms.GroupBox
  Friend WithEvents gpbReport As System.Windows.Forms.GroupBox
  Friend WithEvents lblCollectingStatus As System.Windows.Forms.Label
  Friend WithEvents Label1 As System.Windows.Forms.Label
  Friend WithEvents tbxNumber As System.Windows.Forms.TextBox
  Friend WithEvents lblInfo As System.Windows.Forms.Label
  Friend WithEvents radManual As System.Windows.Forms.RadioButton
  Friend WithEvents radAutoGraphic As System.Windows.Forms.RadioButton
  Friend WithEvents radAutoText As System.Windows.Forms.RadioButton
  Friend WithEvents tbrAutoComplete As System.Windows.Forms.TrackBar
  Friend WithEvents lblAutoComplete As System.Windows.Forms.Label
  Friend WithEvents lbl1sec As System.Windows.Forms.Label
  Friend WithEvents TableLayoutPanel1 As System.Windows.Forms.TableLayoutPanel
  Friend WithEvents AxMapControl1 As ESRI.ArcGIS.Controls.AxMapControl
  Friend WithEvents AxToolbarControl1 As ESRI.ArcGIS.Controls.AxToolbarControl
  Friend WithEvents AxLicenseControl1 As ESRI.ArcGIS.Controls.AxLicenseControl
  Friend WithEvents lbl10sec As System.Windows.Forms.Label
  <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Form1))
        Me.gpbInkSketch = New System.Windows.Forms.GroupBox
        Me.lbl10sec = New System.Windows.Forms.Label
        Me.lbl1sec = New System.Windows.Forms.Label
        Me.lblAutoComplete = New System.Windows.Forms.Label
        Me.tbrAutoComplete = New System.Windows.Forms.TrackBar
        Me.radAutoText = New System.Windows.Forms.RadioButton
        Me.radAutoGraphic = New System.Windows.Forms.RadioButton
        Me.radManual = New System.Windows.Forms.RadioButton
        Me.lblInfo = New System.Windows.Forms.Label
        Me.gpbReport = New System.Windows.Forms.GroupBox
        Me.tbxNumber = New System.Windows.Forms.TextBox
        Me.Label1 = New System.Windows.Forms.Label
        Me.lblCollectingStatus = New System.Windows.Forms.Label
        Me.TableLayoutPanel1 = New System.Windows.Forms.TableLayoutPanel
        Me.AxMapControl1 = New ESRI.ArcGIS.Controls.AxMapControl
        Me.AxToolbarControl1 = New ESRI.ArcGIS.Controls.AxToolbarControl
        Me.AxLicenseControl1 = New ESRI.ArcGIS.Controls.AxLicenseControl
        Me.gpbInkSketch.SuspendLayout()
        CType(Me.tbrAutoComplete, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.gpbReport.SuspendLayout()
        Me.TableLayoutPanel1.SuspendLayout()
        CType(Me.AxMapControl1, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.AxToolbarControl1, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.AxLicenseControl1, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'gpbInkSketch
        '
        Me.gpbInkSketch.Controls.Add(Me.lbl10sec)
        Me.gpbInkSketch.Controls.Add(Me.lbl1sec)
        Me.gpbInkSketch.Controls.Add(Me.lblAutoComplete)
        Me.gpbInkSketch.Controls.Add(Me.tbrAutoComplete)
        Me.gpbInkSketch.Controls.Add(Me.radAutoText)
        Me.gpbInkSketch.Controls.Add(Me.radAutoGraphic)
        Me.gpbInkSketch.Controls.Add(Me.radManual)
        Me.gpbInkSketch.Controls.Add(Me.lblInfo)
        Me.gpbInkSketch.Location = New System.Drawing.Point(364, 32)
        Me.gpbInkSketch.Name = "gpbInkSketch"
        Me.gpbInkSketch.Size = New System.Drawing.Size(250, 317)
        Me.gpbInkSketch.TabIndex = 3
        Me.gpbInkSketch.TabStop = False
        Me.gpbInkSketch.Text = "Ink Sketch Commit Options"
        '
        'lbl10sec
        '
        Me.lbl10sec.Location = New System.Drawing.Point(173, 263)
        Me.lbl10sec.Name = "lbl10sec"
        Me.lbl10sec.Size = New System.Drawing.Size(54, 14)
        Me.lbl10sec.TabIndex = 7
        Me.lbl10sec.Text = "(10 sec)"
        '
        'lbl1sec
        '
        Me.lbl1sec.Location = New System.Drawing.Point(7, 263)
        Me.lbl1sec.Name = "lbl1sec"
        Me.lbl1sec.Size = New System.Drawing.Size(46, 14)
        Me.lbl1sec.TabIndex = 6
        Me.lbl1sec.Text = "(1 sec)"
        '
        'lblAutoComplete
        '
        Me.lblAutoComplete.Location = New System.Drawing.Point(20, 208)
        Me.lblAutoComplete.Name = "lblAutoComplete"
        Me.lblAutoComplete.Size = New System.Drawing.Size(220, 20)
        Me.lblAutoComplete.TabIndex = 5
        Me.lblAutoComplete.Text = "Automatically Commit the Ink Sketch after:"
        '
        'tbrAutoComplete
        '
        Me.tbrAutoComplete.Location = New System.Drawing.Point(7, 229)
        Me.tbrAutoComplete.Minimum = 1
        Me.tbrAutoComplete.Name = "tbrAutoComplete"
        Me.tbrAutoComplete.Size = New System.Drawing.Size(220, 42)
        Me.tbrAutoComplete.TabIndex = 4
        Me.tbrAutoComplete.Value = 1
        '
        'radAutoText
        '
        Me.radAutoText.Location = New System.Drawing.Point(13, 153)
        Me.radAutoText.Name = "radAutoText"
        Me.radAutoText.Size = New System.Drawing.Size(220, 34)
        Me.radAutoText.TabIndex = 3
        Me.radAutoText.Text = "Automatically Committed and Recognized as Text (Tablet PC only)"
        '
        'radAutoGraphic
        '
        Me.radAutoGraphic.Location = New System.Drawing.Point(13, 125)
        Me.radAutoGraphic.Name = "radAutoGraphic"
        Me.radAutoGraphic.Size = New System.Drawing.Size(207, 21)
        Me.radAutoGraphic.TabIndex = 2
        Me.radAutoGraphic.Text = "Automatically Committed to Graphic"
        '
        'radManual
        '
        Me.radManual.Location = New System.Drawing.Point(13, 97)
        Me.radManual.Name = "radManual"
        Me.radManual.Size = New System.Drawing.Size(180, 21)
        Me.radManual.TabIndex = 1
        Me.radManual.Text = "Manually Committed"
        '
        'lblInfo
        '
        Me.lblInfo.Location = New System.Drawing.Point(13, 35)
        Me.lblInfo.Name = "lblInfo"
        Me.lblInfo.Size = New System.Drawing.Size(220, 48)
        Me.lblInfo.TabIndex = 0
        Me.lblInfo.Text = "Ink sketches can be committed manually or automatically. Click on the buttons belo" & _
            "w to change the commit method."
        '
        'gpbReport
        '
        Me.gpbReport.Controls.Add(Me.tbxNumber)
        Me.gpbReport.Controls.Add(Me.Label1)
        Me.gpbReport.Controls.Add(Me.lblCollectingStatus)
        Me.gpbReport.Location = New System.Drawing.Point(364, 355)
        Me.gpbReport.Name = "gpbReport"
        Me.gpbReport.Size = New System.Drawing.Size(246, 98)
        Me.gpbReport.TabIndex = 4
        Me.gpbReport.TabStop = False
        Me.gpbReport.Text = "Sketch Report"
        '
        'tbxNumber
        '
        Me.tbxNumber.BackColor = System.Drawing.SystemColors.Control
        Me.tbxNumber.BorderStyle = System.Windows.Forms.BorderStyle.None
        Me.tbxNumber.Location = New System.Drawing.Point(147, 28)
        Me.tbxNumber.Name = "tbxNumber"
        Me.tbxNumber.ReadOnly = True
        Me.tbxNumber.Size = New System.Drawing.Size(93, 13)
        Me.tbxNumber.TabIndex = 2
        Me.tbxNumber.Text = "0"
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(7, 28)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(140, 14)
        Me.Label1.TabIndex = 1
        Me.Label1.Text = "Number of Ink Sketches = "
        '
        'lblCollectingStatus
        '
        Me.lblCollectingStatus.Location = New System.Drawing.Point(7, 62)
        Me.lblCollectingStatus.Name = "lblCollectingStatus"
        Me.lblCollectingStatus.Size = New System.Drawing.Size(233, 14)
        Me.lblCollectingStatus.TabIndex = 0
        '
        'TableLayoutPanel1
        '
        Me.TableLayoutPanel1.ColumnCount = 2
        Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 57.85257!))
        Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 42.14743!))
        Me.TableLayoutPanel1.Controls.Add(Me.gpbInkSketch, 1, 1)
        Me.TableLayoutPanel1.Controls.Add(Me.AxMapControl1, 0, 1)
        Me.TableLayoutPanel1.Controls.Add(Me.AxToolbarControl1, 0, 0)
        Me.TableLayoutPanel1.Controls.Add(Me.gpbReport, 1, 2)
        Me.TableLayoutPanel1.Controls.Add(Me.AxLicenseControl1, 0, 2)
        Me.TableLayoutPanel1.Location = New System.Drawing.Point(2, 2)
        Me.TableLayoutPanel1.Name = "TableLayoutPanel1"
        Me.TableLayoutPanel1.RowCount = 3
        Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 8.275862!))
        Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 91.72414!))
        Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 103.0!))
        Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20.0!))
        Me.TableLayoutPanel1.Size = New System.Drawing.Size(624, 456)
        Me.TableLayoutPanel1.TabIndex = 5
        '
        'AxMapControl1
        '
        Me.AxMapControl1.Location = New System.Drawing.Point(3, 32)
        Me.AxMapControl1.Name = "AxMapControl1"
        Me.AxMapControl1.OcxState = CType(resources.GetObject("AxMapControl1.OcxState"), System.Windows.Forms.AxHost.State)
        Me.AxMapControl1.Size = New System.Drawing.Size(355, 317)
        Me.AxMapControl1.TabIndex = 7
        '
        'AxToolbarControl1
        '
        Me.TableLayoutPanel1.SetColumnSpan(Me.AxToolbarControl1, 2)
        Me.AxToolbarControl1.Location = New System.Drawing.Point(3, 3)
        Me.AxToolbarControl1.Name = "AxToolbarControl1"
        Me.AxToolbarControl1.OcxState = CType(resources.GetObject("AxToolbarControl1.OcxState"), System.Windows.Forms.AxHost.State)
        Me.AxToolbarControl1.Size = New System.Drawing.Size(618, 28)
        Me.AxToolbarControl1.TabIndex = 6
        '
        'AxLicenseControl1
        '
        Me.AxLicenseControl1.Enabled = True
        Me.AxLicenseControl1.Location = New System.Drawing.Point(3, 355)
        Me.AxLicenseControl1.Name = "AxLicenseControl1"
        Me.AxLicenseControl1.OcxState = CType(resources.GetObject("AxLicenseControl1.OcxState"), System.Windows.Forms.AxHost.State)
        Me.AxLicenseControl1.Size = New System.Drawing.Size(32, 32)
        Me.AxLicenseControl1.TabIndex = 8
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(638, 476)
        Me.Controls.Add(Me.TableLayoutPanel1)
        Me.MaximumSize = New System.Drawing.Size(646, 503)
        Me.MinimumSize = New System.Drawing.Size(646, 503)
        Me.Name = "Form1"
        Me.Text = "Ink Sketch Commit"
        Me.gpbInkSketch.ResumeLayout(False)
        Me.gpbInkSketch.PerformLayout()
        CType(Me.tbrAutoComplete, System.ComponentModel.ISupportInitialize).EndInit()
        Me.gpbReport.ResumeLayout(False)
        Me.gpbReport.PerformLayout()
        Me.TableLayoutPanel1.ResumeLayout(False)
        CType(Me.AxMapControl1, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.AxToolbarControl1, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.AxLicenseControl1, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub

#End Region

  Private m_EngineInkEnvironment As ESRI.ArcGIS.Controls.IEngineInkEnvironment
  Private WithEvents m_EngineInkEnvironmentEvents As ESRI.ArcGIS.Controls.EngineInkEnvironment
  Private m_Map As IMap

  Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load

    'Set buddy control 
    AxToolbarControl1.SetBuddyControl(AxMapControl1)

    'Add items to the ToolbarControl
    AxToolbarControl1.AddItem("esriControls.ControlsOpenDocCommand", 0, -1, False, 0, esriCommandStyles.esriCommandStyleIconOnly)
    AxToolbarControl1.AddItem("esriControls.ControlsSaveAsDocCommand", 0, -1, False, 0, esriCommandStyles.esriCommandStyleIconOnly)
    AxToolbarControl1.AddItem("esriControls.ControlsInkToolbar", 0, -1, True, 0, esriCommandStyles.esriCommandStyleIconOnly)
    AxToolbarControl1.AddItem("esriControls.ControlsMapZoomInTool", 0, -1, True, 0, esriCommandStyles.esriCommandStyleIconOnly)
    AxToolbarControl1.AddItem("esriControls.ControlsMapZoomOutTool", 0, -1, False, 0, esriCommandStyles.esriCommandStyleIconOnly)
    AxToolbarControl1.AddItem("esriControls.ControlsMapFullExtentCommand", 0, -1, False, 0, esriCommandStyles.esriCommandStyleIconOnly)
    AxToolbarControl1.AddItem("esriControls.ControlsSelectTool", 0, -1, False, 0, esriCommandStyles.esriCommandStyleIconOnly)

    'Set the EngineInkEnviroment Singleton
    m_EngineInkEnvironment = New EngineInkEnvironmentClass
    m_EngineInkEnvironmentEvents = m_EngineInkEnvironment

    'Set the Ink Tool commit type to be manual
    m_EngineInkEnvironment.ToolCommitType = esriEngineInkToolCommitType.esriEngineInkToolCommitTypeManual

    'Set the Form Controls 
    tbrAutoComplete.Enabled = False
    tbrAutoComplete.Minimum = 1
    tbrAutoComplete.Maximum = 10
    tbrAutoComplete.TickFrequency = 1
    tbrAutoComplete.TickStyle = TickStyle.BottomRight
    lblAutoComplete.Enabled = False
    lbl1sec.Enabled = False
    lbl10sec.Enabled = False
    lblCollectingStatus.Text = "Not Collecting Ink"
    tbxNumber.Text = "0"
    radManual.Checked = True

    'The radAutoText Radio button is only available on a Tablet PC.
    'Converting ink to text requires a Recognizer which can only 
    'run on Windows XP Tablet PC Edition.
    If IsRunningOnTabletPC() Then
      radAutoText.Enabled = True
    Else
      radAutoText.Enabled = False
    End If

  End Sub

  Private Sub tbrAutoComplete_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles tbrAutoComplete.MouseUp
    'Set the ToolCommitDelay using the value of the TrackBar
    m_EngineInkEnvironment.ToolCommitDelay = tbrAutoComplete.Value
  End Sub

  Private Sub m_EngineInkEnvironmentEvents_OnStop() Handles m_EngineInkEnvironmentEvents.OnStop
    'Report to the user the mode of the Ink Collector
    lblCollectingStatus.Text = "Not Collecting Ink Sketch"
  End Sub

  Private Sub m_EngineInkEnvironmentEvents_OnStart() Handles m_EngineInkEnvironmentEvents.OnStart

    'Report to the user the mode of the Ink Collector
    lblCollectingStatus.Text = "Collecting Ink Sketch"
  End Sub

  Private Sub m_EngineInkEnvironmentEvents_OnGesture(ByVal gestureType As ESRI.ArcGIS.Controls.esriEngineInkGesture, ByVal hotPoint As Object) Handles m_EngineInkEnvironmentEvents.OnGesture

    'Report to the user that a Gesture has been made
    lblCollectingStatus.Text = "Gesture Made Sketch"

  End Sub

  Private Sub AxMapControl1_OnAfterScreenDraw(ByVal sender As Object, ByVal e As ESRI.ArcGIS.Controls.IMapControlEvents2_OnAfterScreenDrawEvent) Handles AxMapControl1.OnAfterScreenDraw

    'Report to the user the number of Ink Sketches that are present
    Dim pElement As IElement
    Dim pContainer As IGraphicsContainer
    Dim i As Integer = 0

    m_Map = AxMapControl1.Map
    pContainer = m_Map
    pContainer.Reset()
    pElement = pContainer.Next

    Do While Not pElement Is Nothing
      If TypeOf pElement Is InkGraphic Then
        i = i + 1
      End If
      pElement = pContainer.Next
    Loop
    tbxNumber.Text = i.ToString

  End Sub

  Private Sub radManual_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radManual.CheckedChanged

    'Manually committed ink sketch
    If radManual.Checked Then
      tbrAutoComplete.Enabled = False
      lblAutoComplete.Enabled = False
      lbl1sec.Enabled = False
      lbl10sec.Enabled = False
      m_EngineInkEnvironment.ToolCommitType = esriEngineInkToolCommitType.esriEngineInkToolCommitTypeManual
    End If

  End Sub

  Private Sub radAutoGraphic_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles radAutoGraphic.CheckedChanged

    'Automatically commit and save as ink graphic
    If radAutoGraphic.Checked Then
      tbrAutoComplete.Enabled = True
      lblAutoComplete.Enabled = True
      lbl1sec.Enabled = True
      lbl10sec.Enabled = True
      m_EngineInkEnvironment.ToolCommitType = esriEngineInkToolCommitType.esriEngineInkToolCommitTypeAutoGraphic
      m_EngineInkEnvironment.ToolCommitDelay = tbrAutoComplete.Value
    End If

  End Sub

  Private Sub radAutoText_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles radAutoText.CheckedChanged

        'Automatically commit and recognize as ink text
    'This is only available on a Tablet PC
    If radAutoText.Checked Then
      tbrAutoComplete.Enabled = True
      lblAutoComplete.Enabled = True
      lbl1sec.Enabled = True
      lbl10sec.Enabled = True
      m_EngineInkEnvironment.ToolCommitType = esriEngineInkToolCommitType.esriEngineInkToolCommitTypeAutoText
      m_EngineInkEnvironment.ToolCommitDelay = tbrAutoComplete.Value
    End If

  End Sub

    Private Function IsRunningOnTabletPC() As Boolean

        ' Check to see if the application is running on a Tablet PC
        ' MSDN Help GetSystemMetrics(86) 
        ' Nonzero if the current operating system is the Windows XP Tablet PC edition,
        ' 0 (zero) if not.

        IsRunningOnTabletPC = False

        If GetSystemMetrics(SM_TABLETPC) <> 0 Then
            IsRunningOnTabletPC = True
        End If

    End Function
End Class