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 cxDuoBianXing : ConditionPanel { private Sunny.UI.UILabel uilbMsg; private Sunny.UI.UIComboBox uiCBLayers; GeoRegion m_geo = null; public cxDuoBianXing() : base() { this.ConditionPanelName = "多边形查询"; InitializeComponent(); uilbMsg.Text = "鼠标右键开始绘制多边形,\n\r 依次点击鼠标左键,构建多边形断点,\n\r 再次点击右键结束绘制。"; } protected override void OnLoad(EventArgs e) { MapControl.Action = SuperMap.UI.Action.CreatePolygon; MapControl.Tracked += new TrackedEventHandler(TrackedHandler); uiCBLayers.ValueMember = "LayerDatasetName"; uiCBLayers.DisplayMember = "LayerCaption"; uiCBLayers.DataSource = ComsStatic.getLayers(); } private void TrackedHandler(object sender, TrackedEventArgs e) { if (e.Geometry is null) return; m_geo = e.Geometry.Clone() as GeoRegion; if (m_geo is null) { Sunny.UI.UIMessageTip.ShowError("查询区域绘制失败"); return; } m_geo.Style = ComsStatic.geoStyle_Red_1mm_OpaqueRate; MapControl.Map.TrackingLayer.Clear(); MapControl.Map.TrackingLayer.Add(m_geo, "GeoRegion"); MapControl.Map.Refresh(); } public override object Do(DockPanel dockPanel = null) { IsConditionValid = false; if (m_geo is null) { Sunny.UI.UIMessageTip.ShowError("请先绘制查询区域"); return false; } DatasetVector datasetVector = ComsStatic.Datasource.Datasets[uiCBLayers.SelectedValue.ToString()] as DatasetVector; if (datasetVector is null) { Sunny.UI.UIMessageTip.ShowError("当前选择的图层没有可用的数据"); return false; } Recordset recordset = datasetVector.Query(m_geo, 1, "1=1", CursorType.Static); if (recordset is null) { Sunny.UI.UIMessageTip.ShowError("当前图层没有查询到数据"); return false; } DataTable dt = ComsStatic.RecordsetToDataTable(recordset, uiCBLayers.SelectedText); recordset.Close(); recordset.Dispose(); return dt; } public override void AfterClose() { MapControl.Tracked -= new TrackedEventHandler(TrackedHandler); base.AfterClose(); } private void InitializeComponent() { this.uilbMsg = new Sunny.UI.UILabel(); this.uiCBLayers = new Sunny.UI.UIComboBox(); this.SuspendLayout(); // // uilbMsg // this.uilbMsg.AutoSize = true; this.uilbMsg.Font = new System.Drawing.Font("微软雅黑", 12F); this.uilbMsg.Location = new System.Drawing.Point(3, 35); this.uilbMsg.Name = "uilbMsg"; this.uilbMsg.Size = new System.Drawing.Size(74, 21); this.uilbMsg.TabIndex = 0; this.uilbMsg.Text = "操作说明"; this.uilbMsg.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // uiCBLayers // this.uiCBLayers.DataSource = null; this.uiCBLayers.FillColor = System.Drawing.Color.White; this.uiCBLayers.Font = new System.Drawing.Font("微软雅黑", 12F); this.uiCBLayers.Location = new System.Drawing.Point(60, 5); this.uiCBLayers.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.uiCBLayers.MinimumSize = new System.Drawing.Size(63, 0); this.uiCBLayers.Name = "uiCBLayers"; this.uiCBLayers.Padding = new System.Windows.Forms.Padding(0, 0, 30, 2); this.uiCBLayers.Size = new System.Drawing.Size(328, 29); this.uiCBLayers.TabIndex = 1; this.uiCBLayers.Text = "请选择需要查询的图层"; this.uiCBLayers.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft; // // cxDuoBianXing // this.Controls.Add(this.uiCBLayers); this.Controls.Add(this.uilbMsg); this.Name = "cxDuoBianXing"; this.Size = new System.Drawing.Size(392, 215); this.ResumeLayout(false); this.PerformLayout(); } } }