123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- 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
- {
- public BZGuanDian() : base()
- {
- this.ConditionPanelName = "管点标注";
- InitializeComponent();
- base.IsShowToolStripComboBox = true;
- toolStripComboBoxLayer.SelectedIndexChanged += ToolStripComboBoxLayer_SelectedIndexChanged;
- 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 ToolStripComboBoxLayer_SelectedIndexChanged(object sender, EventArgs e)
- {
- ComsStatic.SetLayersIsSelectableFalse((toolStripComboBoxLayer.ComboBox.SelectedItem as DoListItem).Key, true);
- }
- 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;
- }
- Recordset 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.dvConfig.Query(queryParameter);
- if (rd.RecordCount == 0) { Sunny.UI.UIMessageTip.ShowError("选中的图层未配置标注字段信息"); return; }
- m_recordset.MoveFirst();
- TextPart m_TextPart = new TextPart();
- GeoText geoText = new GeoText();
- geoText.TextStyle = ComsStatic.BiaoZhuFengGe();
- StringBuilder sb = new StringBuilder();
- while (!m_recordset.IsEOF)
- {
- m_TextPart.AnchorPoint = m_recordset.GetGeometry().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), rd.GetFieldValue("valueAfter"));
- }
- rd.MoveNext();
- }
- m_TextPart.Text = sb.ToString();
- geoText.AddPart(m_TextPart);
- m_recordset.MoveNext();
- }
- ComsStatic.RecordsetDispose(m_recordset);
- ComsStatic.RecordsetDispose(rd);
- MapControl.Map.TrackingLayer.Add(geoText, "geoText");
- MapControl.Map.RefreshTrackingLayer();
- }
- protected override void OnLoad(EventArgs e)
- {
- MapControl.Action = SuperMap.UI.Action.Select2;
- base.OnLoad(e);
- }
- private void InitializeComponent()
- {
- this.SuspendLayout();
- //
- // BZGuanDian
- //
- this.ResumeLayout(false);
- this.PerformLayout();
- }
- }
- }
|