using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using WWPipeLine.MapBasic.Conditions; using WeifenLuo.WinFormsUI.Docking; using WWPipeLine.MapBasic; using SuperMap.Data; using Sunny.UI; namespace WWPipeLine.MapTools.Conditions.Locations { public partial class DWroad : ConditionPanel { private DatasetVector _dv; public DWroad() { this.ConditionPanelName = "按照交通道路定位"; InitializeComponent(); this.IsShowPanelFooter = false; } protected override void OnLoad(EventArgs e) { _dv = ComsStatic.Datasource.Datasets["ROADPY"] as DatasetVector; if (_dv == null) { Sunny.UI.UIMessageTip.ShowError("当前数据源中不包含相应的矢量数据集"); return; } ComsStatic.setUIDataGridView(uiDataGridViewDW, ComsStatic.RecordsetToDataTable(_dv.GetRecordset(false, CursorType.Static))); uiDataGridViewDW.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; } private void uiDataGridViewDW_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { DataGridView dataGridView = (sender as DataGridView); var selectRows = dataGridView.SelectedRows; if (selectRows == null || selectRows.Count != 1) return;//选择不是一行 DataGridViewRow selectRow = selectRows[0]; var index = -1; foreach (DataGridViewColumn c in selectRow.DataGridView.Columns) { if (c.Name.ToUpper() == "SMID") { index = selectRow.DataGridView.Columns.IndexOf(c); break; } } if (index == -1) return;//列数据中不包含SMID列 int smid = ComsStatic.StringToInt(selectRow.Cells[index].Value); if (smid == 0) return;//SMID的值为null Geometry geoxy = null; var fs = _dv.GetAllFeatures(); if (fs.ContainsKey(smid)) { geoxy = fs[smid].GetGeometry(); } if (geoxy == null) return;//当前数据集没有找到SMID对应的数据 MapControl.Map.ViewBounds = geoxy.Bounds; MapControl.Map.Refresh(); } } }