1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- using SuperMap.Data;
- using System;
- using System.Collections.Generic;
- using System.Windows.Forms;
- using WWPipeLine.MapBasic.Conditions;
- using WWPipeLine.MapBasic;
- using SuperMap.UI;
- namespace WWPipeLine.MapTools.Conditions.FuZhuGongJu
- {
- public class BZShuanDian : BasicToolBar
- {
- private Point2D m_StartPoint = Point2D.Empty;
- private Point2D m_EndPoint = Point2D.Empty;
- public BZShuanDian() : base()
- {
- this.ConditionPanelName = "栓点标注";
- InitializeComponent();
- toolStripLB.Text = "鼠标左键点击选择起点,再次点击选择终点,并完成标注。";
- }
- protected override void OnLoad(EventArgs e)
- {
- MapControl.Action = SuperMap.UI.Action.CreateLine;
- MapControl.Tracked += new TrackedEventHandler(MapControl_Tracked);
- MapControl.Tracking += new TrackingEventHandler(MapControl_Tracking);
- }
- private void MapControl_Tracking(object sender, TrackingEventArgs e)
- {
- if (m_StartPoint == Point2D.Empty)
- m_StartPoint = new Point2D(e.X, e.Y);
- else
- m_EndPoint = new Point2D(e.X, e.Y);
- }
- private void MapControl_Tracked(object sender, TrackedEventArgs e)
- {
- if (m_StartPoint != Point2D.Empty && m_EndPoint != Point2D.Empty)
- {
- GeoLine line = new GeoLine(new Point2Ds() { m_StartPoint, m_EndPoint });
- line.Style = ComsStatic.geoStyle_Brown_05mm;
- MapControl.Map.TrackingLayer.Add(line, "geoLine");
- TextPart m_TextPart = new TextPart();
- m_TextPart.AnchorPoint = line.InnerPoint;
- m_TextPart.Text = string.Format("{0}M", Math.Round(line.Length));
- double rotate = 0.0D;
- if (e.Azimuth < 180) rotate = -e.Azimuth + 90;
- else rotate = 270 - e.Azimuth;
- GeoText geoText = new GeoText(m_TextPart, ComsStatic.BiaoZhuFengGe());
- geoText.Rotate(line.InnerPoint, rotate);
- MapControl.Map.TrackingLayer.Add(geoText, "geoText");
- m_StartPoint = Point2D.Empty; m_EndPoint = Point2D.Empty;
- MapControl.Map.Refresh();
- }
- }
- public override void AfterClose()
- {
- MapControl.Tracked -= MapControl_Tracked;
- MapControl.Tracking -= MapControl_Tracking;
- base.AfterClose();
- }
- private void InitializeComponent()
- {
- this.SuspendLayout();
- //
- // ToolsConditions
- //
- this.ResumeLayout(false);
- }
- }
- }
|