SercherOnClick.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 WeifenLuo.WinFormsUI.Docking;
  8. using WWPipeLine.MapBasic;
  9. using WWPipeLine.MapBasic.Conditions;
  10. using WWPipeLine.MapBasic;
  11. namespace WWPipeLine.MapTools.Conditions
  12. {
  13. public class SercherOnClick : ConditionPanel
  14. {
  15. private DatasetVectorEx _dvEx;
  16. private LayerWithDataListPanel LayerPanel;
  17. public SercherOnClick() : base()
  18. {
  19. this.ConditionPanelName = "点击查询";
  20. InitializeComponent();
  21. }
  22. private Selection[] _selection = null;
  23. protected override void OnLoad(EventArgs e)
  24. {
  25. LayerPanel = new LayerWithDataListPanel();
  26. LayerPanel.Init(base.MapControl);
  27. LayerPanel.LoadToVector();
  28. this.Controls.Add(LayerPanel);
  29. }
  30. public override object Do(DockPanel dockPanel = null)
  31. {
  32. if (string.IsNullOrEmpty(LayerPanel.SelectLayerName))
  33. {
  34. Sunny.UI.UIMessageTip.ShowError("请先选择需要查询的图层");
  35. return false;
  36. }
  37. BaseConditions.Remove("SelectLayerNameConditionPanel");
  38. //BaseConditions.Add("SelectLayerNameConditionPanel", LayerPanel.SelectLayerName);
  39. _selection = base.MapControl.Map.FindSelection(true);
  40. MapControl.Map.Layers.FindLayer(LayerPanel.SelectLayerName);
  41. if (_selection.Length == 0)
  42. {
  43. Sunny.UI.UIMessageTip.ShowError("没有选中的数据。<br /> 此处需要鼠标右键,点选图层中的信息!");
  44. return false;
  45. }
  46. Recordset _rd = null;
  47. for (int i = 0; i < _selection.Length; i++)
  48. {
  49. if (_selection[i].Dataset.Name == LayerPanel.SelectLayerName.Split('@')[0])
  50. {
  51. _rd = _selection[i].ToRecordset();
  52. }
  53. }
  54. _dvEx = new DatasetVectorEx(_rd.Dataset.Name);
  55. _dvEx.ResultFields.Clear();
  56. DataTable recordsetTable = _dvEx.ToDataTable(_rd);
  57. return recordsetTable;
  58. }
  59. private void InitializeComponent()
  60. {
  61. this.SuspendLayout();
  62. //
  63. // SercherOnClick
  64. //
  65. this.Name = "SercherOnClick";
  66. this.Size = new System.Drawing.Size(392, 215);
  67. this.ResumeLayout(false);
  68. }
  69. }
  70. }