About the ArcReaderGlobeControl globe tools Sample
[C#]
GlobeTools.cs
using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using ESRI.ArcGIS.PublisherControls; namespace GlobeTools { /// <summary> /// Summary description for Form1. /// </summary> public class GlobeTools : System.Windows.Forms.Form { private ESRI.ArcGIS.PublisherControls.AxArcReaderGlobeControl axArcReaderGlobeControl1; internal System.Windows.Forms.RadioButton optTool4; internal System.Windows.Forms.RadioButton optTool3; internal System.Windows.Forms.RadioButton optTool2; internal System.Windows.Forms.RadioButton optTool1; internal System.Windows.Forms.RadioButton optTool0; internal System.Windows.Forms.Button btnFullExtent; internal System.Windows.Forms.Button btnLoad; private System.Windows.Forms.OpenFileDialog openFileDialog1; private esriARGlobeTool arGlobeTool; /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.Container components = null; public GlobeTools() { // // 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(GlobeTools)); this.axArcReaderGlobeControl1 = new ESRI.ArcGIS.PublisherControls.AxArcReaderGlobeControl(); this.optTool4 = new System.Windows.Forms.RadioButton(); this.optTool3 = new System.Windows.Forms.RadioButton(); this.optTool2 = new System.Windows.Forms.RadioButton(); this.optTool1 = new System.Windows.Forms.RadioButton(); this.optTool0 = new System.Windows.Forms.RadioButton(); this.btnFullExtent = new System.Windows.Forms.Button(); this.btnLoad = new System.Windows.Forms.Button(); this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); ((System.ComponentModel.ISupportInitialize)(this.axArcReaderGlobeControl1)).BeginInit(); this.SuspendLayout(); // // axArcReaderGlobeControl1 // this.axArcReaderGlobeControl1.Location = new System.Drawing.Point(12, 68); this.axArcReaderGlobeControl1.Name = "axArcReaderGlobeControl1"; this.axArcReaderGlobeControl1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axArcReaderGlobeControl1.OcxState"))); this.axArcReaderGlobeControl1.Size = new System.Drawing.Size(524, 332); this.axArcReaderGlobeControl1.TabIndex = 0; this.axArcReaderGlobeControl1.OnDocumentUnloaded += new System.EventHandler(this.axArcReaderGlobeControl1_OnDocumentUnloaded); this.axArcReaderGlobeControl1.OnDocumentLoaded += new ESRI.ArcGIS.PublisherControls.IARGlobeControlEvents_Ax_OnDocumentLoadedEventHandler(this.axArcReaderGlobeControl1_OnDocumentLoaded); // // optTool4 // this.optTool4.Appearance = System.Windows.Forms.Appearance.Button; this.optTool4.Location = new System.Drawing.Point(372, 12); this.optTool4.Name = "optTool4"; this.optTool4.Size = new System.Drawing.Size(84, 44); this.optTool4.TabIndex = 14; this.optTool4.Text = "Zoom In\\Out"; this.optTool4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.optTool4.Click += new System.EventHandler(this.MixedControls_Click); // // optTool3 // this.optTool3.Appearance = System.Windows.Forms.Appearance.Button; this.optTool3.Location = new System.Drawing.Point(300, 12); this.optTool3.Name = "optTool3"; this.optTool3.Size = new System.Drawing.Size(72, 44); this.optTool3.TabIndex = 13; this.optTool3.Text = "Target"; this.optTool3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.optTool3.Click += new System.EventHandler(this.MixedControls_Click); // // optTool2 // this.optTool2.Appearance = System.Windows.Forms.Appearance.Button; this.optTool2.Location = new System.Drawing.Point(228, 12); this.optTool2.Name = "optTool2"; this.optTool2.Size = new System.Drawing.Size(72, 44); this.optTool2.TabIndex = 12; this.optTool2.Text = "Navigate"; this.optTool2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.optTool2.Click += new System.EventHandler(this.MixedControls_Click); // // optTool1 // this.optTool1.Appearance = System.Windows.Forms.Appearance.Button; this.optTool1.Location = new System.Drawing.Point(156, 12); this.optTool1.Name = "optTool1"; this.optTool1.Size = new System.Drawing.Size(72, 44); this.optTool1.TabIndex = 11; this.optTool1.Text = "Pivot"; this.optTool1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.optTool1.Click += new System.EventHandler(this.MixedControls_Click); // // optTool0 // this.optTool0.Appearance = System.Windows.Forms.Appearance.Button; this.optTool0.Location = new System.Drawing.Point(84, 12); this.optTool0.Name = "optTool0"; this.optTool0.Size = new System.Drawing.Size(72, 44); this.optTool0.TabIndex = 10; this.optTool0.Text = "Pan"; this.optTool0.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.optTool0.Click += new System.EventHandler(this.MixedControls_Click); // // btnFullExtent // this.btnFullExtent.Location = new System.Drawing.Point(452, 12); this.btnFullExtent.Name = "btnFullExtent"; this.btnFullExtent.Size = new System.Drawing.Size(84, 44); this.btnFullExtent.TabIndex = 9; this.btnFullExtent.Text = "Full Extent"; this.btnFullExtent.Click += new System.EventHandler(this.btnFullExtent_Click); // // btnLoad // this.btnLoad.Location = new System.Drawing.Point(12, 12); this.btnLoad.Name = "btnLoad"; this.btnLoad.Size = new System.Drawing.Size(72, 44); this.btnLoad.TabIndex = 8; this.btnLoad.Text = "Load"; this.btnLoad.Click += new System.EventHandler(this.btnLoad_Click); // // GlobeTools // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(544, 410); this.Controls.Add(this.optTool4); this.Controls.Add(this.optTool3); this.Controls.Add(this.optTool2); this.Controls.Add(this.optTool1); this.Controls.Add(this.optTool0); this.Controls.Add(this.btnFullExtent); this.Controls.Add(this.btnLoad); this.Controls.Add(this.axArcReaderGlobeControl1); this.Name = "GlobeTools"; this.Text = "GlobeTools"; this.Closing += new System.ComponentModel.CancelEventHandler(this.GlobeTools_Closing); this.Load += new System.EventHandler(this.GlobeTools_Load); ((System.ComponentModel.ISupportInitialize)(this.axArcReaderGlobeControl1)).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 GlobeTools()); } private void btnLoad_Click(object sender, System.EventArgs e) { //Open a file dialog for selecting map documents openFileDialog1.Title = "Select Published Map Document"; openFileDialog1.Filter = "Published Map Documents (*.pmf)|*.pmf"; openFileDialog1.ShowDialog(); //Exit if no map document is selected string sFilePath = openFileDialog1.FileName; if (sFilePath == "") return; //Load the specified pmf if (axArcReaderGlobeControl1.CheckDocument(sFilePath) == true) { axArcReaderGlobeControl1.LoadDocument(sFilePath,""); } else { System.Windows.Forms.MessageBox.Show("This document cannot be loaded!"); return; } } private void MixedControls_Click(object sender, System.EventArgs e) { RadioButton b = (RadioButton) sender; //Set current tool switch (b.Name) { case "optTool0": axArcReaderGlobeControl1.CurrentARGlobeTool = esriARGlobeTool.esriARGlobeToolPan; break; case "optTool1": axArcReaderGlobeControl1.CurrentARGlobeTool = esriARGlobeTool.esriARGlobeToolPivot; break; case "optTool2": axArcReaderGlobeControl1.CurrentARGlobeTool = esriARGlobeTool.esriARGlobeToolNavigate; break; case "optTool3": axArcReaderGlobeControl1.CurrentARGlobeTool = esriARGlobeTool.esriARGlobeToolTarget; break; case "optTool4": axArcReaderGlobeControl1.CurrentARGlobeTool = esriARGlobeTool.esriARGlobeToolZoomInOut; break; } //Remember the current tool arGlobeTool = axArcReaderGlobeControl1.CurrentARGlobeTool; } private void GlobeTools_Closing(object sender, System.ComponentModel.CancelEventArgs e) { //Release COM objects ESRI.ArcGIS.ADF.COMSupport.AOUninitialize.Shutdown(); } private void GlobeTools_Load(object sender, System.EventArgs e) { //Disable controls optTool0.Enabled = false; optTool1.Enabled = false; optTool2.Enabled = false; optTool3.Enabled = false; optTool4.Enabled = false; btnFullExtent.Enabled = false; } private void axArcReaderGlobeControl1_OnDocumentLoaded(object sender, ESRI.ArcGIS.PublisherControls.IARGlobeControlEvents_OnDocumentLoadedEvent e) { //Enable Tools optTool0.Enabled = true; optTool1.Enabled = true; optTool2.Enabled = true; optTool3.Enabled = true; optTool4.Enabled = true; btnFullExtent.Enabled = true; } private void axArcReaderGlobeControl1_OnDocumentUnloaded(object sender, System.EventArgs e) { //Enable Tools optTool0.Enabled = false; optTool1.Enabled = false; optTool2.Enabled = false; optTool3.Enabled = false; optTool4.Enabled = false; btnFullExtent.Enabled = false; } private void btnFullExtent_Click(object sender, System.EventArgs e) { //Zoom to Full Extent axArcReaderGlobeControl1.ARGlobe.ZoomToFullExtent(); } } }
[Visual Basic .NET]
GlobeTools.vb
Imports ESRI.ArcGIS.PublisherControls Imports ESRI.ArcGIS Public Class GlobeTools 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() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents btnLoad As System.Windows.Forms.Button Friend WithEvents btnFullExtent As System.Windows.Forms.Button Friend WithEvents OpenFileDialog1 As System.Windows.Forms.OpenFileDialog Friend WithEvents optTool0 As System.Windows.Forms.RadioButton Friend WithEvents optTool1 As System.Windows.Forms.RadioButton Friend WithEvents optTool2 As System.Windows.Forms.RadioButton Friend WithEvents optTool3 As System.Windows.Forms.RadioButton Friend WithEvents AxArcReaderGlobeControl1 As ESRI.ArcGIS.PublisherControls.AxArcReaderGlobeControl Friend WithEvents optTool4 As System.Windows.Forms.RadioButton <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(GlobeTools)) Me.btnLoad = New System.Windows.Forms.Button Me.btnFullExtent = New System.Windows.Forms.Button Me.optTool0 = New System.Windows.Forms.RadioButton Me.optTool1 = New System.Windows.Forms.RadioButton Me.optTool2 = New System.Windows.Forms.RadioButton Me.optTool3 = New System.Windows.Forms.RadioButton Me.optTool4 = New System.Windows.Forms.RadioButton Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog Me.AxArcReaderGlobeControl1 = New ESRI.ArcGIS.PublisherControls.AxArcReaderGlobeControl CType(Me.AxArcReaderGlobeControl1, System.ComponentModel.ISupportInitialize).BeginInit() Me.SuspendLayout() ' 'btnLoad ' Me.btnLoad.Location = New System.Drawing.Point(8, 12) Me.btnLoad.Name = "btnLoad" Me.btnLoad.Size = New System.Drawing.Size(72, 44) Me.btnLoad.TabIndex = 0 Me.btnLoad.Text = "Load" ' 'btnFullExtent ' Me.btnFullExtent.Location = New System.Drawing.Point(448, 12) Me.btnFullExtent.Name = "btnFullExtent" Me.btnFullExtent.Size = New System.Drawing.Size(84, 44) Me.btnFullExtent.TabIndex = 1 Me.btnFullExtent.Text = "Full Extent" ' 'optTool0 ' Me.optTool0.Appearance = System.Windows.Forms.Appearance.Button Me.optTool0.Location = New System.Drawing.Point(80, 12) Me.optTool0.Name = "optTool0" Me.optTool0.Size = New System.Drawing.Size(72, 44) Me.optTool0.TabIndex = 3 Me.optTool0.Text = "Pan" Me.optTool0.TextAlign = System.Drawing.ContentAlignment.MiddleCenter ' 'optTool1 ' Me.optTool1.Appearance = System.Windows.Forms.Appearance.Button Me.optTool1.Location = New System.Drawing.Point(152, 12) Me.optTool1.Name = "optTool1" Me.optTool1.Size = New System.Drawing.Size(72, 44) Me.optTool1.TabIndex = 4 Me.optTool1.Text = "Pivot" Me.optTool1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter ' 'optTool2 ' Me.optTool2.Appearance = System.Windows.Forms.Appearance.Button Me.optTool2.Location = New System.Drawing.Point(224, 12) Me.optTool2.Name = "optTool2" Me.optTool2.Size = New System.Drawing.Size(72, 44) Me.optTool2.TabIndex = 5 Me.optTool2.Text = "Navigate" Me.optTool2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter ' 'optTool3 ' Me.optTool3.Appearance = System.Windows.Forms.Appearance.Button Me.optTool3.Location = New System.Drawing.Point(296, 12) Me.optTool3.Name = "optTool3" Me.optTool3.Size = New System.Drawing.Size(72, 44) Me.optTool3.TabIndex = 6 Me.optTool3.Text = "Target" Me.optTool3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter ' 'optTool4 ' Me.optTool4.Appearance = System.Windows.Forms.Appearance.Button Me.optTool4.Location = New System.Drawing.Point(368, 12) Me.optTool4.Name = "optTool4" Me.optTool4.Size = New System.Drawing.Size(84, 44) Me.optTool4.TabIndex = 7 Me.optTool4.Text = "Zoom In\Out" Me.optTool4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter ' 'AxArcReaderGlobeControl1 ' Me.AxArcReaderGlobeControl1.Location = New System.Drawing.Point(14, 65) Me.AxArcReaderGlobeControl1.Name = "AxArcReaderGlobeControl1" Me.AxArcReaderGlobeControl1.OcxState = CType(resources.GetObject("AxArcReaderGlobeControl1.OcxState"), System.Windows.Forms.AxHost.State) Me.AxArcReaderGlobeControl1.Size = New System.Drawing.Size(517, 368) Me.AxArcReaderGlobeControl1.TabIndex = 8 ' 'GlobeTools ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(542, 442) Me.Controls.Add(Me.AxArcReaderGlobeControl1) Me.Controls.Add(Me.optTool4) Me.Controls.Add(Me.optTool3) Me.Controls.Add(Me.optTool2) Me.Controls.Add(Me.optTool1) Me.Controls.Add(Me.optTool0) Me.Controls.Add(Me.btnFullExtent) Me.Controls.Add(Me.btnLoad) Me.Name = "GlobeTools" Me.Text = "GlobeTools" CType(Me.AxArcReaderGlobeControl1, System.ComponentModel.ISupportInitialize).EndInit() Me.ResumeLayout(False) End Sub #End Region Dim pARGlobeTool As esriARGlobeTool Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Disable controls optTool0.Enabled = False optTool1.Enabled = False optTool2.Enabled = False optTool3.Enabled = False optTool4.Enabled = False btnFullExtent.Enabled = False End Sub Private Sub MixedControls_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles optTool0.Click, optTool1.Click, optTool2.Click, optTool3.Click, optTool4.Click Dim senderName As String senderName = sender.Name Select Case senderName 'Set current tool Case "optTool0" AxArcReaderGlobeControl1.CurrentARGlobeTool = esriARGlobeTool.esriARGlobeToolPan Case "optTool1" AxArcReaderGlobeControl1.CurrentARGlobeTool = esriARGlobeTool.esriARGlobeToolPivot Case "optTool2" AxArcReaderGlobeControl1.CurrentARGlobeTool = esriARGlobeTool.esriARGlobeToolNavigate Case "optTool3" AxArcReaderGlobeControl1.CurrentARGlobeTool = esriARGlobeTool.esriARGlobeToolTarget Case "optTool4" AxArcReaderGlobeControl1.CurrentARGlobeTool = esriARGlobeTool.esriARGlobeToolZoomInOut End Select 'Remember the current tool pARGlobeTool = AxArcReaderGlobeControl1.CurrentARGlobeTool End Sub Private Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoad.Click 'Open a file dialog for selecting map documents OpenFileDialog1.Title = "Select Published Map Document" OpenFileDialog1.Filter = "Published Map Documents (*.pmf)|*.pmf" OpenFileDialog1.ShowDialog() 'Exit if no map document is selected Dim sFilePath As String sFilePath = OpenFileDialog1.FileName If sFilePath = "" Then Exit Sub 'Load the specified pmf If AxArcReaderGlobeControl1.CheckDocument(sFilePath) = True Then AxArcReaderGlobeControl1.LoadDocument(sFilePath) Else MsgBox("This document cannot be loaded!") Exit Sub End If End Sub Private Sub AxArcReaderGlobeControl1_OnDocumentLoaded(ByVal sender As Object, ByVal e As ESRI.ArcGIS.PublisherControls.IARGlobeControlEvents_OnDocumentLoadedEvent) Handles AxArcReaderGlobeControl1.OnDocumentLoaded 'Enable Tools optTool0.Enabled = True optTool1.Enabled = True optTool2.Enabled = True optTool3.Enabled = True optTool4.Enabled = True btnFullExtent.Enabled = True End Sub Private Sub AxArcReaderGlobeControl1_OnDocumentUnloaded(ByVal sender As Object, ByVal e As System.EventArgs) Handles AxArcReaderGlobeControl1.OnDocumentUnloaded 'Enable Tools optTool0.Enabled = False optTool1.Enabled = False optTool2.Enabled = False optTool3.Enabled = False optTool4.Enabled = False btnFullExtent.Enabled = False End Sub Private Sub btnFullExtent_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnFullExtent.Click 'Zoom to Full Extent AxArcReaderGlobeControl1.ARGlobe.ZoomToFullExtent() End Sub Private Sub GlobeTools_Disposed(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Disposed 'Release COM objects ESRI.ArcGIS.ADF.COMSupport.AOUninitialize.Shutdown() End Sub End Class