Newer
Older
GHFX_REFACTOR / Backup / FrmSetFlytoPos.cs
wxn on 2 Nov 2016 4 KB 提交
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using GeoScene.Data;
using GeoScene.Engine;
using GeoScene.Globe;

namespace Cyberpipe
{
    public partial class FrmSetFlytoPos : DevComponents.DotNetBar.Office2007Form
    {
        GSOGlobeControl globeControl1;

        static FrmSetFlytoPos frm;
        public static void ShowForm(GSOGlobeControl globecontrol)
        {
            if (frm == null)
            {
                frm = new FrmSetFlytoPos(globecontrol);
                frm.Show(globecontrol.Parent);
            }
            else
            {
                if (frm.WindowState == FormWindowState.Minimized)
                {
                    frm.WindowState = FormWindowState.Normal;
                }
            }
        }

        public FrmSetFlytoPos(GSOGlobeControl globecontrol)
        {
            InitializeComponent();
            globeControl1 = globecontrol;
        }

        private void SetLatLonPos_Load(object sender, EventArgs e)
        {

        }
        /// <summary>
        /// 确定按钮事件处理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {            
            double m_strLon;
            double m_strLat;
            double m_strAlt;

            if (textbox1.Text == "")
            {
                MessageBox.Show("经度不能为空!");
                return;
            }
            else
            {
                bool bl = double.TryParse(textbox1.Text,out m_strLon);
                if (!bl)
                {
                    MessageBox.Show("请输入正确的经度!");
                    textbox1.Text = "";
                    return;
                }
                else
                {
                    if (m_strLon > 180 || m_strLon < -180)
                    {
                        MessageBox.Show("请输入正确的经度!");
                        textbox1.Text = "";
                        return;
                    }
                }
            }
            if (textBox2.Text == "")
            {
                MessageBox.Show("纬度不能为空!");
                return;
            }
            else
            {
                bool bl = double.TryParse(textBox2.Text, out m_strLat);
                if (!bl)
                {
                    MessageBox.Show("请输入正确的纬度!");
                    textBox2.Text = "";
                    return;
                }
                else
                {
                    if (m_strLat > 85 || m_strLat < -85)
                    {
                        MessageBox.Show("请输入正确的纬度!");
                        textBox2.Text = "";
                        return;
                    }
                }
            }
            if (textBox3.Text == "")
            {
                textBox3.Text = "1000";
            }
            bool bl1 = double.TryParse(textBox3.Text, out m_strAlt);
            if (!bl1)
            {
                MessageBox.Show("请输入正确的高度!");
                textBox3.Text = "";
                return;
            }
            GSOPoint3d point3d = new GSOPoint3d();

            point3d.X = m_strLon;
            point3d.Y = m_strLat;
            point3d.Z = m_strAlt;

            globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.RelativeToGround);
        }
        /// <summary>
        /// 窗体关闭事件处理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FrmSetFlytoPos_FormClosing(object sender, FormClosingEventArgs e)
        {
            frm = null;
        }
        /// <summary>
        /// 取消按钮事件处理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonX2_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}