HuanChong.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using WWPipeLine.MapBasic.Conditions;
  11. using WWPipeLine.MapBasic;
  12. using SuperMap.Data;
  13. using WeifenLuo.WinFormsUI.Docking;
  14. using SuperMap.Mapping;
  15. namespace WWPipeLine.MapTools.Conditions.AnalystToolBar
  16. {
  17. public partial class HuanChong : ConditionPanel
  18. {
  19. Point2D pClick;
  20. GeoCircle geoCircle = null;
  21. public HuanChong()
  22. {
  23. this.ConditionPanelName = "缓冲区分析";
  24. InitializeComponent();
  25. this.SetSize(300, 200);
  26. }
  27. protected override void OnLoad(EventArgs e)
  28. {
  29. MapControl.MouseDoubleClick += MapControl_MouseDoubleClick;
  30. }
  31. public override object Do(DockPanel dockPanel = null)
  32. {
  33. if (geoCircle == null) { Sunny.UI.UIMessageTip.ShowError("请先生成分析范围"); return false; }
  34. List<DataTable> dts = new List<DataTable>();
  35. Recordset _rd = null;
  36. DatasetVector dv = null;
  37. DataTable dt = null;
  38. foreach (Layer lyr in ComsStatic.MapLayersUsed)
  39. {
  40. dv = lyr.Dataset as DatasetVector;
  41. if (dv is null || dv.RecordCount == 0) continue;
  42. _rd = dv.Query(geoCircle, 0, "", CursorType.Static);
  43. if (_rd is null || _rd.RecordCount == 0) continue;
  44. dt = ComsStatic.RecordsetToDataTable(_rd);
  45. dt.TableName = lyr.Caption;
  46. dts.Add(dt);
  47. }
  48. ComsStatic.RecordsetDispose(_rd);
  49. return dts;
  50. }
  51. private void MapControl_MouseDoubleClick(object sender, MouseEventArgs e)
  52. {
  53. pClick = MapControl.Map.PixelToMap(new Point(e.X, e.Y));
  54. GeoPoint geoPoint = new GeoPoint(pClick);
  55. geoPoint.Style = ComsStatic.geoStyle_Red_Mark5mm;
  56. MapControl.Map.TrackingLayer.Clear();
  57. MapControl.Map.TrackingLayer.Add(geoPoint, "jiedian");
  58. MapControl.Map.RefreshTrackingLayer();
  59. }
  60. public override void AfterClose()
  61. {
  62. MapControl.MouseDoubleClick -= MapControl_MouseDoubleClick;
  63. base.AfterClose();
  64. }
  65. private void uiButton1_Click(object sender, EventArgs e)
  66. {
  67. if (pClick.X == 0) { Sunny.UI.UIMessageTip.ShowError("请先在地图中双击确定圆形中心点"); return; }
  68. geoCircle = new GeoCircle() { Center = pClick, Radius = ComsStatic.StringToDouble(uitbBanjing.Text) };
  69. geoCircle.Style = ComsStatic.geoStyle_Red_1mm_OpaqueRate;
  70. MapControl.Map.TrackingLayer.Add(geoCircle, "yuanxing");
  71. MapControl.Map.RefreshTrackingLayer();
  72. }
  73. }
  74. }