Skyline - it's your world

Developer

Product Overview
Why should you choose SkylineGlobe products? Click here...

Contact Us

Developer - C#


Getting started

  1. Download and install TerraExplorer Plus.
  2. Create a new Windows Forms Application project in Visual Studio, using either C# or VB.Net:
    • In Visual Studio, select File> New> Project.
    • If you want to create a C# project: Select Visual C#> Windows> Windows Forms Application. Name the project TerraExplorerShowcase, and click OK.
    • If you want to create a Visual Basic project: Select Visual Basic> Windows> Windows Forms Application. Name the project TerraExplorerShowcase, and click OK.
  3. Add TerraExplorer ActiveX objects to the Toolbox.
    • In Design view, right click the Toolbox, and select Choose Items.
    • Click the COM Components tab and select the TE3DWindow Class, TEInformationWindow Class and TENavigationMap Class check-boxes.
    • Click OK. Three icons are added to your toolbox: the 3D Window, the Information Window and the Navigation Map controls.
  4. Add a 3D Window to the form.
    • Click the 3D window control icon in the toolbox and drag it to the required location on your form.
  5. Reference TerraExplorerX COM dll.
    • From the Project menu, select Add References.
    • Click the COM Components tab and locate TerraExplorerX 1.0 Type Library from the available references.
  6. Add the using directive for TerraExplorerX namespace in the Form1 code.
    using TerraExplorerX;
    Imports TerraExplorerX
  7. Define a variable to hold a SGWorld object instance.
    Note: You will use this variable later to access extensive TerraExplorer API.
    private SGWorld61 sgworld;
    Private sgworld As SGWorld61
  8. Initialize a SGWorld object.
    Note: This object will automatically find the ActiveX control that you have placed on the form and interact with it.

    Note: You should initialize this object only after the ActiveX object was already created, i.e. after the call to InitializeComponent() in the constructor.
    sgworld = new SGWorld61();
    sgworld = New SGWorld61
  9. Now you can use SGWorld object to control the TerraExplorer ActiveX. The following code loads a .fly project and flies to a specific location.
        public partial class Form1 : Form
        {
            private SGWorld61 sgworld;
            public Form1()
            {
                InitializeComponent();
                sgworld = new SGWorld61();
            }
     
            private void Form1_Load(object sender, EventArgs e)
            {
                // Register to OnLoadFinished globe event
                sgworld.OnLoadFinished += new _ISGWorld61Events_OnLoadFinishedEventHandler(OnProjectLoadFinished);
                // Open Project in asynchronous mode
                string flyFile = "http://www.skylineglobe.com/SkylineGlobe/WebClient/PresentationLayer/WebClient/SkyglobeLB.fly";
                sgworld.Project.Open(flyFile, truenullnull);
                MessageBox.Show("Opening project " + flyFile + " in async mode");
            }
     
            void OnProjectLoadFinished()
            {
                MessageBox.Show("Received project loaded event. Click OK to fly to  Washington DC.");
                IPosition61 Washington = sgworld.Creator.CreatePosition(-77.036667, 38.895111, 1500, AltitudeTypeCode.ATC_TERRAIN_RELATIVE, 0, 0, 0, 0);
                sgworld.Navigate.FlyTo(Washington);
            }
        }
    Imports TerraExplorerX
     
    Partial Public Class Form1
        Private sgworld As SGWorld61
        Public Sub New()
            InitializeComponent()
            sgworld = New SGWorld61()
        End Sub
     
        Private Sub Form1_Load(sender As Object, e As EventArgs)
            ' Register to OnLoadFinished globe event
            AddHandler sgworld.OnLoadFinished, AddressOf OnProjectLoadFinished
            ' Open Project in asynchronous mode
            Dim flyFile As String = "http://www.skylineglobe.com/SkylineGlobe/WebClient/PresentationLayer/WebClient/SkyglobeLB.fly"
            sgworld.Project.Open(flyFile, TrueNothingNothing)
            MessageBox.Show("Opening project " & flyFile & " in async mode")
        End Sub
     
        Private Sub OnProjectLoadFinished()
            MessageBox.Show("Received project loaded event. Click OK to fly to  Washington DC.")
            Dim Washington As IPosition61 = sgworld.Creator.CreatePosition(-77.036667, 38.895111, 1500, AltitudeTypeCode.ATC_TERRAIN_RELATIVE, 0, 0, 0, 0)
            sgworld.Navigate.FlyTo(Washington)
        End Sub
    End Class
  10. Download additional code samples and examples of TerraExplorer’s capabilities for C# or VB.Net.
    Note: Those samples require Visual Studio 2008.
  11. Visit SkylineGlobe to see an example of a working web application that utilizes TerraExplorer.

Related Links & Files

© 2011 Skyline Software Systems Inc. All rights reserved.  contact us  |  support  |  legal notice  |  privacy

Content

Close