SercherOnClick.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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 SercherOnClick : ConditionPanel
  14. {
  15. private LayerWithDataListPanel LayerPanel;
  16. public SercherOnClick() : base()
  17. {
  18. this.ConditionPanelName = "点击查询";
  19. this.SetSize(300, 400);
  20. InitializeComponent();
  21. }
  22. private Sunny.UI.UIGroupBox uigbLayer;
  23. private Sunny.UI.UITextBox uitbBanjing;
  24. private Sunny.UI.UILabel uiLabel1;
  25. private Selection[] _selection = null;
  26. protected override void OnLoad(EventArgs e)
  27. {
  28. LayerPanel = new LayerWithDataListPanel();
  29. LayerPanel.LoadToVector(true, true, true);
  30. uigbLayer.Controls.Add(LayerPanel);
  31. }
  32. public override object Do(DockPanel dockPanel = null)
  33. {
  34. if (LayerPanel.SelectLayers.Count == 0)
  35. {
  36. Sunny.UI.UIMessageTip.ShowError("请先选择需要查询的图层"); return false;
  37. }
  38. double banjing = ComsStatic.StringToDouble(uitbBanjing.Text);
  39. if (banjing == 0.0)
  40. {
  41. Sunny.UI.UIMessageTip.ShowError("请输入正确的查询半径"); return false;
  42. }
  43. _selection = MapControl.Map.FindSelection(true);
  44. if (_selection is null || _selection.Length != 1 || _selection[0].Count != 1)
  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. Geometry m_geo = _selection[0].ToRecordset().GetGeometry();
  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, banjing, "", 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. private void InitializeComponent()
  67. {
  68. this.uigbLayer = new Sunny.UI.UIGroupBox();
  69. this.uitbBanjing = new Sunny.UI.UITextBox();
  70. this.uiLabel1 = new Sunny.UI.UILabel();
  71. this.SuspendLayout();
  72. //
  73. // uigbLayer
  74. //
  75. this.uigbLayer.Dock = System.Windows.Forms.DockStyle.Top;
  76. this.uigbLayer.Font = new System.Drawing.Font("微软雅黑", 12F);
  77. this.uigbLayer.Location = new System.Drawing.Point(0, 0);
  78. this.uigbLayer.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
  79. this.uigbLayer.MinimumSize = new System.Drawing.Size(1, 1);
  80. this.uigbLayer.Name = "uigbLayer";
  81. this.uigbLayer.Padding = new System.Windows.Forms.Padding(0, 32, 0, 0);
  82. this.uigbLayer.Size = new System.Drawing.Size(300, 268);
  83. this.uigbLayer.TabIndex = 0;
  84. this.uigbLayer.Text = "查询图层选择";
  85. this.uigbLayer.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter;
  86. //
  87. // uitbBanjing
  88. //
  89. this.uitbBanjing.Cursor = System.Windows.Forms.Cursors.IBeam;
  90. this.uitbBanjing.DoubleValue = 10D;
  91. this.uitbBanjing.FillColor = System.Drawing.Color.White;
  92. this.uitbBanjing.Font = new System.Drawing.Font("微软雅黑", 12F);
  93. this.uitbBanjing.IntValue = 10;
  94. this.uitbBanjing.Location = new System.Drawing.Point(141, 278);
  95. this.uitbBanjing.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
  96. this.uitbBanjing.Maximum = 2147483647D;
  97. this.uitbBanjing.Minimum = -2147483648D;
  98. this.uitbBanjing.MinimumSize = new System.Drawing.Size(1, 1);
  99. this.uitbBanjing.Name = "uitbBanjing";
  100. this.uitbBanjing.Size = new System.Drawing.Size(76, 29);
  101. this.uitbBanjing.TabIndex = 3;
  102. this.uitbBanjing.Text = "10";
  103. this.uitbBanjing.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
  104. this.uitbBanjing.KeyPress += new System.Windows.Forms.KeyPressEventHandler(ComsStatic.uiTextBox_num_KeyPress);
  105. //
  106. // uiLabel1
  107. //
  108. this.uiLabel1.Font = new System.Drawing.Font("微软雅黑", 12F);
  109. this.uiLabel1.Location = new System.Drawing.Point(34, 282);
  110. this.uiLabel1.Name = "uiLabel1";
  111. this.uiLabel1.Size = new System.Drawing.Size(100, 23);
  112. this.uiLabel1.TabIndex = 2;
  113. this.uiLabel1.Text = "查询半径(M):";
  114. this.uiLabel1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
  115. //
  116. // SercherOnClick
  117. //
  118. this.Controls.Add(this.uitbBanjing);
  119. this.Controls.Add(this.uiLabel1);
  120. this.Controls.Add(this.uigbLayer);
  121. this.Name = "SercherOnClick";
  122. this.Size = new System.Drawing.Size(300, 315);
  123. this.ResumeLayout(false);
  124. }
  125. }
  126. }