Newer
Older
GHFX_REFACTOR / FrmFlyToPosition.cs
wxn on 2 Nov 2016 2 KB 提交
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;
using GeoScene.Data;
using GeoScene.Engine;
using GeoScene.Globe;

namespace Cyberpipe
{
    public partial class FrmFlyToPosition : Office2007Form
    {
        GSOGlobeControl globeControl;
        GSOGlobeControl globeControl2;
        public FrmFlyToPosition(GSOGlobeControl globeControl1, GSOGlobeControl globeControl2)
        {
            InitializeComponent();
            globeControl = globeControl1;
            this.globeControl2 = globeControl2;
            foreach (Location l in Utility.locationList)
            {
                comboBox1.Items.Add(l.NAME);
            }
        }

        public FrmFlyToPosition(GSOGlobeControl globeControl1)
        {
            InitializeComponent();
            globeControl = globeControl1;

            foreach (Location l in Utility.locationList)
            {
                comboBox1.Items.Add(l.NAME);
            }
        }

        private void buttonX1_Click(object sender, EventArgs e)
        {
            if (comboBox1.SelectedItem==null)
            {
                MessageBox.Show("请选择定位点!");
                return;
            }
            else
            {
                Location l = Utility.locationList.Find(
                delegate(Location location)
                {
                    return location.NAME.Equals(comboBox1.Text.Trim());
                });
                if (l != null)
                {
                    jumpToCameraState(l.X, l.Y, l.Z);
                }
                /*
                double x = Convert.ToDouble(Utility.Query_Roads[comboBox1.SelectedItem.ToString()].ToString().Split(',')[0]);
                double y = Convert.ToDouble(Utility.Query_Roads[comboBox1.SelectedItem.ToString()].ToString().Split(',')[1]);
                double z = Convert.ToDouble(Utility.Query_Roads[comboBox1.SelectedItem.ToString()].ToString().Split(',')[2]);
                jumpToCameraState(x, y, z);
                */
            }

        }

        /// <summary>
        /// 定位正北正90度俯视
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="z"></param>
        private void jumpToCameraState(double x, double y, double z)
        {
            GSOCameraState camera = new GSOCameraState();
            camera.Latitude = y;
            camera.Longitude = x;
            camera.Distance = z;
            camera.Tilt = 0;
            camera.Heading = 0;
            if (globeControl != null)
            {
                globeControl.Globe.JumpToCameraState(camera);
            }
            if (globeControl2 != null)
            {
                globeControl2.Globe.JumpToCameraState(camera);
            }
            

        }



    }
}