Newer
Older
EMS_REFACTOR / FrmFlyToPosition.cs
nn-203 on 26 Jul 2017 2 KB first commit
using System;
using System.Windows.Forms;
using DevComponents.DotNetBar;
using GeoScene.Globe;

namespace Cyberpipe
{
    public partial class FrmFlyToPosition : Office2007Form
    {
        GSOGlobeControl globeControl1;
        GSOGlobeControl globeControl2;

        public FrmFlyToPosition(GSOGlobeControl _globeControl1, GSOGlobeControl _globeControl2)
        {
            InitializeComponent();
            globeControl1 = _globeControl1;
            globeControl2 = _globeControl2;
            foreach (Location l in Utility.locationList)
                comboBox1.Items.Add(l.NAME);
        }

        public FrmFlyToPosition(GSOGlobeControl _globeControl1)
        {
            InitializeComponent();
            globeControl1 = _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);
            }
        }

        /// <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 (globeControl1 != null)
                globeControl1.Globe.JumpToCameraState(camera);
            if (globeControl2 != null)
                globeControl2.Globe.JumpToCameraState(camera);
        }

    }
}