Newer
Older
GHFX_REFACTOR / FrmAnalysisGuiHuaResult.cs
wxn on 9 Nov 2016 6 KB 冗余代码整理
using System;
using System.Collections.Generic;
using System.Data;
using System.Windows.Forms;
using DevComponents.DotNetBar;
using DevComponents.DotNetBar.Controls;
using GeoScene.Data;
using GeoScene.Globe;

namespace Cyberpipe
{
    public partial class FrmAnalysisGuiHuaResult : Office2007Form
    {
        
        //DataTable dt = null;
        //定位和闪烁初始化定义
        int count;
        private string flashflag = "single";
        GSOFeature hlfeature;
        public GSOGlobeControl globleControl1;

        DataGridViewX dataGridView2;
        List<MainFrm.LineStruct> lineStrcut = new List<MainFrm.LineStruct>();
        PanelEx panel;
        //ToolStripStatusLabel toolStripNumbers;
        //ToolStripStatusLabel toolStripFeatureLength;
        string layer;
        string hxName;
        List<GSOFeatures> featsList = new List<GSOFeatures>();

        public FrmAnalysisGuiHuaResult(GSOGlobeControl _globleControl1, List<MainFrm.LineStruct> _lineStrcut, List<GSOFeatures> _featsList,PanelEx p, DataGridViewX _dataGridView1,string _layer,string _hxName)
        {
            InitializeComponent();
            lineStrcut = _lineStrcut;
            panel = p;
            globleControl1 = _globleControl1;
            dataGridView2 = _dataGridView1;
            layer = _layer;
            hxName = _hxName;
            featsList = _featsList;
        }

        private void FrmAnalysisGuiHuaResult_Load(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("图层类型");
            dt.Columns.Add("编号");

            for (int i = 0; i < lineStrcut.Count;i++ )
            {
                if (lineStrcut[i].layerName == layer&&lineStrcut[i].hxName==hxName)
                {
                    DataRow row = dt.NewRow();
                    row[0] = lineStrcut[i].layerName;
                    row[1] = lineStrcut[i].layerCode;
                    dt.Rows.Add(row);
                }
            }
            if (featsList.Count > 0)
            {
                for (int j = 0; j < featsList.Count; j++)
                {
                    GSOFeatures feats = featsList[j];
                    if (feats[0].Dataset.Caption.Contains(layer))
                    {
                        for (int n = 0; n < feats.Length; n++)
                        {
                            DataRow pointRow = dt.NewRow();
                            pointRow[0] = feats[n].Dataset.Caption;
                            pointRow[1] = feats[n].GetFieldAsString("编号");
                            dt.Rows.Add(pointRow);
                        }
                    }
                }
            }
           
            dataGridView1.DataSource = dt;
            dataGridView1.Columns[1].Width = 200;
        }

        private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex > -1)
            {
                string BH = dataGridView1.Rows[e.RowIndex].Cells["编号"].Value.ToString();

                GSOLayer gsoLayer = globleControl1.Globe.Layers.GetLayerByCaption(layer);
                GSOFeatures rowFeatures = gsoLayer.GetFeatureByName(BH, true);
                if (rowFeatures.Length == 0)
                {
                    gsoLayer = globleControl1.Globe.Layers.GetLayerByCaption(layer + "附属物");
                    rowFeatures = gsoLayer.GetFeatureByName(BH, true);
                }
                GSOFeature feature = rowFeatures[0];
                hlfeature = feature;
                highlight();
                //globleControl1.Globe.FlyToFeature(feature, 0, 45, 3);
                globleControl1.Globe.JumpToFeature(feature, 10);

                #region
                //string layer = dataGridView1.Rows[e.RowIndex].Cells["管线类型"].Value.ToString();

                //string sql = "select " + getpipeLineFields.getFields(layer, globleControl1) + " from " + layer + " where 编号 = ";
                //for (int i = 0; i < lineStrcut.Count; i++)
                //{
                //    if (i == lineStrcut.Count - 1)
                //    {
                //        sql += "'" + lineStrcut[i].layerCode + "'";
                //    }
                //    else
                //    {
                //        sql += "'" + lineStrcut[i].layerCode + "'" + " or 编号 = ";
                //    }

                //}

                //DataTable table = OledbHelper.QueryTable(sql);
                //if (table != null && table.Rows.Count > 0)
                //{
                //    dataGridView2.DataSource = table;
                //    panel.Visible = true;
                //    toolStripNumbers.Text =layer;
                //    toolStripFeatureLength.Text = " 共有:" + table.Rows.Count + "条";
                //}
                //else
                //{
                //}
                #endregion
            }
        }

        /// <summary>
        /// 高亮显示
        /// </summary>
        public void highlight()
        {
            flashflag = "single";
            timer1.Start();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            GSOFeature rowFeature = hlfeature;//as GSOFeature;
            if (rowFeature == null)
                return;

            if (count < 100)
            {
                count++;
                if (flashflag == "single")
                {
                    if (rowFeature != null)
                    {
                        if (count % 2 != 0)
                        {
                            rowFeature.HighLight = true;
                            globleControl1.Refresh();
                        }
                        else
                        {
                            rowFeature.HighLight = false;
                            globleControl1.Refresh();
                        }
                    }
                }
            }
            else
            {
                timer1.Stop();
                rowFeature.HighLight = false;
                count = 0;
            }

        }

        private void FrmAnalysisGuiHuaResult_FormClosing(object sender, FormClosingEventArgs e)
        {
            //dataGridView2.DataSource = null;
            //dataGridView2.Refresh();
            //panel.Visible = false;
            //toolStripNumbers.Text = " 类型:";
            //toolStripFeatureLength.Text = " 管线里程:";
            //lineStrcut.Clear();
            
            timer1.Stop();
        }
        int rowIndex;
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            rowIndex = e.RowIndex;
        }

    }
}