123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- 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;
- using SuperMap.Mapping;
- using System.Text;
- namespace WWPipeLine.MapTools.Conditions.FuZhuGongJu
- {
- public class BZCheQi : BasicToolBar
- {
- private Point2D m_StartPoint = Point2D.Empty;
- private Point2D m_EndPoint = Point2D.Empty;
-
-
- private StringBuilder sb = new StringBuilder();
- public BZCheQi() : base()
- {
- this.ConditionPanelName = "扯旗标注";
- InitializeComponent();
- }
- protected override void OnLoad(EventArgs e)
- {
- ComsStatic.SetLayersIsSelectableFalse(ComsStatic.gsGuanXian.Name, true);
- MapControl.Action = SuperMap.UI.Action.Select;
- MapControl.MouseClick += MapControl_MouseClick;
- MapControl.MouseMove += MapControl_MouseMove;
- }
- private void MapControl_MouseMove(object sender, MouseEventArgs e)
- {
- if (m_StartPoint != Point2D.Empty)
- {
- m_EndPoint = MapControl.Map.PixelToMap(new Point(e.X, e.Y));
- GeoLine geoLine = new GeoLine(new Point2Ds() { m_StartPoint, m_EndPoint });
- geoLine.Style = ComsStatic.geoStyle_Brown_05mm;
- int index = MapControl.Map.TrackingLayer.IndexOf("MapControl_MouseMove");
- if (index > -1) MapControl.Map.TrackingLayer.Remove(index);
- MapControl.Map.TrackingLayer.Add(geoLine, "MapControl_MouseMove");
- MapControl.Map.RefreshTrackingLayer();
- }
- }
- private void MapControl_MouseClick(object sender, MouseEventArgs e)
- {
- if (e.Button == MouseButtons.Left && MapControl.Action == SuperMap.UI.Action.Select && m_StartPoint == Point2D.Empty)
- {
- Selection[] _selection = MapControl.Map.FindSelection(true);
- if (_selection is null || _selection.Length != 1)
- {
- Sunny.UI.UIMessageTip.ShowError("没有选中任何管线元素"); return;
- }
- Recordset _recordset = _selection[0].ToRecordset();
- if (_recordset.RecordCount != 1)
- {
- Sunny.UI.UIMessageTip.ShowError("一次只可标记一条管线"); return;
- }
- QueryParameter queryParameter = new QueryParameter
- {
- AttributeFilter = string.Format(" pzlx='扯旗标注配置' AND gxlx='{0}' AND valueEnable=1 ", _recordset.Dataset.Name),
- ResultFields = new string[] { "pzKey", "valueBefore", "valueAfter" },
- OrderBy = new string[] { " valueSort asc " },
- CursorType = CursorType.Static
- };
- Recordset rd = ComsStatic.dvConfig.Query(queryParameter);
- if (rd.RecordCount == 0) { Sunny.UI.UIMessageTip.ShowError("选中的图层未配置标注字段信息"); return; }
- rd.MoveFirst();
- sb.Clear();
- while (!rd.IsEOF)
- {
- string ziduan = rd.GetFieldValue("pzKey").ToString();
- if (ComsStatic.HasField(_recordset, ziduan))
- {
- sb.AppendFormat("{0}:{1}{2}\r\n", rd.GetFieldValue("valueBefore"), _recordset.GetFieldValue(ziduan), rd.GetFieldValue("valueAfter"));
- }
- rd.MoveNext();
- }
- m_StartPoint = _recordset.GetGeometry().InnerPoint;
- ComsStatic.RecordsetDispose(_recordset);
- ComsStatic.RecordsetDispose(rd);
- }
- else if (e.Button == MouseButtons.Left && m_StartPoint != Point2D.Empty && m_EndPoint != Point2D.Empty)
- {
- TextPart m_TextPart = new TextPart();
- m_TextPart.AnchorPoint = m_EndPoint;
- m_TextPart.Text = sb.ToString();
- GeoText geoText = new GeoText(m_TextPart, ComsStatic.BiaoZhuFengGe());
- MapControl.Map.TrackingLayer.Add(geoText, "geoText");
- GeoLine geoLine = new GeoLine(new Point2Ds() { m_StartPoint, m_EndPoint });
- geoLine.Style = ComsStatic.geoStyle_Brown_05mm;
- MapControl.Map.TrackingLayer.Add(geoLine, "geoLine");
- MapControl.Map.RefreshTrackingLayer();
- m_StartPoint = Point2D.Empty; m_EndPoint = Point2D.Empty;
- }
- }
- public override void AfterClose()
- {
- MapControl.MouseClick -= MapControl_MouseClick;
- MapControl.MouseMove -= MapControl_MouseMove;
- base.AfterClose();
- }
- private void InitializeComponent()
- {
- this.SuspendLayout();
- //
- // ToolsConditions
- //
- this.Name = "坐标标注";
- this.ResumeLayout(false);
- }
- }
- }
|