using SuperMap.Data; using SuperMap.Mapping; using SuperMap.UI; using System; using System.Collections.Generic; using System.Data; using WeifenLuo.WinFormsUI.Docking; using WWPipeLine.MapBasic; using WWPipeLine.MapBasic.Conditions; using WWPipeLine.MapBasic; namespace WWPipeLine.MapTools.Conditions { public class SercherOnClick : ConditionPanel { private DatasetVectorEx _dvEx; private LayerWithDataListPanel LayerPanel; public SercherOnClick() : base() { this.ConditionPanelName = "点击查询"; InitializeComponent(); } private Selection[] _selection = null; protected override void OnLoad(EventArgs e) { LayerPanel = new LayerWithDataListPanel(); LayerPanel.Init(base.MapControl); LayerPanel.LoadToVector(); this.Controls.Add(LayerPanel); } public override object Do(DockPanel dockPanel = null) { if (string.IsNullOrEmpty(LayerPanel.SelectLayerName)) { Sunny.UI.UIMessageTip.ShowError("请先选择需要查询的图层"); return false; } BaseConditions.Remove("SelectLayerNameConditionPanel"); //BaseConditions.Add("SelectLayerNameConditionPanel", LayerPanel.SelectLayerName); _selection = base.MapControl.Map.FindSelection(true); MapControl.Map.Layers.FindLayer(LayerPanel.SelectLayerName); if (_selection.Length == 0) { Sunny.UI.UIMessageTip.ShowError("没有选中的数据。
此处需要鼠标右键,点选图层中的信息!"); return false; } Recordset _rd = null; for (int i = 0; i < _selection.Length; i++) { if (_selection[i].Dataset.Name == LayerPanel.SelectLayerName.Split('@')[0]) { _rd = _selection[i].ToRecordset(); } } _dvEx = new DatasetVectorEx(_rd.Dataset.Name); _dvEx.ResultFields.Clear(); DataTable recordsetTable = _dvEx.ToDataTable(_rd); return recordsetTable; } private void InitializeComponent() { this.SuspendLayout(); // // SercherOnClick // this.Name = "SercherOnClick"; this.Size = new System.Drawing.Size(392, 215); this.ResumeLayout(false); } } }