using SuperMap.Data; using SuperMap.Mapping; using SuperMap.UI; using System; using System.Collections.Generic; using System.Data; using System.Drawing; using WeifenLuo.WinFormsUI.Docking; using WWPipeLine.MapBasic; using WWPipeLine.MapBasic.Conditions; namespace WWPipeLine.MapTools.Conditions.Sercher { public class SercherOnClick : ConditionPanel { private LayerWithDataListPanel LayerPanel; public SercherOnClick() : base() { this.ConditionPanelName = "点击查询"; this.SetSize(300, 400); InitializeComponent(); } private Sunny.UI.UIGroupBox uigbLayer; private Sunny.UI.UITextBox uitbBanjing; private Sunny.UI.UILabel uiLabel1; private Selection[] _selection = null; protected override void OnLoad(EventArgs e) { LayerPanel = new LayerWithDataListPanel(); LayerPanel.LoadToVector(true, true, true); uigbLayer.Controls.Add(LayerPanel); } public override object Do(DockPanel dockPanel = null) { if (LayerPanel.SelectLayers.Count == 0) { Sunny.UI.UIMessageTip.ShowError("请先选择需要查询的图层"); return false; } double banjing = ComsStatic.StringToDouble(uitbBanjing.Text); if (banjing == 0.0) { Sunny.UI.UIMessageTip.ShowError("请输入正确的查询半径"); return false; } _selection = MapControl.Map.FindSelection(true); if (_selection is null || _selection.Length != 1 || _selection[0].Count != 1) { Sunny.UI.UIMessageTip.ShowError("请先选择一个基础元素"); return false; } List dts = new List(); Recordset _rd = null; DatasetVector dv = null; DataTable dt = null; Geometry m_geo = _selection[0].ToRecordset().GetGeometry(); foreach (Layer lyr in LayerPanel.SelectLayers) { dv = lyr.Dataset as DatasetVector; if (dv is null || dv.RecordCount == 0) continue; _rd = dv.Query(m_geo, banjing, "", CursorType.Static); if (_rd is null || _rd.RecordCount == 0) continue; dt = ComsStatic.RecordsetToDataTable(_rd); dt.TableName = lyr.Caption; dts.Add(dt); } ComsStatic.RecordsetDispose(_rd); return dts; } private void InitializeComponent() { this.uigbLayer = new Sunny.UI.UIGroupBox(); this.uitbBanjing = new Sunny.UI.UITextBox(); this.uiLabel1 = new Sunny.UI.UILabel(); this.SuspendLayout(); // // uigbLayer // this.uigbLayer.Dock = System.Windows.Forms.DockStyle.Top; this.uigbLayer.Font = new System.Drawing.Font("微软雅黑", 12F); this.uigbLayer.Location = new System.Drawing.Point(0, 0); this.uigbLayer.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.uigbLayer.MinimumSize = new System.Drawing.Size(1, 1); this.uigbLayer.Name = "uigbLayer"; this.uigbLayer.Padding = new System.Windows.Forms.Padding(0, 32, 0, 0); this.uigbLayer.Size = new System.Drawing.Size(300, 268); this.uigbLayer.TabIndex = 0; this.uigbLayer.Text = "查询图层选择"; this.uigbLayer.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter; // // uitbBanjing // this.uitbBanjing.Cursor = System.Windows.Forms.Cursors.IBeam; this.uitbBanjing.DoubleValue = 10D; this.uitbBanjing.FillColor = System.Drawing.Color.White; this.uitbBanjing.Font = new System.Drawing.Font("微软雅黑", 12F); this.uitbBanjing.IntValue = 10; this.uitbBanjing.Location = new System.Drawing.Point(141, 278); this.uitbBanjing.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.uitbBanjing.Maximum = 2147483647D; this.uitbBanjing.Minimum = -2147483648D; this.uitbBanjing.MinimumSize = new System.Drawing.Size(1, 1); this.uitbBanjing.Name = "uitbBanjing"; this.uitbBanjing.Size = new System.Drawing.Size(76, 29); this.uitbBanjing.TabIndex = 3; this.uitbBanjing.Text = "10"; this.uitbBanjing.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft; this.uitbBanjing.KeyPress += new System.Windows.Forms.KeyPressEventHandler(ComsStatic.uiTextBox_num_KeyPress); // // uiLabel1 // this.uiLabel1.Font = new System.Drawing.Font("微软雅黑", 12F); this.uiLabel1.Location = new System.Drawing.Point(34, 282); this.uiLabel1.Name = "uiLabel1"; this.uiLabel1.Size = new System.Drawing.Size(100, 23); this.uiLabel1.TabIndex = 2; this.uiLabel1.Text = "查询半径(M):"; this.uiLabel1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // SercherOnClick // this.Controls.Add(this.uitbBanjing); this.Controls.Add(this.uiLabel1); this.Controls.Add(this.uigbLayer); this.Name = "SercherOnClick"; this.Size = new System.Drawing.Size(300, 315); this.ResumeLayout(false); } } }