cxDuoBianXing.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. using SuperMap.Data;
  2. using SuperMap.Mapping;
  3. using SuperMap.UI;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Data;
  7. using System.Drawing;
  8. using WeifenLuo.WinFormsUI.Docking;
  9. using WWPipeLine.MapBasic;
  10. using WWPipeLine.MapBasic.Conditions;
  11. namespace WWPipeLine.MapTools.Conditions.Sercher
  12. {
  13. public class cxDuoBianXing : ConditionPanel
  14. {
  15. GeoRegion m_geo = null;
  16. private Sunny.UI.UIGroupBox uigbLayer;
  17. private LayerWithDataListPanel LayerPanel;
  18. public cxDuoBianXing()
  19. {
  20. this.ConditionPanelName = "多边形查询";
  21. InitializeComponent();
  22. }
  23. protected override void OnLoad(EventArgs e)
  24. {
  25. LayerPanel = new LayerWithDataListPanel();
  26. LayerPanel.LoadToVector(true, true, true);
  27. uigbLayer.Controls.Add(LayerPanel);
  28. MapControl.Action = SuperMap.UI.Action.CreatePolygon;
  29. MapControl.Tracked += new TrackedEventHandler(TrackedHandler);
  30. }
  31. private void TrackedHandler(object sender, TrackedEventArgs e)
  32. {
  33. if (e.Geometry is null) return;
  34. m_geo = e.Geometry.Clone() as GeoRegion;
  35. if (m_geo is null) { Sunny.UI.UIMessageTip.ShowError("查询区域绘制失败"); return; }
  36. m_geo.Style = ComsStatic.geoStyle_Red_1mm_OpaqueRate;
  37. MapControl.Map.TrackingLayer.Clear();
  38. MapControl.Map.TrackingLayer.Add(m_geo, "GeoRegion");
  39. MapControl.Map.Refresh();
  40. }
  41. public override object Do(DockPanel dockPanel = null)
  42. {
  43. if (m_geo is null) { Sunny.UI.UIMessageTip.ShowError("请先绘制查询区域"); return false; }
  44. if (LayerPanel.SelectLayers.Count == 0)
  45. {
  46. Sunny.UI.UIMessageTip.ShowError("请先选择需要查询的图层"); return false;
  47. }
  48. List<DataTable> dts = new List<DataTable>();
  49. Recordset _rd = null;
  50. DatasetVector dv = null;
  51. DataTable dt = null;
  52. foreach (Layer lyr in LayerPanel.SelectLayers)
  53. {
  54. dv = lyr.Dataset as DatasetVector;
  55. if (dv is null || dv.RecordCount == 0) continue;
  56. _rd = dv.Query(m_geo, 1, "", CursorType.Static);
  57. if (_rd is null || _rd.RecordCount == 0) continue;
  58. dt = ComsStatic.RecordsetToDataTable(_rd);
  59. dt.TableName = lyr.Caption;
  60. dts.Add(dt);
  61. }
  62. ComsStatic.RecordsetDispose(_rd);
  63. return dts;
  64. }
  65. public override void AfterClose()
  66. {
  67. MapControl.Tracked -= new TrackedEventHandler(TrackedHandler);
  68. base.AfterClose();
  69. }
  70. private void InitializeComponent()
  71. {
  72. this.uigbLayer = new Sunny.UI.UIGroupBox();
  73. this.SuspendLayout();
  74. //
  75. // uigbLayer
  76. //
  77. this.uigbLayer.Dock = System.Windows.Forms.DockStyle.Fill;
  78. this.uigbLayer.Font = new System.Drawing.Font("微软雅黑", 12F);
  79. this.uigbLayer.Location = new System.Drawing.Point(0, 0);
  80. this.uigbLayer.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
  81. this.uigbLayer.MinimumSize = new System.Drawing.Size(1, 1);
  82. this.uigbLayer.Name = "uigbLayer";
  83. this.uigbLayer.Padding = new System.Windows.Forms.Padding(0, 32, 0, 0);
  84. this.uigbLayer.Size = new System.Drawing.Size(500, 315);
  85. this.uigbLayer.TabIndex = 1;
  86. this.uigbLayer.Text = "查询图层选择";
  87. this.uigbLayer.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter;
  88. //
  89. // cxDuoBianXing
  90. //
  91. this.Controls.Add(this.uigbLayer);
  92. this.Name = "cxDuoBianXing";
  93. this.Size = new System.Drawing.Size(500, 315);
  94. this.ResumeLayout(false);
  95. }
  96. }
  97. }