BZGuanWang.cs 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 BZGuanWang : BasicToolBar
  13. {
  14. public BZGuanWang() : base()
  15. {
  16. this.ConditionPanelName = "管网标注";
  17. InitializeComponent();
  18. var bzBiaozhu = new ToolStripButton()
  19. {
  20. DisplayStyle = ToolStripItemDisplayStyle.ImageAndText,
  21. Text = "标注信息",
  22. Name = "bzBiaozhu",
  23. AutoToolTip = false
  24. };
  25. var img = Commons.Paths.ApplicationResourcesDir + "\\ToolBar\\标注信息.png";
  26. if (System.IO.File.Exists(img)) bzBiaozhu.Image = System.Drawing.Image.FromFile(img);
  27. base.ToolStrip.Items.Add(bzBiaozhu); bzBiaozhu.Click += bzBiaozhu_Click;
  28. }
  29. private void bzBiaozhu_Click(object sender, EventArgs e)
  30. {
  31. Selection[] m_selection = MapControl.Map.FindSelection(true);
  32. if (m_selection is null || m_selection.Length != 1)
  33. {
  34. Sunny.UI.UIMessageTip.ShowError("没有选中任何管线元素"); return;
  35. }
  36. Recordset m_recordset = m_selection[0].ToRecordset();
  37. if (m_recordset.Dataset.Name != ComsStatic.gsGuanXian.Name)
  38. {
  39. Sunny.UI.UIMessageTip.ShowError("当前选择图层不是管线图层"); return;
  40. }
  41. QueryParameter queryParameter = new QueryParameter
  42. {
  43. AttributeFilter = string.Format(" pzlx='标注字段配置' AND gxlx='{0}' AND valueEnable=1 ", m_recordset.Dataset.Name),
  44. ResultFields = new string[] { "pzKey", "valueBefore", "valueAfter" },
  45. OrderBy = new string[] { " valueSort asc " },
  46. CursorType = CursorType.Static
  47. };
  48. Recordset rd = ComsStatic.dvConfig.Query(queryParameter);
  49. if (rd.RecordCount == 0) { Sunny.UI.UIMessageTip.ShowError("选中的图层未配置标注字段信息"); return; }
  50. TextPart m_TextPart = new TextPart();
  51. GeoText geoText = new GeoText();
  52. geoText.TextStyle = ComsStatic.BiaoZhuFengGe();
  53. m_recordset.MoveFirst();
  54. StringBuilder sb = new StringBuilder();
  55. while (!m_recordset.IsEOF)
  56. {
  57. m_TextPart.AnchorPoint = m_recordset.GetGeometry().InnerPoint;
  58. rd.MoveFirst();
  59. sb.Clear();
  60. while (!rd.IsEOF)
  61. {
  62. string ziduan = rd.GetFieldValue("pzKey").ToString();
  63. if (ComsStatic.HasField(m_recordset, ziduan))
  64. {
  65. sb.AppendFormat("{0}:{1}{2}\r\n", rd.GetFieldValue("valueBefore"), m_recordset.GetFieldValue(ziduan), rd.GetFieldValue("valueAfter"));
  66. }
  67. rd.MoveNext();
  68. }
  69. m_TextPart.Text = sb.ToString();
  70. geoText.AddPart(m_TextPart);
  71. m_recordset.MoveNext();
  72. }
  73. ComsStatic.RecordsetDispose(m_recordset);
  74. ComsStatic.RecordsetDispose(rd);
  75. MapControl.Map.TrackingLayer.Add(geoText, "geoText");
  76. MapControl.Map.RefreshTrackingLayer();
  77. }
  78. protected override void OnLoad(EventArgs e)
  79. {
  80. ComsStatic.SetLayersIsSelectableFalse(ComsStatic.gsGuanXian.Name, true);
  81. MapControl.Action = SuperMap.UI.Action.Select2;
  82. }
  83. private void InitializeComponent()
  84. {
  85. this.SuspendLayout();
  86. //
  87. // ToolsConditions
  88. //
  89. this.Name = "坐标标注";
  90. this.ResumeLayout(false);
  91. }
  92. }
  93. }