ArcObjects Library Reference  

MapTools

About the ArcReaderControl map tools Sample

[C#]

MapTools.cs

using System;
using System.Windows.Forms;
using ESRI.ArcGIS.PublisherControls;

namespace MapTools
{
	/// <summary>
	/// Summary description for Form1.
	/// </summary>
	public class MapTools : System.Windows.Forms.Form
	{
		public System.Windows.Forms.Button cmdLoad;
		public System.Windows.Forms.TextBox txbPath;
		public System.Windows.Forms.Label _Label3_1;
		public System.Windows.Forms.Label Label6;
		public System.Windows.Forms.Label Label4;
		public System.Windows.Forms.Label _Label3_0;
		public System.Windows.Forms.Label Label2;
		public System.Windows.Forms.Button cmdRedo;
		public System.Windows.Forms.Button cmdUndo;
		public System.Windows.Forms.Button cmdFullExtent;
		public System.Windows.Forms.RadioButton optTool2;
		public System.Windows.Forms.RadioButton optTool1;
		public System.Windows.Forms.RadioButton optTool0;
		private esriARTool arTool;
			private ESRI.ArcGIS.PublisherControls.AxArcReaderControl axArcReaderControl1;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public MapTools()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			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.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(MapTools));
				this.cmdLoad = new System.Windows.Forms.Button();
				this.txbPath = new System.Windows.Forms.TextBox();
				this._Label3_1 = new System.Windows.Forms.Label();
				this.Label6 = new System.Windows.Forms.Label();
				this.Label4 = new System.Windows.Forms.Label();
				this._Label3_0 = new System.Windows.Forms.Label();
				this.Label2 = new System.Windows.Forms.Label();
				this.cmdRedo = new System.Windows.Forms.Button();
				this.cmdUndo = new System.Windows.Forms.Button();
				this.cmdFullExtent = new System.Windows.Forms.Button();
				this.optTool2 = new System.Windows.Forms.RadioButton();
				this.optTool1 = new System.Windows.Forms.RadioButton();
				this.optTool0 = new System.Windows.Forms.RadioButton();
				this.axArcReaderControl1 = new ESRI.ArcGIS.PublisherControls.AxArcReaderControl();
				((System.ComponentModel.ISupportInitialize)(this.axArcReaderControl1)).BeginInit();
				this.SuspendLayout();
				// 
				// cmdLoad
				// 
				this.cmdLoad.BackColor = System.Drawing.SystemColors.Control;
				this.cmdLoad.Cursor = System.Windows.Forms.Cursors.Default;
				this.cmdLoad.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
				this.cmdLoad.ForeColor = System.Drawing.SystemColors.ControlText;
				this.cmdLoad.Location = new System.Drawing.Point(392, 8);
				this.cmdLoad.Name = "cmdLoad";
				this.cmdLoad.RightToLeft = System.Windows.Forms.RightToLeft.No;
				this.cmdLoad.Size = new System.Drawing.Size(81, 25);
				this.cmdLoad.TabIndex = 4;
				this.cmdLoad.Text = "Load PMF";
				this.cmdLoad.Click += new System.EventHandler(this.cmdLoad_Click);
				// 
				// txbPath
				// 
				this.txbPath.AcceptsReturn = true;
				this.txbPath.AutoSize = false;
				this.txbPath.BackColor = System.Drawing.SystemColors.Window;
				this.txbPath.Cursor = System.Windows.Forms.Cursors.IBeam;
				this.txbPath.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
				this.txbPath.ForeColor = System.Drawing.SystemColors.WindowText;
				this.txbPath.Location = new System.Drawing.Point(8, 8);
				this.txbPath.MaxLength = 0;
				this.txbPath.Name = "txbPath";
				this.txbPath.RightToLeft = System.Windows.Forms.RightToLeft.No;
				this.txbPath.Size = new System.Drawing.Size(377, 25);
				this.txbPath.TabIndex = 3;
				this.txbPath.Text = "";
				// 
				// _Label3_1
				// 
				this._Label3_1.BackColor = System.Drawing.SystemColors.Control;
				this._Label3_1.Cursor = System.Windows.Forms.Cursors.Default;
				this._Label3_1.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
				this._Label3_1.ForeColor = System.Drawing.SystemColors.Highlight;
				this._Label3_1.Location = new System.Drawing.Point(488, 120);
				this._Label3_1.Name = "_Label3_1";
				this._Label3_1.RightToLeft = System.Windows.Forms.RightToLeft.No;
				this._Label3_1.Size = new System.Drawing.Size(201, 33);
				this._Label3_1.TabIndex = 17;
				this._Label3_1.Text = "4) Use the \'Layout\' button to display the layout view. ";
				// 
				// Label6
				// 
				this.Label6.BackColor = System.Drawing.SystemColors.Control;
				this.Label6.Cursor = System.Windows.Forms.Cursors.Default;
				this.Label6.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
				this.Label6.ForeColor = System.Drawing.SystemColors.Highlight;
				this.Label6.Location = new System.Drawing.Point(488, 160);
				this.Label6.Name = "Label6";
				this.Label6.RightToLeft = System.Windows.Forms.RightToLeft.No;
				this.Label6.Size = new System.Drawing.Size(201, 56);
				this.Label6.TabIndex = 16;
				this.Label6.Text = "5) Use the \'tools below to navigate the data within any of the data frames on the" +
						" page layout.";
				// 
				// Label4
				// 
				this.Label4.BackColor = System.Drawing.SystemColors.Control;
				this.Label4.Cursor = System.Windows.Forms.Cursors.Default;
				this.Label4.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
				this.Label4.ForeColor = System.Drawing.SystemColors.Highlight;
				this.Label4.Location = new System.Drawing.Point(488, 80);
				this.Label4.Name = "Label4";
				this.Label4.RightToLeft = System.Windows.Forms.RightToLeft.No;
				this.Label4.Size = new System.Drawing.Size(201, 33);
				this.Label4.TabIndex = 15;
				this.Label4.Text = "3) Use the tools below to navigate the focus map.";
				// 
				// _Label3_0
				// 
				this._Label3_0.BackColor = System.Drawing.SystemColors.Control;
				this._Label3_0.Cursor = System.Windows.Forms.Cursors.Default;
				this._Label3_0.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
				this._Label3_0.ForeColor = System.Drawing.SystemColors.Highlight;
				this._Label3_0.Location = new System.Drawing.Point(488, 40);
				this._Label3_0.Name = "_Label3_0";
				this._Label3_0.RightToLeft = System.Windows.Forms.RightToLeft.No;
				this._Label3_0.Size = new System.Drawing.Size(201, 33);
				this._Label3_0.TabIndex = 14;
				this._Label3_0.Text = "2) Use the \'Map\' button to display the data view. ";
				// 
				// Label2
				// 
				this.Label2.BackColor = System.Drawing.SystemColors.Control;
				this.Label2.Cursor = System.Windows.Forms.Cursors.Default;
				this.Label2.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
				this.Label2.ForeColor = System.Drawing.SystemColors.Highlight;
				this.Label2.Location = new System.Drawing.Point(488, 8);
				this.Label2.Name = "Label2";
				this.Label2.RightToLeft = System.Windows.Forms.RightToLeft.No;
				this.Label2.Size = new System.Drawing.Size(201, 33);
				this.Label2.TabIndex = 13;
				this.Label2.Text = "1) Enter a valid file path and load the PMF.";
				// 
				// cmdRedo
				// 
				this.cmdRedo.BackColor = System.Drawing.SystemColors.Control;
				this.cmdRedo.Cursor = System.Windows.Forms.Cursors.Default;
				this.cmdRedo.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
				this.cmdRedo.ForeColor = System.Drawing.SystemColors.ControlText;
				this.cmdRedo.ImageAlign = System.Drawing.ContentAlignment.BottomCenter;
				this.cmdRedo.Location = new System.Drawing.Point(632, 288);
				this.cmdRedo.Name = "cmdRedo";
				this.cmdRedo.RightToLeft = System.Windows.Forms.RightToLeft.No;
				this.cmdRedo.Size = new System.Drawing.Size(64, 49);
				this.cmdRedo.TabIndex = 23;
				this.cmdRedo.Text = "Redo";
				this.cmdRedo.TextAlign = System.Drawing.ContentAlignment.TopCenter;
				this.cmdRedo.Click += new System.EventHandler(this.cmdRedo_Click);
				// 
				// cmdUndo
				// 
				this.cmdUndo.BackColor = System.Drawing.SystemColors.Control;
				this.cmdUndo.Cursor = System.Windows.Forms.Cursors.Default;
				this.cmdUndo.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
				this.cmdUndo.ForeColor = System.Drawing.SystemColors.ControlText;
				this.cmdUndo.ImageAlign = System.Drawing.ContentAlignment.BottomCenter;
				this.cmdUndo.Location = new System.Drawing.Point(560, 288);
				this.cmdUndo.Name = "cmdUndo";
				this.cmdUndo.RightToLeft = System.Windows.Forms.RightToLeft.No;
				this.cmdUndo.Size = new System.Drawing.Size(64, 49);
				this.cmdUndo.TabIndex = 22;
				this.cmdUndo.Text = "Undo";
				this.cmdUndo.TextAlign = System.Drawing.ContentAlignment.TopCenter;
				this.cmdUndo.Click += new System.EventHandler(this.cmdUndo_Click);
				// 
				// cmdFullExtent
				// 
				this.cmdFullExtent.BackColor = System.Drawing.SystemColors.Control;
				this.cmdFullExtent.Cursor = System.Windows.Forms.Cursors.Default;
				this.cmdFullExtent.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
				this.cmdFullExtent.ForeColor = System.Drawing.SystemColors.ControlText;
				this.cmdFullExtent.ImageAlign = System.Drawing.ContentAlignment.BottomCenter;
				this.cmdFullExtent.Location = new System.Drawing.Point(488, 288);
				this.cmdFullExtent.Name = "cmdFullExtent";
				this.cmdFullExtent.RightToLeft = System.Windows.Forms.RightToLeft.No;
				this.cmdFullExtent.Size = new System.Drawing.Size(64, 49);
				this.cmdFullExtent.TabIndex = 21;
				this.cmdFullExtent.Text = "FullExtent";
				this.cmdFullExtent.TextAlign = System.Drawing.ContentAlignment.TopCenter;
				this.cmdFullExtent.Click += new System.EventHandler(this.cmdFullExtent_Click);
				// 
				// optTool2
				// 
				this.optTool2.Appearance = System.Windows.Forms.Appearance.Button;
				this.optTool2.BackColor = System.Drawing.SystemColors.Control;
				this.optTool2.Cursor = System.Windows.Forms.Cursors.Default;
				this.optTool2.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
				this.optTool2.ForeColor = System.Drawing.SystemColors.ControlText;
				this.optTool2.ImageAlign = System.Drawing.ContentAlignment.BottomCenter;
				this.optTool2.Location = new System.Drawing.Point(632, 232);
				this.optTool2.Name = "optTool2";
				this.optTool2.RightToLeft = System.Windows.Forms.RightToLeft.No;
				this.optTool2.Size = new System.Drawing.Size(64, 49);
				this.optTool2.TabIndex = 18;
				this.optTool2.TabStop = true;
				this.optTool2.Text = "Pan";
				this.optTool2.TextAlign = System.Drawing.ContentAlignment.TopCenter;
				this.optTool2.Click += new System.EventHandler(this.MixedControls_Click);
				// 
				// optTool1
				// 
				this.optTool1.Appearance = System.Windows.Forms.Appearance.Button;
				this.optTool1.BackColor = System.Drawing.SystemColors.Control;
				this.optTool1.Cursor = System.Windows.Forms.Cursors.Default;
				this.optTool1.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
				this.optTool1.ForeColor = System.Drawing.SystemColors.ControlText;
				this.optTool1.ImageAlign = System.Drawing.ContentAlignment.BottomCenter;
				this.optTool1.Location = new System.Drawing.Point(560, 232);
				this.optTool1.Name = "optTool1";
				this.optTool1.RightToLeft = System.Windows.Forms.RightToLeft.No;
				this.optTool1.Size = new System.Drawing.Size(64, 49);
				this.optTool1.TabIndex = 20;
				this.optTool1.TabStop = true;
				this.optTool1.Text = "ZoomOut";
				this.optTool1.TextAlign = System.Drawing.ContentAlignment.TopCenter;
				this.optTool1.Click += new System.EventHandler(this.MixedControls_Click);
				// 
				// optTool0
				// 
				this.optTool0.Appearance = System.Windows.Forms.Appearance.Button;
				this.optTool0.BackColor = System.Drawing.SystemColors.Control;
				this.optTool0.Cursor = System.Windows.Forms.Cursors.Default;
				this.optTool0.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
				this.optTool0.ForeColor = System.Drawing.SystemColors.ControlText;
				this.optTool0.ImageAlign = System.Drawing.ContentAlignment.BottomCenter;
				this.optTool0.Location = new System.Drawing.Point(488, 232);
				this.optTool0.Name = "optTool0";
				this.optTool0.RightToLeft = System.Windows.Forms.RightToLeft.No;
				this.optTool0.Size = new System.Drawing.Size(64, 49);
				this.optTool0.TabIndex = 19;
				this.optTool0.TabStop = true;
				this.optTool0.Text = "ZoomIn";
				this.optTool0.TextAlign = System.Drawing.ContentAlignment.TopCenter;
				this.optTool0.Click += new System.EventHandler(this.MixedControls_Click);
				// 
				// axArcReaderControl1
				// 
				this.axArcReaderControl1.Location = new System.Drawing.Point(8, 40);
				this.axArcReaderControl1.Name = "axArcReaderControl1";
				this.axArcReaderControl1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axArcReaderControl1.OcxState")));
				this.axArcReaderControl1.Size = new System.Drawing.Size(464, 432);
				this.axArcReaderControl1.TabIndex = 24;
				this.axArcReaderControl1.OnAfterScreenDraw += new System.EventHandler(this.axArcReaderControl1_OnAfterScreenDraw);
				this.axArcReaderControl1.OnCurrentViewChanged += new ESRI.ArcGIS.PublisherControls.IARControlEvents_Ax_OnCurrentViewChangedEventHandler(this.axArcReaderControl1_OnCurrentViewChanged);
				// 
				// Form1
				// 
				this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
				this.ClientSize = new System.Drawing.Size(704, 478);
				this.Controls.Add(this.axArcReaderControl1);
				this.Controls.Add(this.cmdRedo);
				this.Controls.Add(this.cmdUndo);
				this.Controls.Add(this.cmdFullExtent);
				this.Controls.Add(this.optTool2);
				this.Controls.Add(this.optTool1);
				this.Controls.Add(this.optTool0);
				this.Controls.Add(this._Label3_1);
				this.Controls.Add(this.Label6);
				this.Controls.Add(this.Label4);
				this.Controls.Add(this._Label3_0);
				this.Controls.Add(this.Label2);
				this.Controls.Add(this.cmdLoad);
				this.Controls.Add(this.txbPath);
				this.Name = "Form1";
				this.Text = "Form1";
				this.Closing += new System.ComponentModel.CancelEventHandler(this.Form1_Closing);
				this.Load += new System.EventHandler(this.Form1_Load);
				((System.ComponentModel.ISupportInitialize)(this.axArcReaderControl1)).EndInit();
				this.ResumeLayout(false);

		}
		#endregion

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

            Application.Run(new MapTools());
		}

		private void Form1_Load(object sender, System.EventArgs e)
		{
			//Load option/command button images
			System.Drawing.Bitmap bitmap1 = new System.Drawing.Bitmap (GetType().Assembly.GetManifestResourceStream(GetType(), "ZoomIn.bmp"));
			bitmap1.MakeTransparent(System.Drawing.Color.Teal);
			optTool0.Image = bitmap1;
			System.Drawing.Bitmap bitmap2 = new System.Drawing.Bitmap (GetType().Assembly.GetManifestResourceStream(GetType(), "ZoomOut.bmp"));
			bitmap2.MakeTransparent(System.Drawing.Color.Teal);
			optTool1.Image = bitmap2;
			System.Drawing.Bitmap bitmap3 = new System.Drawing.Bitmap (GetType().Assembly.GetManifestResourceStream(GetType(), "Pan.bmp"));
			bitmap3.MakeTransparent(System.Drawing.Color.Teal);
			optTool2.Image = bitmap3;		
			System.Drawing.Bitmap bitmap4 = new System.Drawing.Bitmap (GetType().Assembly.GetManifestResourceStream(GetType(), "FullExtent.bmp"));
			bitmap4.MakeTransparent(System.Drawing.Color.Teal);
			cmdFullExtent.Image = bitmap4;
			System.Drawing.Bitmap bitmap5 = new System.Drawing.Bitmap (GetType().Assembly.GetManifestResourceStream(GetType(), "UnDoDraw.bmp"));
			bitmap5.MakeTransparent(System.Drawing.Color.Teal);
			cmdUndo.Image = bitmap5;
			System.Drawing.Bitmap bitmap6 = new System.Drawing.Bitmap (GetType().Assembly.GetManifestResourceStream(GetType(), "ReDoDraw.bmp"));
			bitmap6.MakeTransparent(System.Drawing.Color.Teal);
			cmdRedo.Image = bitmap6;

			//Disable controls
			optTool0.Enabled = false;
			optTool1.Enabled = false;
			optTool2.Enabled = false;
			cmdUndo.Enabled = false;
			cmdRedo.Enabled = false;
			cmdFullExtent.Enabled = false;
		}

		private void cmdFullExtent_Click(object sender, System.EventArgs e)
		{
			//Set extent to full data extent
			double xMax = 0;
			double xMin = 0;
			double yMin = 0;
			double yMax = 0;
			axArcReaderControl1.ARPageLayout.FocusARMap.GetFullExtent(ref xMin, ref yMin, ref xMax, ref yMax);
			axArcReaderControl1.ARPageLayout.FocusARMap.SetExtent(xMin, yMin, xMax, yMax);
			//Refresh the display
			axArcReaderControl1.ARPageLayout.FocusARMap.Refresh(true);
		}

		private void cmdLoad_Click(object sender, System.EventArgs e)
		{
			//Load the specified pmf
			if (txbPath.Text == "")
			{
				return;
			}   
			if (axArcReaderControl1.CheckDocument(txbPath.Text) == true) 
			{
				axArcReaderControl1.LoadDocument(txbPath.Text,"");
			}
			else
			{
				MessageBox.Show("This document cannot be loaded!");
				return;
			}

			optTool0.Checked = true;
		}

		private void cmdRedo_Click(object sender, System.EventArgs e)
		{
			//Redo extent
			axArcReaderControl1.ARPageLayout.FocusARMap.RedoExtent();
		}

		private void cmdUndo_Click(object sender, System.EventArgs e)
		{
			//Undo extent
			axArcReaderControl1.ARPageLayout.FocusARMap.UndoExtent();
		}

		private void axArcReaderControl1_OnAfterScreenDraw(object sender, System.EventArgs e)
		{
			//Determine whether can undo/redo extent and enable/disbale control
			cmdUndo.Enabled = axArcReaderControl1.ARPageLayout.FocusARMap.CanUndoExtent;
			cmdRedo.Enabled = axArcReaderControl1.ARPageLayout.FocusARMap.CanRedoExtent; 
		}

		private void axArcReaderControl1_OnCurrentViewChanged(object sender, ESRI.ArcGIS.PublisherControls.IARControlEvents_OnCurrentViewChangedEvent e)
		{

			bool bEnabled = false;
			//Determine view type
			if (axArcReaderControl1.CurrentViewType != esriARViewType.esriARViewTypeNone)
			{
				bEnabled = true;
				//Update the current tool if necessary
				if (axArcReaderControl1.CurrentARTool != arTool)
				{
					axArcReaderControl1.CurrentARTool = arTool;
				}
			}

			//Enable/ disable controls
			optTool0.Enabled = bEnabled;
			optTool1.Enabled = bEnabled;
			optTool2.Enabled = bEnabled;
			cmdFullExtent.Enabled = bEnabled;
		}

		private void MixedControls_Click(object sender, System.EventArgs e)
		{
			RadioButton b = (RadioButton) sender;
			//Set current tool
			switch (b.Name)
			{
				case "optTool0":
					axArcReaderControl1.CurrentARTool = esriARTool.esriARToolMapZoomIn;
					break;
				case "optTool1":
					axArcReaderControl1.CurrentARTool = esriARTool.esriARToolMapZoomOut;
					break;
				case "optTool2":
					axArcReaderControl1.CurrentARTool = esriARTool.esriARToolMapPan;
					break;
			}

			//Remember the current tool
			arTool = axArcReaderControl1.CurrentARTool;
		}

		private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
		{
			//Release COM objects
			ESRI.ArcGIS.ADF.COMSupport.AOUninitialize.Shutdown();
		}
	}
}

[Visual Basic .NET]

MapTools.vb

Imports ESRI.ArcGIS.PublisherControls
Imports ESRI.ArcGIS

Public Class MapTools
    Inherits System.Windows.Forms.Form
#Region "Windows Form Designer generated code "
    Public Sub New()
        MyBase.New()
        'Load runtime 
        If Not RuntimeManager.Bind(ProductCode.ArcReader) Then
            If Not RuntimeManager.Bind(ProductCode.EngineOrDesktop) Then
                MessageBox.Show("Unable to bind to ArcGIS runtime. Application will be shut down.")
                System.Environment.Exit(1) ' Force exit 
            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 cmdRedo As System.Windows.Forms.Button
    Public WithEvents cmdUndo As System.Windows.Forms.Button
    Public WithEvents cmdFullExtent As System.Windows.Forms.Button
    Public WithEvents cmdLoad As System.Windows.Forms.Button
    Public WithEvents txbPath As System.Windows.Forms.TextBox
    Public WithEvents _Label3_1 As System.Windows.Forms.Label
    Public WithEvents Label6 As System.Windows.Forms.Label
    Public WithEvents Label4 As System.Windows.Forms.Label
    Public WithEvents _Label3_0 As System.Windows.Forms.Label
    Public WithEvents Label2 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.
    Public WithEvents optTool2 As System.Windows.Forms.RadioButton
    Public WithEvents optTool1 As System.Windows.Forms.RadioButton
    Public WithEvents optTool0 As System.Windows.Forms.RadioButton
    Friend WithEvents AxArcReaderControl1 As ESRI.ArcGIS.PublisherControls.AxArcReaderControl
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(MapTools))
        Me.cmdRedo = New System.Windows.Forms.Button
        Me.cmdUndo = New System.Windows.Forms.Button
        Me.cmdFullExtent = New System.Windows.Forms.Button
        Me.optTool2 = New System.Windows.Forms.RadioButton
        Me.optTool1 = New System.Windows.Forms.RadioButton
        Me.optTool0 = New System.Windows.Forms.RadioButton
        Me.cmdLoad = New System.Windows.Forms.Button
        Me.txbPath = New System.Windows.Forms.TextBox
        Me._Label3_1 = New System.Windows.Forms.Label
        Me.Label6 = New System.Windows.Forms.Label
        Me.Label4 = New System.Windows.Forms.Label
        Me._Label3_0 = New System.Windows.Forms.Label
        Me.Label2 = New System.Windows.Forms.Label
        Me.AxArcReaderControl1 = New ESRI.ArcGIS.PublisherControls.AxArcReaderControl
        CType(Me.AxArcReaderControl1, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'cmdRedo
        '
        Me.cmdRedo.BackColor = System.Drawing.SystemColors.Control
        Me.cmdRedo.Cursor = System.Windows.Forms.Cursors.Default
        Me.cmdRedo.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.cmdRedo.ForeColor = System.Drawing.SystemColors.ControlText
        Me.cmdRedo.ImageAlign = System.Drawing.ContentAlignment.BottomCenter
        Me.cmdRedo.Location = New System.Drawing.Point(616, 288)
        Me.cmdRedo.Name = "cmdRedo"
        Me.cmdRedo.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.cmdRedo.Size = New System.Drawing.Size(64, 49)
        Me.cmdRedo.TabIndex = 11
        Me.cmdRedo.Text = "Redo"
        Me.cmdRedo.TextAlign = System.Drawing.ContentAlignment.TopCenter
        '
        'cmdUndo
        '
        Me.cmdUndo.BackColor = System.Drawing.SystemColors.Control
        Me.cmdUndo.Cursor = System.Windows.Forms.Cursors.Default
        Me.cmdUndo.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.cmdUndo.ForeColor = System.Drawing.SystemColors.ControlText
        Me.cmdUndo.ImageAlign = System.Drawing.ContentAlignment.BottomCenter
        Me.cmdUndo.Location = New System.Drawing.Point(544, 288)
        Me.cmdUndo.Name = "cmdUndo"
        Me.cmdUndo.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.cmdUndo.Size = New System.Drawing.Size(64, 49)
        Me.cmdUndo.TabIndex = 10
        Me.cmdUndo.Text = "Undo"
        Me.cmdUndo.TextAlign = System.Drawing.ContentAlignment.TopCenter
        '
        'cmdFullExtent
        '
        Me.cmdFullExtent.BackColor = System.Drawing.SystemColors.Control
        Me.cmdFullExtent.Cursor = System.Windows.Forms.Cursors.Default
        Me.cmdFullExtent.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.cmdFullExtent.ForeColor = System.Drawing.SystemColors.ControlText
        Me.cmdFullExtent.ImageAlign = System.Drawing.ContentAlignment.BottomCenter
        Me.cmdFullExtent.Location = New System.Drawing.Point(472, 288)
        Me.cmdFullExtent.Name = "cmdFullExtent"
        Me.cmdFullExtent.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.cmdFullExtent.Size = New System.Drawing.Size(64, 49)
        Me.cmdFullExtent.TabIndex = 9
        Me.cmdFullExtent.Text = "FullExtent"
        Me.cmdFullExtent.TextAlign = System.Drawing.ContentAlignment.TopCenter
        '
        'optTool2
        '
        Me.optTool2.Appearance = System.Windows.Forms.Appearance.Button
        Me.optTool2.BackColor = System.Drawing.SystemColors.Control
        Me.optTool2.Cursor = System.Windows.Forms.Cursors.Default
        Me.optTool2.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.optTool2.ForeColor = System.Drawing.SystemColors.ControlText
        Me.optTool2.ImageAlign = System.Drawing.ContentAlignment.BottomCenter
        Me.optTool2.Location = New System.Drawing.Point(616, 232)
        Me.optTool2.Name = "optTool2"
        Me.optTool2.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.optTool2.Size = New System.Drawing.Size(64, 49)
        Me.optTool2.TabIndex = 0
        Me.optTool2.TabStop = True
        Me.optTool2.Text = "Pan"
        Me.optTool2.TextAlign = System.Drawing.ContentAlignment.TopCenter
        '
        'optTool1
        '
        Me.optTool1.Appearance = System.Windows.Forms.Appearance.Button
        Me.optTool1.BackColor = System.Drawing.SystemColors.Control
        Me.optTool1.Cursor = System.Windows.Forms.Cursors.Default
        Me.optTool1.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.optTool1.ForeColor = System.Drawing.SystemColors.ControlText
        Me.optTool1.ImageAlign = System.Drawing.ContentAlignment.BottomCenter
        Me.optTool1.Location = New System.Drawing.Point(544, 232)
        Me.optTool1.Name = "optTool1"
        Me.optTool1.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.optTool1.Size = New System.Drawing.Size(64, 49)
        Me.optTool1.TabIndex = 8
        Me.optTool1.TabStop = True
        Me.optTool1.Text = "ZoomOut"
        Me.optTool1.TextAlign = System.Drawing.ContentAlignment.TopCenter
        '
        'optTool0
        '
        Me.optTool0.Appearance = System.Windows.Forms.Appearance.Button
        Me.optTool0.BackColor = System.Drawing.SystemColors.Control
        Me.optTool0.Cursor = System.Windows.Forms.Cursors.Default
        Me.optTool0.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.optTool0.ForeColor = System.Drawing.SystemColors.ControlText
        Me.optTool0.ImageAlign = System.Drawing.ContentAlignment.BottomCenter
        Me.optTool0.Location = New System.Drawing.Point(472, 232)
        Me.optTool0.Name = "optTool0"
        Me.optTool0.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.optTool0.Size = New System.Drawing.Size(64, 49)
        Me.optTool0.TabIndex = 7
        Me.optTool0.TabStop = True
        Me.optTool0.Text = "ZoomIn"
        Me.optTool0.TextAlign = System.Drawing.ContentAlignment.TopCenter
        '
        'cmdLoad
        '
        Me.cmdLoad.BackColor = System.Drawing.SystemColors.Control
        Me.cmdLoad.Cursor = System.Windows.Forms.Cursors.Default
        Me.cmdLoad.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.cmdLoad.ForeColor = System.Drawing.SystemColors.ControlText
        Me.cmdLoad.Location = New System.Drawing.Point(392, 8)
        Me.cmdLoad.Name = "cmdLoad"
        Me.cmdLoad.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.cmdLoad.Size = New System.Drawing.Size(81, 25)
        Me.cmdLoad.TabIndex = 2
        Me.cmdLoad.Text = "Load PMF"
        '
        'txbPath
        '
        Me.txbPath.AcceptsReturn = True
        Me.txbPath.AutoSize = False
        Me.txbPath.BackColor = System.Drawing.SystemColors.Window
        Me.txbPath.Cursor = System.Windows.Forms.Cursors.IBeam
        Me.txbPath.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.txbPath.ForeColor = System.Drawing.SystemColors.WindowText
        Me.txbPath.Location = New System.Drawing.Point(8, 8)
        Me.txbPath.MaxLength = 0
        Me.txbPath.Name = "txbPath"
        Me.txbPath.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.txbPath.Size = New System.Drawing.Size(377, 25)
        Me.txbPath.TabIndex = 1
        Me.txbPath.Text = ""
        '
        '_Label3_1
        '
        Me._Label3_1.BackColor = System.Drawing.SystemColors.Control
        Me._Label3_1.Cursor = System.Windows.Forms.Cursors.Default
        Me._Label3_1.Font = New System.Drawing.Font("Verdana", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me._Label3_1.ForeColor = System.Drawing.SystemColors.Highlight
        Me._Label3_1.Location = New System.Drawing.Point(488, 128)
        Me._Label3_1.Name = "_Label3_1"
        Me._Label3_1.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me._Label3_1.Size = New System.Drawing.Size(201, 33)
        Me._Label3_1.TabIndex = 12
        Me._Label3_1.Text = "4) Use the 'Layout' button to display the layout view. "
        '
        'Label6
        '
        Me.Label6.BackColor = System.Drawing.SystemColors.Control
        Me.Label6.Cursor = System.Windows.Forms.Cursors.Default
        Me.Label6.Font = New System.Drawing.Font("Verdana", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label6.ForeColor = System.Drawing.SystemColors.Highlight
        Me.Label6.Location = New System.Drawing.Point(488, 168)
        Me.Label6.Name = "Label6"
        Me.Label6.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Label6.Size = New System.Drawing.Size(201, 56)
        Me.Label6.TabIndex = 6
        Me.Label6.Text = "5) Use the 'tools below to navigate the data within any of the data frames on the" & _
        " page layout."
        '
        'Label4
        '
        Me.Label4.BackColor = System.Drawing.SystemColors.Control
        Me.Label4.Cursor = System.Windows.Forms.Cursors.Default
        Me.Label4.Font = New System.Drawing.Font("Verdana", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label4.ForeColor = System.Drawing.SystemColors.Highlight
        Me.Label4.Location = New System.Drawing.Point(488, 88)
        Me.Label4.Name = "Label4"
        Me.Label4.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Label4.Size = New System.Drawing.Size(201, 33)
        Me.Label4.TabIndex = 5
        Me.Label4.Text = "3) Use the tools below to navigate the focus map."
        '
        '_Label3_0
        '
        Me._Label3_0.BackColor = System.Drawing.SystemColors.Control
        Me._Label3_0.Cursor = System.Windows.Forms.Cursors.Default
        Me._Label3_0.Font = New System.Drawing.Font("Verdana", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me._Label3_0.ForeColor = System.Drawing.SystemColors.Highlight
        Me._Label3_0.Location = New System.Drawing.Point(488, 50)
        Me._Label3_0.Name = "_Label3_0"
        Me._Label3_0.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me._Label3_0.Size = New System.Drawing.Size(201, 33)
        Me._Label3_0.TabIndex = 4
        Me._Label3_0.Text = "2) Use the 'Map' button to display the data view. "
        '
        'Label2
        '
        Me.Label2.BackColor = System.Drawing.SystemColors.Control
        Me.Label2.Cursor = System.Windows.Forms.Cursors.Default
        Me.Label2.Font = New System.Drawing.Font("Verdana", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label2.ForeColor = System.Drawing.SystemColors.Highlight
        Me.Label2.Location = New System.Drawing.Point(488, 16)
        Me.Label2.Name = "Label2"
        Me.Label2.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Label2.Size = New System.Drawing.Size(201, 33)
        Me.Label2.TabIndex = 3
        Me.Label2.Text = "1) Enter a valid file path and load the PMF."
        '
        'AxArcReaderControl1
        '
        Me.AxArcReaderControl1.Location = New System.Drawing.Point(8, 40)
        Me.AxArcReaderControl1.Name = "AxArcReaderControl1"
        Me.AxArcReaderControl1.OcxState = CType(resources.GetObject("AxArcReaderControl1.OcxState"), System.Windows.Forms.AxHost.State)
        Me.AxArcReaderControl1.Size = New System.Drawing.Size(464, 448)
        Me.AxArcReaderControl1.TabIndex = 13
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.BackColor = System.Drawing.SystemColors.Control
        Me.ClientSize = New System.Drawing.Size(687, 498)
        Me.Controls.Add(Me.AxArcReaderControl1)
        Me.Controls.Add(Me.cmdRedo)
        Me.Controls.Add(Me.cmdUndo)
        Me.Controls.Add(Me.cmdFullExtent)
        Me.Controls.Add(Me.optTool2)
        Me.Controls.Add(Me.optTool1)
        Me.Controls.Add(Me.optTool0)
        Me.Controls.Add(Me.cmdLoad)
        Me.Controls.Add(Me.txbPath)
        Me.Controls.Add(Me._Label3_1)
        Me.Controls.Add(Me.Label6)
        Me.Controls.Add(Me.Label4)
        Me.Controls.Add(Me._Label3_0)
        Me.Controls.Add(Me.Label2)
        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.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
        Me.Location = New System.Drawing.Point(3, 22)
        Me.MaximizeBox = False
        Me.MinimizeBox = False
        Me.Name = "Form1"
        Me.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Text = "Map Tools"
        CType(Me.AxArcReaderControl1, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub
#End Region

    Dim pARTool As esriARTool

    Private Sub cmdFullExtent_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdFullExtent.Click

        'Set extent to full data extent
        Dim xMax, xMin, yMin, yMax As Double
        AxArcReaderControl1.ARPageLayout.FocusARMap.GetFullExtent(xMin, yMin, xMax, yMax)
        AxArcReaderControl1.ARPageLayout.FocusARMap.SetExtent(xMin, yMin, xMax, yMax)
        'Refresh the display
        AxArcReaderControl1.ARPageLayout.FocusARMap.Refresh()

    End Sub

    Private Sub cmdLoad_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdLoad.Click

        'Load the specified pmf
        If txbPath.Text = "" Then Exit Sub
        If AxArcReaderControl1.CheckDocument(txbPath.Text) = True Then
            AxArcReaderControl1.LoadDocument(txbPath.Text)
        Else
            MsgBox("This document cannot be loaded!")
            Exit Sub
        End If

        optTool0.Checked = True

    End Sub

    Private Sub cmdRedo_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdRedo.Click

        'Redo extent
        AxArcReaderControl1.ARPageLayout.FocusARMap.RedoExtent()

    End Sub

    Private Sub cmdUndo_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdUndo.Click

        'Undo extent
        AxArcReaderControl1.ARPageLayout.FocusARMap.UndoExtent()

    End Sub

    Private Sub Form1_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load

        'Load option/command button images
        Dim pImage As System.Drawing.Image
        Dim pBitmap As System.Drawing.Bitmap
        pImage = New System.Drawing.Bitmap(GetType(MapTools).Assembly.GetManifestResourceStream(GetType(MapTools), "ZoomIn.bmp"))
        pBitmap = pImage
        pBitmap.MakeTransparent(System.Drawing.Color.Teal)
        optTool0.Image = pImage
        pImage = New System.Drawing.Bitmap(GetType(MapTools).Assembly.GetManifestResourceStream(GetType(MapTools), "ZoomOut.bmp"))
        pBitmap = pImage
        pBitmap.MakeTransparent(System.Drawing.Color.Teal)
        optTool1.Image = pImage
        pImage = New System.Drawing.Bitmap(GetType(MapTools).Assembly.GetManifestResourceStream(GetType(MapTools), "Pan.bmp"))
        pBitmap = pImage
        pBitmap.MakeTransparent(System.Drawing.Color.Teal)
        optTool2.Image = pImage
        pImage = New System.Drawing.Bitmap(GetType(MapTools).Assembly.GetManifestResourceStream(GetType(MapTools), "FullExtent.bmp"))
        pBitmap = pImage
        pBitmap.MakeTransparent(System.Drawing.Color.Teal)
        cmdFullExtent.Image = pImage
        pImage = New System.Drawing.Bitmap(GetType(MapTools).Assembly.GetManifestResourceStream(GetType(MapTools), "UnDoDraw.bmp"))
        pBitmap = pImage
        pBitmap.MakeTransparent(System.Drawing.Color.Teal)
        cmdUndo.Image = pImage
        pImage = New System.Drawing.Bitmap(GetType(MapTools).Assembly.GetManifestResourceStream(GetType(MapTools), "ReDoDraw.bmp"))
        pBitmap = pImage
        pBitmap.MakeTransparent(System.Drawing.Color.Teal)
        cmdRedo.Image = pImage

        'Disable controls
        optTool0.Enabled = False
        optTool1.Enabled = False
        optTool2.Enabled = False
        cmdUndo.Enabled = False
        cmdRedo.Enabled = False
        cmdFullExtent.Enabled = False

    End Sub
    Private Sub AxArcReaderControl1_OnAfterScreenDraw(ByVal sender As Object, ByVal e As System.EventArgs) Handles AxArcReaderControl1.OnAfterScreenDraw
        Dim bEnabled As Boolean
        'Determine whether can undo/redo extent and enable/disbale control
        If AxArcReaderControl1.ARPageLayout.FocusARMap.CanUndoExtent = True Then bEnabled = True Else bEnabled = False
        cmdUndo.Enabled = bEnabled
        If AxArcReaderControl1.ARPageLayout.FocusARMap.CanRedoExtent = True Then bEnabled = True Else bEnabled = False
        cmdRedo.Enabled = bEnabled
    End Sub

    Private Sub AxArcReaderControl1_OnCurrentViewChanged(ByVal sender As Object, ByVal e As ESRI.ArcGIS.PublisherControls.IARControlEvents_OnCurrentViewChangedEvent) Handles AxArcReaderControl1.OnCurrentViewChanged
        Dim bEnabled As Boolean
        'Determine view type
        If AxArcReaderControl1.CurrentViewType = esriARViewType.esriARViewTypeNone Then
            bEnabled = False
        Else
            bEnabled = True
            'Update the current tool if necessary
            If AxArcReaderControl1.CurrentARTool <> pARTool Then
                AxArcReaderControl1.CurrentARTool = pARTool
            End If
        End If

        'Enable/ disable controls
        optTool0.Enabled = bEnabled
        optTool1.Enabled = bEnabled
        optTool2.Enabled = bEnabled
        cmdFullExtent.Enabled = bEnabled
    End Sub

    Private Sub MixedControls_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles optTool0.Click, optTool1.Click, optTool2.Click

        Dim senderName As String
        senderName = sender.Name

        Select Case senderName
            'Set current tool
            Case "optTool0"
                AxArcReaderControl1.CurrentARTool = esriARTool.esriARToolMapZoomIn
            Case "optTool1"
                AxArcReaderControl1.CurrentARTool = esriARTool.esriARToolMapZoomOut
            Case "optTool2"
                AxArcReaderControl1.CurrentARTool = esriARTool.esriARToolMapPan
        End Select

        'Remember the current tool
        pARTool = AxArcReaderControl1.CurrentARTool

    End Sub

    Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
        'Release COM objects
        ESRI.ArcGIS.ADF.COMSupport.AOUninitialize.Shutdown()
    End Sub
End Class