ArcObjects Library Reference  

SpinGlobe

About the ArcReaderGlobeControl spin globe Sample

[C#]

SpinGlobe.cs

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using ESRI.ArcGIS.ADF;
using ESRI.ArcGIS.PublisherControls;

namespace SpinGlobe
{
	/// <summary>
	/// Summary description for Form1.
	/// </summary>
	public class SpinGlobe : System.Windows.Forms.Form
	{
		internal System.Windows.Forms.Label lblFaster;
		internal System.Windows.Forms.Label lblSlower;
		internal System.Windows.Forms.TrackBar TrackBar1;
		internal System.Windows.Forms.Button btnStop;
		internal System.Windows.Forms.Button btnClockwise;
		internal System.Windows.Forms.Button btnAntiClockwise;
		internal System.Windows.Forms.Button btnLoad;
		private ESRI.ArcGIS.PublisherControls.AxArcReaderGlobeControl axArcReaderGlobeControl1;
		private System.Windows.Forms.OpenFileDialog openFileDialog1;
		private bool m_RotateDirection;
		private double m_CurLat;
		private double m_CurLong;
		private double m_CurElev;
		private double i;
		private System.Windows.Forms.Timer timer1;
		private System.ComponentModel.IContainer components;

		public SpinGlobe()
		{
			//
			// 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()
		{
			this.components = new System.ComponentModel.Container();
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(SpinGlobe));
			this.lblFaster = new System.Windows.Forms.Label();
			this.lblSlower = new System.Windows.Forms.Label();
			this.TrackBar1 = new System.Windows.Forms.TrackBar();
			this.btnStop = new System.Windows.Forms.Button();
			this.btnClockwise = new System.Windows.Forms.Button();
			this.btnAntiClockwise = new System.Windows.Forms.Button();
			this.btnLoad = new System.Windows.Forms.Button();
			this.axArcReaderGlobeControl1 = new ESRI.ArcGIS.PublisherControls.AxArcReaderGlobeControl();
			this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
			this.timer1 = new System.Windows.Forms.Timer(this.components);
			((System.ComponentModel.ISupportInitialize)(this.TrackBar1)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.axArcReaderGlobeControl1)).BeginInit();
			this.SuspendLayout();
			// 
			// lblFaster
			// 
			this.lblFaster.Location = new System.Drawing.Point(152, 16);
			this.lblFaster.Name = "lblFaster";
			this.lblFaster.Size = new System.Drawing.Size(40, 20);
			this.lblFaster.TabIndex = 14;
			this.lblFaster.Text = "Faster";
			// 
			// lblSlower
			// 
			this.lblSlower.Location = new System.Drawing.Point(360, 16);
			this.lblSlower.Name = "lblSlower";
			this.lblSlower.Size = new System.Drawing.Size(40, 20);
			this.lblSlower.TabIndex = 13;
			this.lblSlower.Text = "Slower";
			// 
			// TrackBar1
			// 
			this.TrackBar1.Location = new System.Drawing.Point(192, 8);
			this.TrackBar1.Maximum = 1000;
			this.TrackBar1.Minimum = 100;
			this.TrackBar1.Name = "TrackBar1";
			this.TrackBar1.Size = new System.Drawing.Size(164, 45);
			this.TrackBar1.TabIndex = 12;
			this.TrackBar1.TickStyle = System.Windows.Forms.TickStyle.None;
			this.TrackBar1.Value = 100;
			this.TrackBar1.ValueChanged += new System.EventHandler(this.TrackBar1_ValueChanged);
			// 
			// btnStop
			// 
			this.btnStop.Location = new System.Drawing.Point(512, 16);
			this.btnStop.Name = "btnStop";
			this.btnStop.Size = new System.Drawing.Size(76, 36);
			this.btnStop.TabIndex = 11;
			this.btnStop.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
			this.btnStop.Click += new System.EventHandler(this.btnStop_Click);
			// 
			// btnClockwise
			// 
			this.btnClockwise.Location = new System.Drawing.Point(424, 16);
			this.btnClockwise.Name = "btnClockwise";
			this.btnClockwise.Size = new System.Drawing.Size(76, 36);
			this.btnClockwise.TabIndex = 10;
			this.btnClockwise.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
			this.btnClockwise.Click += new System.EventHandler(this.btnClockwise_Click);
			// 
			// btnAntiClockwise
			// 
			this.btnAntiClockwise.Location = new System.Drawing.Point(592, 16);
			this.btnAntiClockwise.Name = "btnAntiClockwise";
			this.btnAntiClockwise.Size = new System.Drawing.Size(76, 36);
			this.btnAntiClockwise.TabIndex = 9;
			this.btnAntiClockwise.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
			this.btnAntiClockwise.Click += new System.EventHandler(this.btnAntiClockwise_Click);
			// 
			// btnLoad
			// 
			this.btnLoad.ImageAlign = System.Drawing.ContentAlignment.BottomCenter;
			this.btnLoad.Location = new System.Drawing.Point(8, 16);
			this.btnLoad.Name = "btnLoad";
			this.btnLoad.Size = new System.Drawing.Size(76, 36);
			this.btnLoad.TabIndex = 8;
			this.btnLoad.Text = "Load";
			this.btnLoad.TextAlign = System.Drawing.ContentAlignment.TopCenter;
			this.btnLoad.Click += new System.EventHandler(this.btnLoad_Click);
			// 
			// axArcReaderGlobeControl1
			// 
			this.axArcReaderGlobeControl1.Location = new System.Drawing.Point(8, 64);
			this.axArcReaderGlobeControl1.Name = "axArcReaderGlobeControl1";
			this.axArcReaderGlobeControl1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axArcReaderGlobeControl1.OcxState")));
			this.axArcReaderGlobeControl1.Size = new System.Drawing.Size(656, 376);
			this.axArcReaderGlobeControl1.TabIndex = 15;
			this.axArcReaderGlobeControl1.OnDocumentUnloaded += new System.EventHandler(this.axArcReaderGlobeControl1_OnDocumentUnloaded);
			this.axArcReaderGlobeControl1.OnDocumentLoaded += new ESRI.ArcGIS.PublisherControls.IARGlobeControlEvents_Ax_OnDocumentLoadedEventHandler(this.axArcReaderGlobeControl1_OnDocumentLoaded);
			this.axArcReaderGlobeControl1.OnMouseUp += new ESRI.ArcGIS.PublisherControls.IARGlobeControlEvents_Ax_OnMouseUpEventHandler(this.axArcReaderGlobeControl1_OnMouseUp);
			// 
			// timer1
			// 
			this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
			// 
			// SpinGlobe
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(676, 450);
			this.Controls.Add(this.axArcReaderGlobeControl1);
			this.Controls.Add(this.lblFaster);
			this.Controls.Add(this.lblSlower);
			this.Controls.Add(this.TrackBar1);
			this.Controls.Add(this.btnStop);
			this.Controls.Add(this.btnClockwise);
			this.Controls.Add(this.btnAntiClockwise);
			this.Controls.Add(this.btnLoad);
			this.Name = "SpinGlobe";
			this.Text = "SpinGlobe";
			this.Closing += new System.ComponentModel.CancelEventHandler(this.SpinGlobe_Closing);
			this.Load += new System.EventHandler(this.SpinGlobe_Load);
			((System.ComponentModel.ISupportInitialize)(this.TrackBar1)).EndInit();
			((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 SpinGlobe());
		}

		private void SpinGlobe_Load(object sender, System.EventArgs e)
		{
			//Load command button images
			System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap (GetType().Assembly.GetManifestResourceStream(GetType(), "browse.bmp"));
			bitmap.MakeTransparent(System.Drawing.Color.Teal);
			btnLoad.Image = bitmap;
			bitmap = new System.Drawing.Bitmap (GetType().Assembly.GetManifestResourceStream(GetType(), "spin_counterclockwise.bmp"));
			bitmap.MakeTransparent(System.Drawing.Color.Teal);
			btnAntiClockwise.Image = bitmap;
			bitmap = new System.Drawing.Bitmap (GetType().Assembly.GetManifestResourceStream(GetType(), "spin_clockwise.bmp"));
			bitmap.MakeTransparent(System.Drawing.Color.Teal);
			btnClockwise.Image = bitmap;
			bitmap = new System.Drawing.Bitmap (GetType().Assembly.GetManifestResourceStream(GetType(), "spin_stop.bmp"));
			bitmap.MakeTransparent(System.Drawing.Color.Teal);
			btnStop.Image = bitmap;

			//Set the current Slider value and timer interval to 100 milliseconds
			//Any faster and the Globe will not be able to refresh fast enough
			TrackBar1.Value = 100;
			timer1.Interval = 100;
			timer1.Enabled = false;
            i = 0;

			//Disable controls until doc is loaded
			btnAntiClockwise.Enabled = false;
			btnClockwise.Enabled = false;
			btnStop.Enabled = false;


		}

		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 = "";
			sFilePath = openFileDialog1.FileName;
			if (sFilePath == "")
			{
				return;
			}

			//Load the specified pmf
			if (axArcReaderGlobeControl1.CheckDocument(sFilePath) == true)
			{
				axArcReaderGlobeControl1.LoadDocument(sFilePath);
			}
			else
			{
				MessageBox.Show("This document cannot be loaded!");
				return;
			}

			//Zoom to Full Extent
			axArcReaderGlobeControl1.ARGlobe.ZoomToFullExtent();

			//Set current tool to Globe Navigate
			axArcReaderGlobeControl1.CurrentARGlobeTool = ESRI.ArcGIS.PublisherControls.esriARGlobeTool.esriARGlobeToolNavigate;


		}

		private void TrackBar1_ValueChanged(object sender, System.EventArgs e)
		{
			//Update the timer interval to match the slider value
			timer1.Interval = TrackBar1.Value;
		}

		private void timer1_Tick(object sender, System.EventArgs e)
		{
			//Longitude Counter
			i = m_CurLong;

			//Increment Longitude by 1 decimal degree
			if (m_RotateDirection == false)
			{
				if (i == 360)
				{
					i = 0;
				}
				i = i + 1;
			}
			else
			{
				if (i == -360)
				{
					i = 0;
				}
				i = i - 1;
			}

			//Update the current location
			axArcReaderGlobeControl1.ARGlobe.SetObserverLocation(i, m_CurLat, m_CurElev);
			axArcReaderGlobeControl1.ARGlobe.GetObserverLocation(ref m_CurLong, ref m_CurLat, ref m_CurElev);
		}

		private void axArcReaderGlobeControl1_OnDocumentUnloaded(object sender, System.EventArgs e)
		{
			btnAntiClockwise.Enabled = false;
			btnClockwise.Enabled = false;
			btnStop.Enabled = false;
		}

		private void axArcReaderGlobeControl1_OnDocumentLoaded(object sender, ESRI.ArcGIS.PublisherControls.IARGlobeControlEvents_OnDocumentLoadedEvent e)
		{
			btnAntiClockwise.Enabled = true;
			btnClockwise.Enabled = true;
			btnStop.Enabled = true;
		}

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

		private void btnClockwise_Click(object sender, System.EventArgs e)
		{
			//Get latest location and start timer
			axArcReaderGlobeControl1.ARGlobe.GetObserverLocation(ref m_CurLong, ref m_CurLat, ref m_CurElev);
			m_RotateDirection = false;
			timer1.Enabled = true;

			//Unselect the current tool
			axArcReaderGlobeControl1.CurrentARGlobeTool = ESRI.ArcGIS.PublisherControls.esriARGlobeTool.esriARGlobeToolNoneSelected;

		}

		private void btnStop_Click(object sender, System.EventArgs e)
		{
			//Stops Timer
			timer1.Enabled = false;

			//Set the current tool to Globe Navigate
			axArcReaderGlobeControl1.CurrentARGlobeTool = ESRI.ArcGIS.PublisherControls.esriARGlobeTool.esriARGlobeToolNavigate;
		}

		private void btnAntiClockwise_Click(object sender, System.EventArgs e)
		{
			//Get latest location and start timer
			axArcReaderGlobeControl1.ARGlobe.GetObserverLocation(ref m_CurLong, ref m_CurLat, ref m_CurElev);
			m_RotateDirection = true;
			timer1.Enabled = true;

			//Unselect the current tool
			axArcReaderGlobeControl1.CurrentARGlobeTool = ESRI.ArcGIS.PublisherControls.esriARGlobeTool.esriARGlobeToolNoneSelected;
		}

		private void axArcReaderGlobeControl1_OnMouseUp(object sender, ESRI.ArcGIS.PublisherControls.IARGlobeControlEvents_OnMouseUpEvent e)
		{
			//Update m_CurLong incase observer has been repositioned as a consequence of using another tool.
			axArcReaderGlobeControl1.ARGlobe.GetObserverLocation(ref m_CurLong, ref m_CurLat, ref m_CurElev);
		}
	}
}

[Visual Basic .NET]

SpinGlobe.vb

Imports ESRI.ArcGIS

Public Class SpinGlobe
    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 btnAntiClockwise As System.Windows.Forms.Button
    Friend WithEvents btnClockwise As System.Windows.Forms.Button
    Friend WithEvents btnStop As System.Windows.Forms.Button
    Friend WithEvents TrackBar1 As System.Windows.Forms.TrackBar
    Friend WithEvents lblSlower As System.Windows.Forms.Label
    Friend WithEvents lblFaster As System.Windows.Forms.Label
    Friend WithEvents Timer1 As System.Windows.Forms.Timer
    Friend WithEvents AxArcReaderGlobeControl1 As ESRI.ArcGIS.PublisherControls.AxArcReaderGlobeControl
    Friend WithEvents OpenFileDialog1 As System.Windows.Forms.OpenFileDialog
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container
        Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(SpinGlobe))
        Me.btnLoad = New System.Windows.Forms.Button
        Me.btnAntiClockwise = New System.Windows.Forms.Button
        Me.btnClockwise = New System.Windows.Forms.Button
        Me.btnStop = New System.Windows.Forms.Button
        Me.TrackBar1 = New System.Windows.Forms.TrackBar
        Me.lblSlower = New System.Windows.Forms.Label
        Me.lblFaster = New System.Windows.Forms.Label
        Me.Timer1 = New System.Windows.Forms.Timer(Me.components)
        Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog
        Me.AxArcReaderGlobeControl1 = New ESRI.ArcGIS.PublisherControls.AxArcReaderGlobeControl
        CType(Me.TrackBar1, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.AxArcReaderGlobeControl1, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'btnLoad
        '
        Me.btnLoad.Location = New System.Drawing.Point(8, 8)
        Me.btnLoad.Name = "btnLoad"
        Me.btnLoad.Size = New System.Drawing.Size(76, 36)
        Me.btnLoad.TabIndex = 1
        Me.btnLoad.Text = "Load"
        '
        'btnAntiClockwise
        '
        Me.btnAntiClockwise.Location = New System.Drawing.Point(596, 8)
        Me.btnAntiClockwise.Name = "btnAntiClockwise"
        Me.btnAntiClockwise.Size = New System.Drawing.Size(76, 36)
        Me.btnAntiClockwise.TabIndex = 2
        Me.btnAntiClockwise.TextAlign = System.Drawing.ContentAlignment.BottomCenter
        '
        'btnClockwise
        '
        Me.btnClockwise.Location = New System.Drawing.Point(428, 8)
        Me.btnClockwise.Name = "btnClockwise"
        Me.btnClockwise.Size = New System.Drawing.Size(76, 36)
        Me.btnClockwise.TabIndex = 3
        Me.btnClockwise.TextAlign = System.Drawing.ContentAlignment.BottomCenter
        '
        'btnStop
        '
        Me.btnStop.Location = New System.Drawing.Point(512, 8)
        Me.btnStop.Name = "btnStop"
        Me.btnStop.Size = New System.Drawing.Size(76, 36)
        Me.btnStop.TabIndex = 4
        Me.btnStop.TextAlign = System.Drawing.ContentAlignment.BottomCenter
        '
        'TrackBar1
        '
        Me.TrackBar1.Location = New System.Drawing.Point(196, 4)
        Me.TrackBar1.Maximum = 1000
        Me.TrackBar1.Minimum = 100
        Me.TrackBar1.Name = "TrackBar1"
        Me.TrackBar1.Size = New System.Drawing.Size(164, 45)
        Me.TrackBar1.TabIndex = 5
        Me.TrackBar1.TickStyle = System.Windows.Forms.TickStyle.None
        Me.TrackBar1.Value = 100
        '
        'lblSlower
        '
        Me.lblSlower.Location = New System.Drawing.Point(364, 8)
        Me.lblSlower.Name = "lblSlower"
        Me.lblSlower.Size = New System.Drawing.Size(40, 20)
        Me.lblSlower.TabIndex = 6
        Me.lblSlower.Text = "Slower"
        '
        'lblFaster
        '
        Me.lblFaster.Location = New System.Drawing.Point(152, 8)
        Me.lblFaster.Name = "lblFaster"
        Me.lblFaster.Size = New System.Drawing.Size(40, 20)
        Me.lblFaster.TabIndex = 7
        Me.lblFaster.Text = "Faster"
        '
        'Timer1
        '
        '
        'AxArcReaderGlobeControl1
        '
        Me.AxArcReaderGlobeControl1.Location = New System.Drawing.Point(10, 52)
        Me.AxArcReaderGlobeControl1.Name = "AxArcReaderGlobeControl1"
        Me.AxArcReaderGlobeControl1.OcxState = CType(resources.GetObject("AxArcReaderGlobeControl1.OcxState"), System.Windows.Forms.AxHost.State)
        Me.AxArcReaderGlobeControl1.Size = New System.Drawing.Size(662, 367)
        Me.AxArcReaderGlobeControl1.TabIndex = 8
        '
        'SpinGlobe
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(688, 430)
        Me.Controls.Add(Me.AxArcReaderGlobeControl1)
        Me.Controls.Add(Me.lblFaster)
        Me.Controls.Add(Me.lblSlower)
        Me.Controls.Add(Me.TrackBar1)
        Me.Controls.Add(Me.btnStop)
        Me.Controls.Add(Me.btnClockwise)
        Me.Controls.Add(Me.btnAntiClockwise)
        Me.Controls.Add(Me.btnLoad)
        Me.Name = "SpinGlobe"
        Me.Text = "SpinGlobe"
        CType(Me.TrackBar1, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.AxArcReaderGlobeControl1, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)
        Me.PerformLayout()

    End Sub

#End Region

    'Variable that indicates direction of rotation
    'Clockwise = True; AntiClockwise = False
    Dim m_RotateDirection As Boolean
    Dim m_TimerInterval As Long
    Dim m_CurLat As Double
    Dim m_CurLong As Double
    Dim m_CurElev As Double
    Dim i As Double

    Private Sub SpinGlobe_Load(ByVal sender As System.Object, ByVal e 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(SpinGlobe).Assembly.GetManifestResourceStream(GetType(SpinGlobe), "spin_counterclockwise.bmp"))
        pBitmap = pImage
        pBitmap.MakeTransparent(System.Drawing.Color.Teal)
        btnAntiClockwise.Image = pImage
        pImage = New System.Drawing.Bitmap(GetType(SpinGlobe).Assembly.GetManifestResourceStream(GetType(SpinGlobe), "spin_clockwise.bmp"))
        pBitmap = pImage
        pBitmap.MakeTransparent(System.Drawing.Color.Teal)
        btnClockwise.Image = pImage
        pImage = New System.Drawing.Bitmap(GetType(SpinGlobe).Assembly.GetManifestResourceStream(GetType(SpinGlobe), "spin_stop.bmp"))
        pBitmap = pImage
        pBitmap.MakeTransparent(System.Drawing.Color.Teal)
        btnStop.Image = pImage

        'Set the current Slider value and timer interval to 100 milliseconds
        'Any faster and the Globe will not be able to refresh fast enough
        TrackBar1.Value = 100
        Timer1.Interval = 100
        Timer1.Enabled = False
        i = 0

        'Disable controls until doc is loaded
        btnAntiClockwise.Enabled = False
        btnClockwise.Enabled = False
        btnStop.Enabled = False

    End Sub

    Private Sub AxArcReaderGlobeControl1_OnMouseUp(ByVal sender As Object, ByVal e As ESRI.ArcGIS.PublisherControls.IARGlobeControlEvents_OnMouseUpEvent)

        'Update m_CurLong incase observer has been repositioned as a consequence of using another tool.
        AxArcReaderGlobeControl1.ARGlobe.GetObserverLocation(m_CurLong, m_CurLat, m_CurElev)

    End Sub

    Private Sub btnAntiClockwise_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAntiClockwise.Click

        'Get latest location and start timer
        AxArcReaderGlobeControl1.ARGlobe.GetObserverLocation(m_CurLong, m_CurLat, m_CurElev)
        m_RotateDirection = True
        Timer1.Enabled = True

        'Unselect the current tool
        AxArcReaderGlobeControl1.CurrentARGlobeTool = ESRI.ArcGIS.PublisherControls.esriARGlobeTool.esriARGlobeToolNoneSelected

    End Sub

    Private Sub btnClockwise_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClockwise.Click

        'Get latest location and start timer
        AxArcReaderGlobeControl1.ARGlobe.GetObserverLocation(m_CurLong, m_CurLat, m_CurElev)
        m_RotateDirection = False
        Timer1.Enabled = True

        'Unselect the current tool
        AxArcReaderGlobeControl1.CurrentARGlobeTool = ESRI.ArcGIS.PublisherControls.esriARGlobeTool.esriARGlobeToolNoneSelected

    End Sub

    Private Sub btnStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStop.Click

        'Stops Timer
        Timer1.Enabled = False

        'Set the current tool to Globe Navigate
        AxArcReaderGlobeControl1.CurrentARGlobeTool = ESRI.ArcGIS.PublisherControls.esriARGlobeTool.esriARGlobeToolNavigate

    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

        'Zoom to Full Extent
        AxArcReaderGlobeControl1.ARGlobe.ZoomToFullExtent()

        'Set current tool to Globe Navigate
        AxArcReaderGlobeControl1.CurrentARGlobeTool = ESRI.ArcGIS.PublisherControls.esriARGlobeTool.esriARGlobeToolNavigate


    End Sub


    Private Sub TrackBar1_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TrackBar1.ValueChanged

        'Update the timer interval to match the slider value
        Timer1.Interval = TrackBar1.Value

    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

        'Longitude Counter
        i = m_CurLong

        'Increment Longitude by 1 decimal degree
        If m_RotateDirection = False Then
            If i = 360 Then
                i = 0
            End If
            i = i + 1
        Else
            If i = -360 Then
                i = 0
            End If
            i = i - 1
        End If

        'Update the current location
        AxArcReaderGlobeControl1.ARGlobe.SetObserverLocation(i, m_CurLat, m_CurElev)
        AxArcReaderGlobeControl1.ARGlobe.GetObserverLocation(m_CurLong, m_CurLat, m_CurElev)

    End Sub

    Private Sub AxArcReaderGlobeControl1_OnDocumentUnloaded(ByVal sender As Object, ByVal e As System.EventArgs) Handles AxArcReaderGlobeControl1.OnDocumentUnloaded

        btnAntiClockwise.Enabled = False
        btnClockwise.Enabled = False
        btnStop.Enabled = False

    End Sub

    Private Sub AxArcReaderGlobeControl1_OnDocumentLoaded(ByVal sender As Object, ByVal e As ESRI.ArcGIS.PublisherControls.IARGlobeControlEvents_OnDocumentLoadedEvent) Handles AxArcReaderGlobeControl1.OnDocumentLoaded

        btnAntiClockwise.Enabled = True
        btnClockwise.Enabled = True
        btnStop.Enabled = True

    End Sub
End Class