BZGuanDian.cs 3.2 KB

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