cxYuanXing.cs 3.2 KB

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