Newer
Older
EMS_SZ / EMS_Forms / Form_TaskInfo.cs
root on 21 Mar 2016 3 KB first
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 GeoScene.Data;
using GeoScene.Engine;
using GeoScene.Globe;

namespace Cyberpipe.EMS_Forms
{
    public partial class Form_TaskInfo : Form
    {
        DataTable dt = new DataTable();
        private GSOGlobeControl globeControl1;

        public delegate void Handle();
        public event Handle showParentForm;

        public Form_TaskInfo(GSOGlobeControl globeControl1,DataTable dt)
        {
            this.globeControl1 = globeControl1;
            this.dt = dt;
            InitializeComponent();
        }

        private void Form_TaskInfo_Load(object sender, EventArgs e)
        {
            try
            {
                //string sql = "select * from MARK_TASK where TASK_ID ='" + taskid + "' order by DBID";
                //dt = OledbHelper.ExecuteDataTable(sql);
                dataGridViewX_TaskInfo.DataSource = dt;

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        private void dataGridViewX_TaskInfo_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                DataGridView.HitTestInfo hittestinfo = dataGridViewX_TaskInfo.HitTest(e.X, e.Y);
                if (hittestinfo.RowIndex > -1)
                {
                    this.WindowState = FormWindowState.Minimized;
                    string markId = "";
                    markId = Convert.ToString(dataGridViewX_TaskInfo.Rows[hittestinfo.RowIndex].Cells["标识器编号"].Value);
                    int ID = GeoScene.Data.GSOProjectManager.AddProject("+proj=tmerc +lat_0=0 +lon_0=120 +k=1 +x_0=499885 +y_0=6 +a=6378140 +b=6356755.288157528 +units=m +no_defs");
                    
                    GSOFeatures features = globeControl1.Globe.Layers.GetLayerByCaption("标识器").GetFeatureByName(markId, true);
                    if (features.Length > 0)
                    {
                        double x = ((GSOGeoModel)(features[0].Geometry)).PositionX;
                        double y = ((GSOGeoModel)(features[0].Geometry)).PositionY;

                        GSOPoint3d p = new GSOPoint3d();
                        GeoScene.Data.GSOPoint2d pt2d = new GeoScene.Data.GSOPoint2d(y, x);
                        GeoScene.Data.GSOPoint2d result = GeoScene.Data.GSOProjectManager.Inverse(pt2d, ID);
                        p.X = result.X;
                        p.Y = result.Y;

                        p.X = x;
                        p.Y = y;
                        p.Z = 2;

                        globeControl1.Globe.JumpToFeature(features[0], 20);

                    }
                    else
                    {
                        MessageBox.Show("未找到对象!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    }
                }

            }
        }

        private void Form_TaskInfo_FormClosing(object sender, FormClosingEventArgs e)
        {
            globeControl1.Globe.MemoryLayer.RemoveAllFeature();
            showParentForm();
        }
    }
}