About the Navigating around the SceneControl Sample
[C#]
SceneNavigateAndBookmarks.cs
using System; using System.Windows.Forms; using ESRI.ArcGIS.Analyst3D; using ESRI.ArcGIS.esriSystem; using ESRI.ArcGIS.SystemUI; using ESRI.ArcGIS; namespace SceneNavigateAndBookmarks { /// <summary> /// Summary description for Form1. /// </summary> public class SceneNavigateAndBookmarks : System.Windows.Forms.Form { public System.Windows.Forms.TextBox txtNewBookmarkName; public System.Windows.Forms.Button cmdCaptureBookmark; public System.Windows.Forms.ListBox lstBookmarks; public System.Windows.Forms.CheckBox chkRotate; public System.Windows.Forms.CheckBox chkNavigate; public System.Windows.Forms.Label Label5; public System.Windows.Forms.Label Label4; public System.Windows.Forms.Label Label3; public System.Windows.Forms.Label Label2; public System.Windows.Forms.Label Line3; public System.Windows.Forms.Label Line2; public System.Windows.Forms.Label Line1; public System.Windows.Forms.Label Label1; public System.Windows.Forms.Button cmdBrowse; public System.Windows.Forms.TextBox txtFileName; public System.Windows.Forms.Button cmdLoad; private System.Windows.Forms.OpenFileDialog openFileDialog1; private IArray m_Bookmarks = new ArrayClass(); private ESRI.ArcGIS.Controls.AxSceneControl axSceneControl1; private ESRI.ArcGIS.Controls.AxLicenseControl axLicenseControl1; /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.Container components = null; public SceneNavigateAndBookmarks() { // // 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 ) { //Release COM objects 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.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(SceneNavigateAndBookmarks)); this.txtNewBookmarkName = new System.Windows.Forms.TextBox(); this.cmdCaptureBookmark = new System.Windows.Forms.Button(); this.lstBookmarks = new System.Windows.Forms.ListBox(); this.chkRotate = new System.Windows.Forms.CheckBox(); this.chkNavigate = new System.Windows.Forms.CheckBox(); this.Label5 = new System.Windows.Forms.Label(); this.Label4 = new System.Windows.Forms.Label(); this.Label3 = new System.Windows.Forms.Label(); this.Label2 = new System.Windows.Forms.Label(); this.Line3 = new System.Windows.Forms.Label(); this.Line2 = new System.Windows.Forms.Label(); this.Line1 = new System.Windows.Forms.Label(); this.Label1 = new System.Windows.Forms.Label(); this.cmdBrowse = new System.Windows.Forms.Button(); this.txtFileName = new System.Windows.Forms.TextBox(); this.cmdLoad = new System.Windows.Forms.Button(); this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); this.axSceneControl1 = new ESRI.ArcGIS.Controls.AxSceneControl(); this.axLicenseControl1 = new ESRI.ArcGIS.Controls.AxLicenseControl(); ((System.ComponentModel.ISupportInitialize)(this.axSceneControl1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.axLicenseControl1)).BeginInit(); this.SuspendLayout(); // // txtNewBookmarkName // this.txtNewBookmarkName.AcceptsReturn = true; this.txtNewBookmarkName.AutoSize = false; this.txtNewBookmarkName.BackColor = System.Drawing.SystemColors.Window; this.txtNewBookmarkName.Cursor = System.Windows.Forms.Cursors.IBeam; this.txtNewBookmarkName.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.txtNewBookmarkName.ForeColor = System.Drawing.SystemColors.WindowText; this.txtNewBookmarkName.Location = new System.Drawing.Point(152, 480); this.txtNewBookmarkName.MaxLength = 0; this.txtNewBookmarkName.Name = "txtNewBookmarkName"; this.txtNewBookmarkName.RightToLeft = System.Windows.Forms.RightToLeft.No; this.txtNewBookmarkName.Size = new System.Drawing.Size(121, 27); this.txtNewBookmarkName.TabIndex = 16; this.txtNewBookmarkName.Text = "New Bookmark"; // // cmdCaptureBookmark // this.cmdCaptureBookmark.BackColor = System.Drawing.SystemColors.Control; this.cmdCaptureBookmark.Cursor = System.Windows.Forms.Cursors.Default; this.cmdCaptureBookmark.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.cmdCaptureBookmark.ForeColor = System.Drawing.SystemColors.ControlText; this.cmdCaptureBookmark.Location = new System.Drawing.Point(8, 480); this.cmdCaptureBookmark.Name = "cmdCaptureBookmark"; this.cmdCaptureBookmark.RightToLeft = System.Windows.Forms.RightToLeft.No; this.cmdCaptureBookmark.Size = new System.Drawing.Size(137, 25); this.cmdCaptureBookmark.TabIndex = 15; this.cmdCaptureBookmark.Text = "Capture Bookmark"; this.cmdCaptureBookmark.Click += new System.EventHandler(this.cmdCaptureBookmark_Click); // // lstBookmarks // this.lstBookmarks.BackColor = System.Drawing.SystemColors.Window; this.lstBookmarks.Cursor = System.Windows.Forms.Cursors.Default; this.lstBookmarks.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.lstBookmarks.ForeColor = System.Drawing.SystemColors.WindowText; this.lstBookmarks.ItemHeight = 14; this.lstBookmarks.Location = new System.Drawing.Point(8, 392); this.lstBookmarks.Name = "lstBookmarks"; this.lstBookmarks.RightToLeft = System.Windows.Forms.RightToLeft.No; this.lstBookmarks.Size = new System.Drawing.Size(265, 74); this.lstBookmarks.TabIndex = 14; this.lstBookmarks.SelectedIndexChanged += new System.EventHandler(this.lstBookmarks_SelectedIndexChanged); // // chkRotate // this.chkRotate.BackColor = System.Drawing.SystemColors.Control; this.chkRotate.Cursor = System.Windows.Forms.Cursors.Default; this.chkRotate.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.chkRotate.ForeColor = System.Drawing.SystemColors.ControlText; this.chkRotate.Location = new System.Drawing.Point(296, 464); this.chkRotate.Name = "chkRotate"; this.chkRotate.RightToLeft = System.Windows.Forms.RightToLeft.No; this.chkRotate.Size = new System.Drawing.Size(121, 25); this.chkRotate.TabIndex = 18; this.chkRotate.Text = "Rotate Gesture"; this.chkRotate.CheckedChanged += new System.EventHandler(this.chkRotate_CheckedChanged); // // chkNavigate // this.chkNavigate.BackColor = System.Drawing.SystemColors.Control; this.chkNavigate.Cursor = System.Windows.Forms.Cursors.Default; this.chkNavigate.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.chkNavigate.ForeColor = System.Drawing.SystemColors.ControlText; this.chkNavigate.Location = new System.Drawing.Point(296, 384); this.chkNavigate.Name = "chkNavigate"; this.chkNavigate.RightToLeft = System.Windows.Forms.RightToLeft.No; this.chkNavigate.Size = new System.Drawing.Size(113, 25); this.chkNavigate.TabIndex = 17; this.chkNavigate.Text = "Navigate Mode"; this.chkNavigate.CheckedChanged += new System.EventHandler(this.chkNavigate_CheckedChanged); // // Label5 // this.Label5.BackColor = System.Drawing.SystemColors.Control; this.Label5.Cursor = System.Windows.Forms.Cursors.Default; this.Label5.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.Label5.ForeColor = System.Drawing.SystemColors.ControlText; this.Label5.Location = new System.Drawing.Point(424, 448); this.Label5.Name = "Label5"; this.Label5.RightToLeft = System.Windows.Forms.RightToLeft.No; this.Label5.Size = new System.Drawing.Size(169, 65); this.Label5.TabIndex = 22; this.Label5.Text = "Hold down left mouse button, move mouse left (or right) and keep mouse moving whi" + "le releasing the left button. Press ESC to stop rotation."; // // Label4 // this.Label4.BackColor = System.Drawing.SystemColors.Control; this.Label4.Cursor = System.Windows.Forms.Cursors.Default; this.Label4.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.Label4.ForeColor = System.Drawing.SystemColors.ControlText; this.Label4.Location = new System.Drawing.Point(424, 392); this.Label4.Name = "Label4"; this.Label4.RightToLeft = System.Windows.Forms.RightToLeft.No; this.Label4.Size = new System.Drawing.Size(169, 17); this.Label4.TabIndex = 21; this.Label4.Text = "Middle mouse to pan"; // // Label3 // this.Label3.BackColor = System.Drawing.SystemColors.Control; this.Label3.Cursor = System.Windows.Forms.Cursors.Default; this.Label3.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.Label3.ForeColor = System.Drawing.SystemColors.ControlText; this.Label3.Location = new System.Drawing.Point(424, 408); this.Label3.Name = "Label3"; this.Label3.RightToLeft = System.Windows.Forms.RightToLeft.No; this.Label3.Size = new System.Drawing.Size(169, 17); this.Label3.TabIndex = 20; this.Label3.Text = "Right mouse to zoom in and out"; // // Label2 // this.Label2.BackColor = System.Drawing.SystemColors.Control; this.Label2.Cursor = System.Windows.Forms.Cursors.Default; this.Label2.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.Label2.ForeColor = System.Drawing.SystemColors.ControlText; this.Label2.Location = new System.Drawing.Point(424, 376); this.Label2.Name = "Label2"; this.Label2.RightToLeft = System.Windows.Forms.RightToLeft.No; this.Label2.Size = new System.Drawing.Size(153, 17); this.Label2.TabIndex = 19; this.Label2.Text = "Left mouse to rotate"; // // Line3 // this.Line3.BackColor = System.Drawing.SystemColors.WindowText; this.Line3.Location = new System.Drawing.Point(8, 360); this.Line3.Name = "Line3"; this.Line3.Size = new System.Drawing.Size(584, 1); this.Line3.TabIndex = 23; // // Line2 // this.Line2.BackColor = System.Drawing.SystemColors.WindowText; this.Line2.Location = new System.Drawing.Point(288, 440); this.Line2.Name = "Line2"; this.Line2.Size = new System.Drawing.Size(304, 1); this.Line2.TabIndex = 24; // // Line1 // this.Line1.BackColor = System.Drawing.SystemColors.WindowText; this.Line1.Location = new System.Drawing.Point(288, 360); this.Line1.Name = "Line1"; this.Line1.Size = new System.Drawing.Size(1, 152); this.Line1.TabIndex = 25; // // Label1 // this.Label1.BackColor = System.Drawing.SystemColors.Control; this.Label1.Cursor = System.Windows.Forms.Cursors.Default; this.Label1.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.Label1.ForeColor = System.Drawing.SystemColors.ControlText; this.Label1.Location = new System.Drawing.Point(8, 368); this.Label1.Name = "Label1"; this.Label1.RightToLeft = System.Windows.Forms.RightToLeft.No; this.Label1.Size = new System.Drawing.Size(265, 17); this.Label1.TabIndex = 26; this.Label1.Text = "Bookmarks: Click on name below"; // // cmdBrowse // this.cmdBrowse.BackColor = System.Drawing.SystemColors.Control; this.cmdBrowse.Cursor = System.Windows.Forms.Cursors.Default; this.cmdBrowse.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.cmdBrowse.ForeColor = System.Drawing.SystemColors.ControlText; this.cmdBrowse.Location = new System.Drawing.Point(528, 328); this.cmdBrowse.Name = "cmdBrowse"; this.cmdBrowse.RightToLeft = System.Windows.Forms.RightToLeft.No; this.cmdBrowse.Size = new System.Drawing.Size(65, 25); this.cmdBrowse.TabIndex = 29; this.cmdBrowse.Text = "Browse..."; this.cmdBrowse.Click += new System.EventHandler(this.cmdBrowse_Click); // // txtFileName // this.txtFileName.AcceptsReturn = true; this.txtFileName.AutoSize = false; this.txtFileName.BackColor = System.Drawing.SystemColors.Window; this.txtFileName.Cursor = System.Windows.Forms.Cursors.IBeam; this.txtFileName.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.txtFileName.ForeColor = System.Drawing.SystemColors.WindowText; this.txtFileName.Location = new System.Drawing.Point(88, 328); this.txtFileName.MaxLength = 0; this.txtFileName.Name = "txtFileName"; this.txtFileName.RightToLeft = System.Windows.Forms.RightToLeft.No; this.txtFileName.Size = new System.Drawing.Size(433, 25); this.txtFileName.TabIndex = 28; this.txtFileName.Text = "Enter a path to a scene document to load into the SceneControl"; // // 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(8, 328); this.cmdLoad.Name = "cmdLoad"; this.cmdLoad.RightToLeft = System.Windows.Forms.RightToLeft.No; this.cmdLoad.Size = new System.Drawing.Size(73, 25); this.cmdLoad.TabIndex = 27; this.cmdLoad.Text = "Load"; this.cmdLoad.Click += new System.EventHandler(this.cmdLoad_Click); // // axSceneControl1 // this.axSceneControl1.Location = new System.Drawing.Point(8, 8); this.axSceneControl1.Name = "axSceneControl1"; this.axSceneControl1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axSceneControl1.OcxState"))); this.axSceneControl1.Size = new System.Drawing.Size(584, 312); this.axSceneControl1.TabIndex = 30; // // axLicenseControl1 // this.axLicenseControl1.Enabled = true; this.axLicenseControl1.Location = new System.Drawing.Point(376, 24); this.axLicenseControl1.Name = "axLicenseControl1"; this.axLicenseControl1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axLicenseControl1.OcxState"))); this.axLicenseControl1.Size = new System.Drawing.Size(200, 50); this.axLicenseControl1.TabIndex = 31; // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(600, 526); this.Controls.Add(this.axLicenseControl1); this.Controls.Add(this.axSceneControl1); this.Controls.Add(this.cmdBrowse); this.Controls.Add(this.txtFileName); this.Controls.Add(this.cmdLoad); this.Controls.Add(this.Label1); this.Controls.Add(this.Line3); this.Controls.Add(this.Line2); this.Controls.Add(this.Line1); this.Controls.Add(this.chkRotate); this.Controls.Add(this.chkNavigate); this.Controls.Add(this.Label5); this.Controls.Add(this.Label4); this.Controls.Add(this.Label3); this.Controls.Add(this.Label2); this.Controls.Add(this.txtNewBookmarkName); this.Controls.Add(this.cmdCaptureBookmark); this.Controls.Add(this.lstBookmarks); this.Name = "Form1"; this.Text = "Form1"; this.Load += new System.EventHandler(this.Form1_Load); ((System.ComponentModel.ISupportInitialize)(this.axSceneControl1)).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 SceneNavigateAndBookmarks()); } private void Form1_Load(object sender, System.EventArgs e) { chkNavigate.Checked = axSceneControl1.Navigate; } private void cmdLoad_Click(object sender, System.EventArgs e) { // Load the specified document if (axSceneControl1.CheckSxFile(txtFileName.Text) == true) { axSceneControl1.LoadSxFile(txtFileName.Text); } else { System.Windows.Forms.MessageBox.Show("This document cannot be loaded!"); return; } UpdateBookmarks(); } private void cmdBrowse_Click(object sender, System.EventArgs e) { //Open a file dialog for selecting map documents openFileDialog1.Title = "Scene Documents"; openFileDialog1.DefaultExt = ".sxd"; openFileDialog1.Filter = "Scene Documents (*.sxd)|*.sxd|Scene Templates (*.sxt)|*.sxt"; openFileDialog1.ShowDialog(); txtFileName.Text = openFileDialog1.FileName; //Try and load the filename cmdLoad_Click(cmdLoad, new System.EventArgs()); } private void cmdCaptureBookmark_Click(object sender, System.EventArgs e) { IBookmark3D bookmark3d = new Bookmark3DClass(); bookmark3d.Name = txtNewBookmarkName.Text; bookmark3d.Capture(axSceneControl1.Camera); ISceneBookmarks bookmarks = (ISceneBookmarks) axSceneControl1.Scene; bookmarks.AddBookmark(bookmark3d); UpdateBookmarks(); } private void lstBookmarks_SelectedIndexChanged(object sender, System.EventArgs e) { //Get a bookmark corresponding to list and apply it to the SceneViewer IBookmark3D bookmark = (IBookmark3D) m_Bookmarks.get_Element(lstBookmarks.SelectedIndex); //Switch to new bookmark location bookmark.Apply(axSceneControl1.SceneViewer, false, 0); } private void UpdateBookmarks() { //Get bookmarks from Scene ISceneBookmarks bookmarks = (ISceneBookmarks) axSceneControl1.Scene; m_Bookmarks = null; m_Bookmarks = bookmarks.Bookmarks; lstBookmarks.Items.Clear(); bool haveBookmarks = false; IBookmark3D bookmark3d; if (m_Bookmarks != null) { //Add the bookmark names to the listbox in the same order as they are in the Scene Document for (int i = 0; i <= m_Bookmarks.Count - 1; i++) { bookmark3d = (IBookmark3D) m_Bookmarks.get_Element(i); lstBookmarks.Items.Add(bookmark3d.Name); } haveBookmarks = m_Bookmarks.Count != 0; lstBookmarks.Enabled = true; } if (haveBookmarks == false) { //No bookmarks available lstBookmarks.Items.Add("<No Bookmarks Available>"); lstBookmarks.Enabled = false; } } private void chkNavigate_CheckedChanged(object sender, System.EventArgs e) { //Enable navigation mode axSceneControl1.Navigate = (bool) chkNavigate.Checked; } private void chkRotate_CheckedChanged(object sender, System.EventArgs e) { //Enable rotate gesture if checked axSceneControl1.SceneViewer.GestureEnabled = chkRotate.Checked; } } }
[Visual Basic .NET]
SceneNavigateAndBookmarks.vb
Imports ESRI.ArcGIS.esriSystem Imports ESRI.ArcGIS.SystemUI Imports ESRI.ArcGIS.Analyst3D Imports ESRI.ArcGIS Public Class Form1 Inherits System.Windows.Forms.Form <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() End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal Disposing As Boolean) 'Release COM objects ESRI.ArcGIS.ADF.COMSupport.AOUninitialize.Shutdown() 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 txtNewBookmarkName As System.Windows.Forms.TextBox Public WithEvents cmdCaptureBookmark As System.Windows.Forms.Button Public WithEvents cmdBrowse As System.Windows.Forms.Button Public WithEvents txtFileName As System.Windows.Forms.TextBox Public WithEvents chkRotate As System.Windows.Forms.CheckBox Public WithEvents chkNavigate As System.Windows.Forms.CheckBox Public WithEvents lstBookmarks As System.Windows.Forms.ListBox Public WithEvents cmdLoad As System.Windows.Forms.Button Public WithEvents Label5 As System.Windows.Forms.Label Public WithEvents Line3 As System.Windows.Forms.Label Public WithEvents Line2 As System.Windows.Forms.Label Public WithEvents Line1 As System.Windows.Forms.Label Public WithEvents Label4 As System.Windows.Forms.Label Public WithEvents Label3 As System.Windows.Forms.Label Public WithEvents Label2 As System.Windows.Forms.Label Public WithEvents Label1 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. Friend WithEvents OpenFileDialog1 As System.Windows.Forms.OpenFileDialog Friend WithEvents AxSceneControl1 As ESRI.ArcGIS.Controls.AxSceneControl Friend WithEvents AxLicenseControl1 As ESRI.ArcGIS.Controls.AxLicenseControl <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1)) Me.txtNewBookmarkName = New System.Windows.Forms.TextBox Me.cmdCaptureBookmark = New System.Windows.Forms.Button Me.cmdBrowse = New System.Windows.Forms.Button Me.txtFileName = New System.Windows.Forms.TextBox Me.chkRotate = New System.Windows.Forms.CheckBox Me.chkNavigate = New System.Windows.Forms.CheckBox Me.lstBookmarks = New System.Windows.Forms.ListBox Me.cmdLoad = New System.Windows.Forms.Button Me.Label5 = New System.Windows.Forms.Label Me.Line3 = New System.Windows.Forms.Label Me.Line2 = New System.Windows.Forms.Label Me.Line1 = New System.Windows.Forms.Label Me.Label4 = New System.Windows.Forms.Label Me.Label3 = New System.Windows.Forms.Label Me.Label2 = New System.Windows.Forms.Label Me.Label1 = New System.Windows.Forms.Label Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog Me.AxSceneControl1 = New ESRI.ArcGIS.Controls.AxSceneControl Me.AxLicenseControl1 = New ESRI.ArcGIS.Controls.AxLicenseControl CType(Me.AxSceneControl1, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.AxLicenseControl1, System.ComponentModel.ISupportInitialize).BeginInit() Me.SuspendLayout() ' 'txtNewBookmarkName ' Me.txtNewBookmarkName.AcceptsReturn = True Me.txtNewBookmarkName.AutoSize = False Me.txtNewBookmarkName.BackColor = System.Drawing.SystemColors.Window Me.txtNewBookmarkName.Cursor = System.Windows.Forms.Cursors.IBeam Me.txtNewBookmarkName.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.txtNewBookmarkName.ForeColor = System.Drawing.SystemColors.WindowText Me.txtNewBookmarkName.Location = New System.Drawing.Point(152, 440) Me.txtNewBookmarkName.MaxLength = 0 Me.txtNewBookmarkName.Name = "txtNewBookmarkName" Me.txtNewBookmarkName.RightToLeft = System.Windows.Forms.RightToLeft.No Me.txtNewBookmarkName.Size = New System.Drawing.Size(121, 27) Me.txtNewBookmarkName.TabIndex = 13 Me.txtNewBookmarkName.Text = "New Bookmark" ' 'cmdCaptureBookmark ' Me.cmdCaptureBookmark.BackColor = System.Drawing.SystemColors.Control Me.cmdCaptureBookmark.Cursor = System.Windows.Forms.Cursors.Default Me.cmdCaptureBookmark.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.cmdCaptureBookmark.ForeColor = System.Drawing.SystemColors.ControlText Me.cmdCaptureBookmark.Location = New System.Drawing.Point(8, 440) Me.cmdCaptureBookmark.Name = "cmdCaptureBookmark" Me.cmdCaptureBookmark.RightToLeft = System.Windows.Forms.RightToLeft.No Me.cmdCaptureBookmark.Size = New System.Drawing.Size(137, 25) Me.cmdCaptureBookmark.TabIndex = 12 Me.cmdCaptureBookmark.Text = "Capture Bookmark" ' 'cmdBrowse ' Me.cmdBrowse.BackColor = System.Drawing.SystemColors.Control Me.cmdBrowse.Cursor = System.Windows.Forms.Cursors.Default Me.cmdBrowse.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.cmdBrowse.ForeColor = System.Drawing.SystemColors.ControlText Me.cmdBrowse.Location = New System.Drawing.Point(528, 280) Me.cmdBrowse.Name = "cmdBrowse" Me.cmdBrowse.RightToLeft = System.Windows.Forms.RightToLeft.No Me.cmdBrowse.Size = New System.Drawing.Size(65, 25) Me.cmdBrowse.TabIndex = 7 Me.cmdBrowse.Text = "Browse..." ' 'txtFileName ' Me.txtFileName.AcceptsReturn = True Me.txtFileName.AutoSize = False Me.txtFileName.BackColor = System.Drawing.SystemColors.Window Me.txtFileName.Cursor = System.Windows.Forms.Cursors.IBeam Me.txtFileName.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.txtFileName.ForeColor = System.Drawing.SystemColors.WindowText Me.txtFileName.Location = New System.Drawing.Point(88, 280) Me.txtFileName.MaxLength = 0 Me.txtFileName.Name = "txtFileName" Me.txtFileName.RightToLeft = System.Windows.Forms.RightToLeft.No Me.txtFileName.Size = New System.Drawing.Size(433, 25) Me.txtFileName.TabIndex = 6 Me.txtFileName.Text = "Enter a path to a scene document to load into the SceneControl" ' 'chkRotate ' Me.chkRotate.BackColor = System.Drawing.SystemColors.Control Me.chkRotate.Cursor = System.Windows.Forms.Cursors.Default Me.chkRotate.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.chkRotate.ForeColor = System.Drawing.SystemColors.ControlText Me.chkRotate.Location = New System.Drawing.Point(304, 416) Me.chkRotate.Name = "chkRotate" Me.chkRotate.RightToLeft = System.Windows.Forms.RightToLeft.No Me.chkRotate.Size = New System.Drawing.Size(121, 25) Me.chkRotate.TabIndex = 4 Me.chkRotate.Text = "Rotate Gesture" ' 'chkNavigate ' Me.chkNavigate.BackColor = System.Drawing.SystemColors.Control Me.chkNavigate.Cursor = System.Windows.Forms.Cursors.Default Me.chkNavigate.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.chkNavigate.ForeColor = System.Drawing.SystemColors.ControlText Me.chkNavigate.Location = New System.Drawing.Point(304, 336) Me.chkNavigate.Name = "chkNavigate" Me.chkNavigate.RightToLeft = System.Windows.Forms.RightToLeft.No Me.chkNavigate.Size = New System.Drawing.Size(113, 25) Me.chkNavigate.TabIndex = 3 Me.chkNavigate.Text = "Navigate Mode" ' 'lstBookmarks ' Me.lstBookmarks.BackColor = System.Drawing.SystemColors.Window Me.lstBookmarks.Cursor = System.Windows.Forms.Cursors.Default Me.lstBookmarks.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.lstBookmarks.ForeColor = System.Drawing.SystemColors.WindowText Me.lstBookmarks.ItemHeight = 14 Me.lstBookmarks.Location = New System.Drawing.Point(8, 352) Me.lstBookmarks.Name = "lstBookmarks" Me.lstBookmarks.RightToLeft = System.Windows.Forms.RightToLeft.No Me.lstBookmarks.Size = New System.Drawing.Size(265, 74) Me.lstBookmarks.TabIndex = 2 ' '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(8, 280) Me.cmdLoad.Name = "cmdLoad" Me.cmdLoad.RightToLeft = System.Windows.Forms.RightToLeft.No Me.cmdLoad.Size = New System.Drawing.Size(73, 25) Me.cmdLoad.TabIndex = 1 Me.cmdLoad.Text = "Load" ' 'Label5 ' Me.Label5.BackColor = System.Drawing.SystemColors.Control Me.Label5.Cursor = System.Windows.Forms.Cursors.Default Me.Label5.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label5.ForeColor = System.Drawing.SystemColors.ControlText Me.Label5.Location = New System.Drawing.Point(432, 400) Me.Label5.Name = "Label5" Me.Label5.RightToLeft = System.Windows.Forms.RightToLeft.No Me.Label5.Size = New System.Drawing.Size(169, 65) Me.Label5.TabIndex = 11 Me.Label5.Text = "Hold down left mouse button, move mouse left (or right) and keep mouse moving whi" & _ "le releasing the left button. Press ESC to stop rotation." ' 'Line3 ' Me.Line3.BackColor = System.Drawing.SystemColors.WindowText Me.Line3.Location = New System.Drawing.Point(8, 312) Me.Line3.Name = "Line3" Me.Line3.Size = New System.Drawing.Size(584, 1) Me.Line3.TabIndex = 14 ' 'Line2 ' Me.Line2.BackColor = System.Drawing.SystemColors.WindowText Me.Line2.Location = New System.Drawing.Point(288, 392) Me.Line2.Name = "Line2" Me.Line2.Size = New System.Drawing.Size(304, 1) Me.Line2.TabIndex = 15 ' 'Line1 ' Me.Line1.BackColor = System.Drawing.SystemColors.WindowText Me.Line1.Location = New System.Drawing.Point(288, 312) Me.Line1.Name = "Line1" Me.Line1.Size = New System.Drawing.Size(1, 152) Me.Line1.TabIndex = 16 ' 'Label4 ' Me.Label4.BackColor = System.Drawing.SystemColors.Control Me.Label4.Cursor = System.Windows.Forms.Cursors.Default Me.Label4.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label4.ForeColor = System.Drawing.SystemColors.ControlText Me.Label4.Location = New System.Drawing.Point(432, 344) Me.Label4.Name = "Label4" Me.Label4.RightToLeft = System.Windows.Forms.RightToLeft.No Me.Label4.Size = New System.Drawing.Size(169, 17) Me.Label4.TabIndex = 10 Me.Label4.Text = "Middle mouse to pan" ' 'Label3 ' Me.Label3.BackColor = System.Drawing.SystemColors.Control Me.Label3.Cursor = System.Windows.Forms.Cursors.Default Me.Label3.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label3.ForeColor = System.Drawing.SystemColors.ControlText Me.Label3.Location = New System.Drawing.Point(432, 360) Me.Label3.Name = "Label3" Me.Label3.RightToLeft = System.Windows.Forms.RightToLeft.No Me.Label3.Size = New System.Drawing.Size(169, 17) Me.Label3.TabIndex = 9 Me.Label3.Text = "Right mouse to zoom in and out" ' 'Label2 ' Me.Label2.BackColor = System.Drawing.SystemColors.Control Me.Label2.Cursor = System.Windows.Forms.Cursors.Default Me.Label2.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label2.ForeColor = System.Drawing.SystemColors.ControlText Me.Label2.Location = New System.Drawing.Point(432, 328) Me.Label2.Name = "Label2" Me.Label2.RightToLeft = System.Windows.Forms.RightToLeft.No Me.Label2.Size = New System.Drawing.Size(153, 17) Me.Label2.TabIndex = 8 Me.Label2.Text = "Left mouse to rotate" ' 'Label1 ' Me.Label1.BackColor = System.Drawing.SystemColors.Control Me.Label1.Cursor = System.Windows.Forms.Cursors.Default Me.Label1.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label1.ForeColor = System.Drawing.SystemColors.ControlText Me.Label1.Location = New System.Drawing.Point(8, 328) Me.Label1.Name = "Label1" Me.Label1.RightToLeft = System.Windows.Forms.RightToLeft.No Me.Label1.Size = New System.Drawing.Size(265, 17) Me.Label1.TabIndex = 5 Me.Label1.Text = "Bookmarks: Click on name below" ' 'AxSceneControl1 ' Me.AxSceneControl1.Location = New System.Drawing.Point(8, 8) Me.AxSceneControl1.Name = "AxSceneControl1" Me.AxSceneControl1.OcxState = CType(resources.GetObject("AxSceneControl1.OcxState"), System.Windows.Forms.AxHost.State) Me.AxSceneControl1.Size = New System.Drawing.Size(592, 264) Me.AxSceneControl1.TabIndex = 17 ' 'AxLicenseControl1 ' Me.AxLicenseControl1.Enabled = True Me.AxLicenseControl1.Location = New System.Drawing.Point(384, 24) Me.AxLicenseControl1.Name = "AxLicenseControl1" Me.AxLicenseControl1.OcxState = CType(resources.GetObject("AxLicenseControl1.OcxState"), System.Windows.Forms.AxHost.State) Me.AxLicenseControl1.Size = New System.Drawing.Size(200, 50) Me.AxLicenseControl1.TabIndex = 18 ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.BackColor = System.Drawing.SystemColors.Control Me.ClientSize = New System.Drawing.Size(606, 476) Me.Controls.Add(Me.AxLicenseControl1) Me.Controls.Add(Me.AxSceneControl1) Me.Controls.Add(Me.txtNewBookmarkName) Me.Controls.Add(Me.cmdCaptureBookmark) Me.Controls.Add(Me.cmdBrowse) Me.Controls.Add(Me.txtFileName) Me.Controls.Add(Me.chkRotate) Me.Controls.Add(Me.chkNavigate) Me.Controls.Add(Me.lstBookmarks) Me.Controls.Add(Me.cmdLoad) Me.Controls.Add(Me.Label5) Me.Controls.Add(Me.Line3) Me.Controls.Add(Me.Line2) Me.Controls.Add(Me.Line1) Me.Controls.Add(Me.Label4) Me.Controls.Add(Me.Label3) Me.Controls.Add(Me.Label2) Me.Controls.Add(Me.Label1) Me.Cursor = System.Windows.Forms.Cursors.Default Me.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Location = New System.Drawing.Point(4, 30) Me.Name = "Form1" Me.RightToLeft = System.Windows.Forms.RightToLeft.No Me.Text = "Form1" CType(Me.AxSceneControl1, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.AxLicenseControl1, System.ComponentModel.ISupportInitialize).EndInit() Me.ResumeLayout(False) End Sub #End Region 'Hold an array of the Scene Bookmarks Dim m_pBookmarks As IArray Private Sub cmdBrowse_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdBrowse.Click OpenFileDialog1.Title = "Scene Documents" OpenFileDialog1.DefaultExt = ".sxd" OpenFileDialog1.Filter = "Scene Documents (*.sxd)|*.sxd|Scene Templates (*.sxt)|*.sxt" OpenFileDialog1.ShowDialog() txtFileName.Text = OpenFileDialog1.FileName 'Try and load the filename cmdLoad_Click(cmdLoad, New System.EventArgs) End Sub Private Sub cmdCaptureBookmark_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdCaptureBookmark.Click Dim pBookmark3d As IBookmark3D pBookmark3d = New Bookmark3DClass pBookmark3d.Name = txtNewBookmarkName.Text pBookmark3d.Capture(AxSceneControl1.Camera) Dim pBookmarks As ISceneBookmarks pBookmarks = AxSceneControl1.Scene pBookmarks.AddBookmark(pBookmark3d) UpdateBookmarks() End Sub Private Sub cmdLoad_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdLoad.Click On Error GoTo errorHandler AxSceneControl1.LoadSxFile(txtFileName.Text) UpdateBookmarks() Exit Sub errorHandler: MsgBox("Error occurred trying to load Scene Document: " & vbCrLf & Err.Description, MsgBoxStyle.Exclamation) End Sub Private Sub Form1_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load chkNavigate.CheckState = AxSceneControl1.Navigate End Sub Private Sub lstBookmarks_SelectedIndexChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles lstBookmarks.SelectedIndexChanged 'Get a bookmark corresponding to list and apply it to the SceneViewer Dim pBookmark As IBookmark3D pBookmark = m_pBookmarks.Element(lstBookmarks.SelectedIndex) 'Switch to new bookmark location pBookmark.Apply(AxSceneControl1.SceneViewer, False, 0) End Sub Private Sub UpdateBookmarks() 'Get bookmarks from Scene Dim pBookmarks As ISceneBookmarks pBookmarks = AxSceneControl1.Scene m_pBookmarks = Nothing m_pBookmarks = pBookmarks.Bookmarks lstBookmarks.Items.Clear() Dim haveBookmarks As Boolean haveBookmarks = False Dim pBookmark3d As IBookmark3D Dim i As Integer If (Not m_pBookmarks Is Nothing) Then 'Add the bookmark names to the listbox in the same order as they are in the Scene Document For i = 0 To m_pBookmarks.Count - 1 pBookmark3d = m_pBookmarks.Element(i) lstBookmarks.Items.Add(pBookmark3d.Name) Next haveBookmarks = m_pBookmarks.Count <> 0 lstBookmarks.Enabled = True End If If (Not haveBookmarks) Then 'No bookmarks available lstBookmarks.Items.Add("<No Bookmarks Available>") lstBookmarks.Enabled = False End If End Sub Private Sub chkNavigate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles chkNavigate.Click 'Enable navigation mode AxSceneControl1.Navigate = chkNavigate.CheckState End Sub Private Sub chkRotate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles chkRotate.Click 'Enable rotate gesture if checked AxSceneControl1.SceneViewer.GestureEnabled = chkRotate.CheckState End Sub End Class