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 BZGuanDian : BasicToolBar { private Selection[] m_selection = null; private Recordset m_recordset = null; private StringBuilder sb = new StringBuilder(); public BZGuanDian() : base() { this.ConditionPanelName = "管点标注"; InitializeComponent(); toolStripLB.Text = "先选择需要标注的图层,再框选需要标注的元素,最后点击“标注信息”完成标注。"; base.IsShowToolStripComboBox = true; toolStripComboBoxLayer.SelectedIndexChanged += ToolStripComboBoxLayer_SelectedIndexChanged; var bzBiaozhu = new ToolStripButton() { DisplayStyle = ToolStripItemDisplayStyle.Text, Text = "标注信息", Name = "bzBiaozhu", AutoToolTip = false }; base.ToolStrip.Items.Add(bzBiaozhu); bzBiaozhu.Click += bzBiaozhu_Click; } private void ToolStripComboBoxLayer_SelectedIndexChanged(object sender, EventArgs e) { ComsStatic.SetLayersIsSelectableFalse(toolStripComboBoxLayer.ComboBox.SelectedValue?.ToString(), true); } private void bzBiaozhu_Click(object sender, EventArgs e) { 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(); 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; } m_recordset.MoveFirst(); GeoPoint g; TextPart m_TextPart = new TextPart(); GeoText geoText = new GeoText(); geoText.TextStyle = ComsStatic.BiaoZhuFengGe(); while (!m_recordset.IsEOF) { g = m_recordset.GetGeometry() as GeoPoint; m_TextPart.AnchorPoint = g.InnerPoint; 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) { MapControl.Action = SuperMap.UI.Action.Select2; base.OnLoad(e); } public override void AfterClose() { ComsStatic.RecordsetDispose(m_recordset); base.AfterClose(); } private void InitializeComponent() { this.SuspendLayout(); // // BZGuanDian // this.ResumeLayout(false); this.PerformLayout(); } } }