cxJuXing.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 cxJuXing : ConditionPanel
  14. {
  15. GeoRegion m_geo = null;
  16. private Sunny.UI.UIGroupBox uigbLayer;
  17. private LayerWithDataListPanel LayerPanel;
  18. public cxJuXing() : 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.CreateRectangle;
  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. if (m_geo is null) { Sunny.UI.UIMessageTip.ShowError("请先绘制查询区域"); return false; }
  45. if (LayerPanel.SelectLayers.Count == 0)
  46. {
  47. Sunny.UI.UIMessageTip.ShowError("请先选择需要查询的图层"); return false;
  48. }
  49. List<DataTable> dts = new List<DataTable>();
  50. Recordset _rd = null;
  51. DatasetVector dv = null;
  52. DataTable dt = null;
  53. foreach (Layer lyr in LayerPanel.SelectLayers)
  54. {
  55. dv = lyr.Dataset as DatasetVector;
  56. if (dv is null || dv.RecordCount == 0) continue;
  57. _rd = dv.Query(m_geo, 1, "", CursorType.Static);
  58. if (_rd is null || _rd.RecordCount == 0) continue;
  59. dt = ComsStatic.RecordsetToDataTable(_rd);
  60. dt.TableName = lyr.Caption;
  61. dts.Add(dt);
  62. }
  63. ComsStatic.RecordsetDispose(_rd);
  64. return dts;
  65. }
  66. public override void AfterClose()
  67. {
  68. MapControl.Tracked -= new TrackedEventHandler(TrackedHandler);
  69. base.AfterClose();
  70. }
  71. private void InitializeComponent()
  72. {
  73. this.uigbLayer = new Sunny.UI.UIGroupBox();
  74. this.SuspendLayout();
  75. //
  76. // uigbLayer
  77. //
  78. this.uigbLayer.Dock = System.Windows.Forms.DockStyle.Fill;
  79. this.uigbLayer.Font = new System.Drawing.Font("微软雅黑", 12F);
  80. this.uigbLayer.Location = new System.Drawing.Point(0, 0);
  81. this.uigbLayer.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
  82. this.uigbLayer.MinimumSize = new System.Drawing.Size(1, 1);
  83. this.uigbLayer.Name = "uigbLayer";
  84. this.uigbLayer.Padding = new System.Windows.Forms.Padding(0, 32, 0, 0);
  85. this.uigbLayer.Size = new System.Drawing.Size(500, 315);
  86. this.uigbLayer.TabIndex = 1;
  87. this.uigbLayer.Text = "查询图层选择";
  88. this.uigbLayer.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter;
  89. //
  90. // cxJuXing
  91. //
  92. this.Controls.Add(this.uigbLayer);
  93. this.Name = "cxJuXing";
  94. this.Size = new System.Drawing.Size(500, 315);
  95. this.ResumeLayout(false);
  96. }
  97. }
  98. }