HuanChong.cs 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. }
  26. protected override void OnLoad(EventArgs e)
  27. {
  28. MapControl.MouseDoubleClick += MapControl_MouseDoubleClick;
  29. }
  30. public override object Do(DockPanel dockPanel = null)
  31. {
  32. if (geoCircle == null) { Sunny.UI.UIMessageTip.ShowError("请先生成分析范围"); return false; }
  33. List<DataTable> dts = new List<DataTable>();
  34. Recordset _rd = null;
  35. DatasetVector dv = null;
  36. DataTable dt = null;
  37. foreach (Layer lyr in ComsStatic.MapLayersUsed)
  38. {
  39. dv = lyr.Dataset as DatasetVector;
  40. if (dv is null || dv.RecordCount == 0) continue;
  41. _rd = dv.Query(geoCircle, 0, "", CursorType.Static);
  42. if (_rd is null || _rd.RecordCount == 0) continue;
  43. dt = ComsStatic.RecordsetToDataTable(_rd);
  44. dt.TableName = lyr.Caption;
  45. dts.Add(dt);
  46. }
  47. ComsStatic.RecordsetDispose(_rd);
  48. return dts;
  49. }
  50. private void MapControl_MouseDoubleClick(object sender, MouseEventArgs e)
  51. {
  52. pClick = MapControl.Map.PixelToMap(new Point(e.X, e.Y));
  53. GeoPoint geoPoint = new GeoPoint(pClick);
  54. geoPoint.Style = new GeoStyle { MarkerSize = new Size2D(5, 5), LineColor = Color.Red };
  55. MapControl.Map.TrackingLayer.Clear();
  56. MapControl.Map.TrackingLayer.Add(geoPoint, "jiedian");
  57. MapControl.Map.RefreshEx(MapControl.Map.ViewBounds);
  58. }
  59. public override void AfterClose()
  60. {
  61. MapControl.MouseDoubleClick -= MapControl_MouseDoubleClick;
  62. base.AfterClose();
  63. }
  64. private void uitbBanjing_KeyPress(object sender, KeyPressEventArgs e)
  65. {
  66. if ((e.KeyChar < 48 || e.KeyChar > 57) && (e.KeyChar != 8))
  67. e.Handled = true;
  68. }
  69. private void uiButton1_Click(object sender, EventArgs e)
  70. {
  71. if (pClick.X == 0) { Sunny.UI.UIMessageTip.ShowError("请先在地图中双击确定圆形中心点"); return; }
  72. geoCircle = new GeoCircle() { Center = pClick, Radius = ComsStatic.StringToDouble(uitbBanjing.Text) };
  73. geoCircle.Style = ComsStatic.geoStyle_Red_1mm_OpaqueRate;
  74. MapControl.Map.TrackingLayer.Add(geoCircle, "yuanxing");
  75. MapControl.Map.Refresh();
  76. }
  77. }
  78. }