BZGuanDian.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. using SuperMap.Data;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Windows.Forms;
  5. using WWPipeLine.MapBasic.Conditions;
  6. using WWPipeLine.MapBasic;
  7. using SuperMap.UI;
  8. using SuperMap.Mapping;
  9. using System.Text;
  10. namespace WWPipeLine.MapTools.Conditions.FuZhuGongJu
  11. {
  12. public class BZGuanDian : BasicToolBar
  13. {
  14. private Selection[] m_selection = null;
  15. private Recordset m_recordset = null;
  16. private StringBuilder sb = new StringBuilder();
  17. public BZGuanDian() : base()
  18. {
  19. this.ConditionPanelName = "管点标注";
  20. InitializeComponent();
  21. toolStripLB.Text = "先选择需要标注的图层,再框选需要标注的元素,最后点击“标注信息”完成标注。";
  22. base.IsShowToolStripComboBox = true;
  23. toolStripComboBoxLayer.SelectedIndexChanged += ToolStripComboBoxLayer_SelectedIndexChanged;
  24. var bzBiaozhu = new ToolStripButton()
  25. {
  26. DisplayStyle = ToolStripItemDisplayStyle.Text,
  27. Text = "标注信息",
  28. Name = "bzBiaozhu",
  29. AutoToolTip = false
  30. };
  31. base.ToolStrip.Items.Add(bzBiaozhu); bzBiaozhu.Click += bzBiaozhu_Click;
  32. }
  33. private void ToolStripComboBoxLayer_SelectedIndexChanged(object sender, EventArgs e)
  34. {
  35. ComsStatic.SetLayersIsSelectableFalse(toolStripComboBoxLayer.ComboBox.SelectedValue?.ToString(), true);
  36. }
  37. private void bzBiaozhu_Click(object sender, EventArgs e)
  38. {
  39. m_selection = MapControl.Map.FindSelection(true);
  40. if (m_selection is null || m_selection.Length != 1)
  41. {
  42. Sunny.UI.UIMessageTip.ShowError("没有选中任何管点元素"); return;
  43. }
  44. m_recordset = m_selection[0].ToRecordset();
  45. QueryParameter queryParameter = new QueryParameter
  46. {
  47. AttributeFilter = string.Format(" pzlx='标注字段配置' AND gxlx='{0}' AND valueEnable=1 ", m_recordset.Dataset.Name),
  48. ResultFields = new string[] { "pzKey", "valueBefore", "valueAfter" },
  49. OrderBy = new string[] { " valueSort asc " },
  50. CursorType = CursorType.Static
  51. };
  52. Recordset rd = ComsStatic.dvJSLK_PZ.Query(queryParameter);
  53. if (rd.RecordCount == 0) { Sunny.UI.UIMessageTip.ShowError("选中的图层未配置标注字段信息"); return; }
  54. m_recordset.MoveFirst();
  55. GeoPoint g;
  56. TextPart m_TextPart = new TextPart();
  57. GeoText geoText = new GeoText();
  58. geoText.TextStyle = ComsStatic.BiaoZhuFengGe();
  59. while (!m_recordset.IsEOF)
  60. {
  61. g = m_recordset.GetGeometry() as GeoPoint;
  62. m_TextPart.AnchorPoint = g.InnerPoint;
  63. rd.MoveFirst();
  64. sb.Clear();
  65. while (!rd.IsEOF)
  66. {
  67. string ziduan = rd.GetFieldValue("pzKey").ToString();
  68. if (ComsStatic.HasField(m_recordset, ziduan))
  69. {
  70. sb.AppendFormat("{0}:{1}{2}\r\n", rd.GetFieldValue("valueBefore"), m_recordset.GetFieldValue(ziduan)?.ToString().Split('.')[0], rd.GetFieldValue("valueAfter"));
  71. }
  72. rd.MoveNext();
  73. }
  74. m_TextPart.Text = sb.ToString();
  75. geoText.AddPart(m_TextPart);
  76. m_recordset.MoveNext();
  77. }
  78. MapControl.Map.TrackingLayer.Add(geoText, "geoText");
  79. MapControl.Map.Refresh();
  80. }
  81. protected override void OnLoad(EventArgs e)
  82. {
  83. MapControl.Action = SuperMap.UI.Action.Select2;
  84. base.OnLoad(e);
  85. }
  86. public override void AfterClose()
  87. {
  88. ComsStatic.RecordsetDispose(m_recordset);
  89. base.AfterClose();
  90. }
  91. private void InitializeComponent()
  92. {
  93. this.SuspendLayout();
  94. //
  95. // BZGuanDian
  96. //
  97. this.ResumeLayout(false);
  98. this.PerformLayout();
  99. }
  100. }
  101. }