1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- using SuperMap.Data;
- using System;
- using System.Collections.Generic;
- using System.Windows.Forms;
- using WWPipeLine.MapBasic.Conditions;
- using WWPipeLine.MapBasic;
- using System.Drawing;
- using SuperMap.UI;
- namespace WWPipeLine.MapTools.Conditions.FuZhuGongJu
- {
- public class BZZuoBiao : BasicToolBar
- {
- private Point2D m_StartPoint = Point2D.Empty;
- private Point2D m_EndPoint = Point2D.Empty;
- public BZZuoBiao() : 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)
- {
- TextPart m_TextPart = new TextPart();
- m_TextPart.AnchorPoint = m_EndPoint;
- m_TextPart.Text = string.Format("X:{0}\r\nY:{1}", Math.Round(m_StartPoint.X, 2), Math.Round(m_StartPoint.Y, 2));
- GeoText geoText = new GeoText(m_TextPart, ComsStatic.BiaoZhuFengGe());
- MapControl.Map.TrackingLayer.Add(geoText, "geoText");
- Point2D p3 = new Point2D(geoText.Bounds.Right, geoText.Bounds.Bottom);
- //此处调试geoText.Bounds 左右、上下端点几乎一致 但是实际上界面是有XY坐标显示额
- //geoText.Bounds.Left 833130.131007001
- //geoText.Bounds.Right 833130.131007401
- //geoText.Bounds.Top 5051136.9966243524
- //geoText.Bounds.Bottom 5051136.9966239519
- GeoLine geoLine = new GeoLine();
- geoLine.AddPart(new Point2Ds() { m_StartPoint, m_EndPoint, p3 });
- geoLine.Style = ComsStatic.geoStyle_Brown_05mm;
- MapControl.Map.TrackingLayer.Add(geoLine, "geoLine");
- 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);
- }
- }
- }
|