12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- 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 DWbount : ConditionPanel
- {
- private DatasetVector _dv;
- public DWbount()
- {
- this.ConditionPanelName = "按照行政区域定位";
- InitializeComponent();
- this.IsShowPanelFooter = false;
- }
- protected override void OnLoad(EventArgs e)
- {
- _dv = ComsStatic.Datasource.Datasets["BOUNTPY"] 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();
- }
- }
- }
|