123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- 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 cxJuXing : ConditionPanel
- {
- GeoRegion m_geo = null;
- private Sunny.UI.UIGroupBox uigbLayer;
- private LayerWithDataListPanel LayerPanel;
- public cxJuXing() : base()
- {
- this.ConditionPanelName = "矩形查询";
- InitializeComponent();
- }
- protected override void OnLoad(EventArgs e)
- {
- MapControl.Action = SuperMap.UI.Action.CreateRectangle;
- MapControl.Tracked += new TrackedEventHandler(TrackedHandler);
- LayerPanel = new LayerWithDataListPanel();
- LayerPanel.LoadToVector(true, true, true);
- uigbLayer.Controls.Add(LayerPanel);
- }
- 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, "GeoRectangle");
- MapControl.Map.Refresh();
- }
- public override object Do(DockPanel dockPanel = null)
- {
- if (m_geo is null) { Sunny.UI.UIMessageTip.ShowError("请先绘制查询区域"); return false; }
- if (LayerPanel.SelectLayers.Count == 0)
- {
- Sunny.UI.UIMessageTip.ShowError("请先选择需要查询的图层"); return false;
- }
- List<DataTable> dts = new List<DataTable>();
- Recordset _rd = null;
- DatasetVector dv = null;
- DataTable dt = null;
- foreach (Layer lyr in LayerPanel.SelectLayers)
- {
- dv = lyr.Dataset as DatasetVector;
- if (dv is null || dv.RecordCount == 0) continue;
- _rd = dv.Query(m_geo, 1, "", 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;
- }
- public override void AfterClose()
- {
- MapControl.Tracked -= new TrackedEventHandler(TrackedHandler);
- base.AfterClose();
- }
- private void InitializeComponent()
- {
- this.uigbLayer = new Sunny.UI.UIGroupBox();
- this.SuspendLayout();
- //
- // uigbLayer
- //
- this.uigbLayer.Dock = System.Windows.Forms.DockStyle.Fill;
- 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(500, 315);
- this.uigbLayer.TabIndex = 1;
- this.uigbLayer.Text = "查询图层选择";
- this.uigbLayer.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter;
- //
- // cxJuXing
- //
- this.Controls.Add(this.uigbLayer);
- this.Name = "cxJuXing";
- this.Size = new System.Drawing.Size(500, 315);
- this.ResumeLayout(false);
- }
- }
- }
|