123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- using SuperMap.Data;
- using System;
- using System.Collections.Generic;
- using System.Windows.Forms;
- using WWPipeLine.MapBasic.Conditions;
- using WWPipeLine.MapBasic;
- using SuperMap.UI;
- using SuperMap.Mapping;
- using System.Text;
- namespace WWPipeLine.MapTools.Conditions.FuZhuGongJu
- {
- public class BZGuanWang : BasicToolBar
- {
- private Recordset m_recordset = null;
- private StringBuilder sb = new StringBuilder();
- public BZGuanWang() : base()
- {
- this.ConditionPanelName = "管网标注";
- InitializeComponent();
- toolStripLB.Text = "先框选需要标注的管线,然后点击“标注信息”完成标注。";
- var bzBiaozhu = new ToolStripButton()
- {
- DisplayStyle = ToolStripItemDisplayStyle.ImageAndText,
- Text = "标注信息",
- Name = "bzBiaozhu",
- AutoToolTip = false
- };
- var img = Commons.Paths.ApplicationResourcesDir + "\\ToolBar\\标注信息.png";
- if (System.IO.File.Exists(img)) bzBiaozhu.Image = System.Drawing.Image.FromFile(img);
- base.ToolStrip.Items.Add(bzBiaozhu); bzBiaozhu.Click += bzBiaozhu_Click;
- }
- private void bzBiaozhu_Click(object sender, EventArgs e)
- {
- Selection[] m_selection = MapControl.Map.FindSelection(true);
- if (m_selection is null || m_selection.Length != 1)
- {
- Sunny.UI.UIMessageTip.ShowError("没有选中任何管线元素"); return;
- }
- m_recordset = m_selection[0].ToRecordset();
- if (m_recordset.Dataset.Name != ComsStatic.dvJSLK.Name)
- {
- Sunny.UI.UIMessageTip.ShowError("当前选择图层不是管线图层"); return;
- }
- QueryParameter queryParameter = new QueryParameter
- {
- AttributeFilter = string.Format(" pzlx='标注字段配置' AND gxlx='{0}' AND valueEnable=1 ", m_recordset.Dataset.Name),
- ResultFields = new string[] { "pzKey", "valueBefore", "valueAfter" },
- OrderBy = new string[] { " valueSort asc " },
- CursorType = CursorType.Static
- };
- Recordset rd = ComsStatic.dvJSLK_PZ.Query(queryParameter);
- if (rd.RecordCount == 0) { Sunny.UI.UIMessageTip.ShowError("选中的图层未配置标注字段信息"); return; }
- GeoLine g;
- TextPart m_TextPart = new TextPart();
- GeoText geoText = new GeoText();
- geoText.TextStyle = ComsStatic.BiaoZhuFengGe();
- m_recordset.MoveFirst();
- while (!m_recordset.IsEOF)
- {
- g = m_recordset.GetGeometry() as GeoLine;
- m_TextPart.AnchorPoint = g.InnerPoint;
- //m_TextPart.Text = string.Format("D{0} {1}M", m_recordset.GetFieldValue("gj"), ComsStatic.StringToDouble(m_recordset.GetFieldValue("cd")), 0);
- rd.MoveFirst();
- sb.Clear();
- while (!rd.IsEOF)
- {
- string ziduan = rd.GetFieldValue("pzKey").ToString();
- if (ComsStatic.HasField(m_recordset, ziduan))
- {
- sb.AppendFormat("{0}:{1}{2}\r\n", rd.GetFieldValue("valueBefore"), m_recordset.GetFieldValue(ziduan)?.ToString().Split('.')[0], rd.GetFieldValue("valueAfter"));
- }
- rd.MoveNext();
- }
- m_TextPart.Text = sb.ToString();
- geoText.AddPart(m_TextPart);
- m_recordset.MoveNext();
- }
- MapControl.Map.TrackingLayer.Add(geoText, "geoText");
- MapControl.Map.Refresh();
- }
- protected override void OnLoad(EventArgs e)
- {
- ComsStatic.SetLayersIsSelectableFalse(ComsStatic.dvJSLK.Name, true);
- MapControl.Action = SuperMap.UI.Action.Select2;
- }
- public override void AfterClose()
- {
- ComsStatic.RecordsetDispose(m_recordset);
- base.AfterClose();
- }
- private void InitializeComponent()
- {
- this.SuspendLayout();
- //
- // ToolsConditions
- //
- this.Name = "坐标标注";
- this.ResumeLayout(false);
- }
- }
- }
|