BZShuanDian.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using SuperMap.Data;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Windows.Forms;
  5. using WWPipeLine.MapBasic.Conditions;
  6. using WWPipeLine.MapBasic;
  7. using SuperMap.UI;
  8. namespace WWPipeLine.MapTools.Conditions.FuZhuGongJu
  9. {
  10. public class BZShuanDian : BasicToolBar
  11. {
  12. private Point2D m_StartPoint = Point2D.Empty;
  13. private Point2D m_EndPoint = Point2D.Empty;
  14. public BZShuanDian() : base()
  15. {
  16. this.ConditionPanelName = "栓点标注";
  17. InitializeComponent();
  18. }
  19. protected override void OnLoad(EventArgs e)
  20. {
  21. MapControl.Action = SuperMap.UI.Action.CreateLine;
  22. MapControl.Tracked += new TrackedEventHandler(MapControl_Tracked);
  23. MapControl.Tracking += new TrackingEventHandler(MapControl_Tracking);
  24. }
  25. private void MapControl_Tracking(object sender, TrackingEventArgs e)
  26. {
  27. if (m_StartPoint == Point2D.Empty)
  28. m_StartPoint = new Point2D(e.X, e.Y);
  29. else
  30. m_EndPoint = new Point2D(e.X, e.Y);
  31. }
  32. private void MapControl_Tracked(object sender, TrackedEventArgs e)
  33. {
  34. if (m_StartPoint != Point2D.Empty && m_EndPoint != Point2D.Empty)
  35. {
  36. GeoLine line = new GeoLine(new Point2Ds() { m_StartPoint, m_EndPoint });
  37. line.Style = ComsStatic.geoStyle_Brown_05mm;
  38. MapControl.Map.TrackingLayer.Add(line, "geoLine");
  39. TextPart m_TextPart = new TextPart();
  40. m_TextPart.AnchorPoint = line.InnerPoint;
  41. m_TextPart.Text = string.Format("{0}M", Math.Round(line.Length));
  42. double rotate = 0.0D;
  43. if (e.Azimuth < 180) rotate = -e.Azimuth + 90;
  44. else rotate = 270 - e.Azimuth;
  45. GeoText geoText = new GeoText(m_TextPart, ComsStatic.BiaoZhuFengGe());
  46. geoText.Rotate(line.InnerPoint, rotate);
  47. MapControl.Map.TrackingLayer.Add(geoText, "geoText");
  48. MapControl.Map.RefreshTrackingLayer();
  49. m_StartPoint = Point2D.Empty; m_EndPoint = Point2D.Empty;
  50. }
  51. }
  52. public override void AfterClose()
  53. {
  54. MapControl.Tracked -= MapControl_Tracked;
  55. MapControl.Tracking -= MapControl_Tracking;
  56. base.AfterClose();
  57. }
  58. private void InitializeComponent()
  59. {
  60. this.SuspendLayout();
  61. //
  62. // ToolsConditions
  63. //
  64. this.ResumeLayout(false);
  65. }
  66. }
  67. }