BZGuanDian.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 System.Drawing;
  8. using SuperMap.UI;
  9. using WWPipeLine.MapBasic;
  10. using SuperMap.Mapping;
  11. namespace WWPipeLine.MapTools.Conditions.FuZhuGongJu
  12. {
  13. public class BZGuanDian : BasicToolBar
  14. {
  15. private Selection[] m_selection = null;
  16. private Recordset m_recordset = null;
  17. public BZGuanDian() : base()
  18. {
  19. this.ConditionPanelName = "管点标注";
  20. InitializeComponent();
  21. base.IsShowToolStripComboBox = true;
  22. toolStripComboBoxLayer.SelectedIndexChanged += ToolStripComboBoxLayer_SelectedIndexChanged;
  23. var bzBiaozhu = new ToolStripButton()
  24. {
  25. DisplayStyle = ToolStripItemDisplayStyle.ImageAndText,
  26. Text = "标注信息",
  27. Name = "bzBiaozhu",
  28. AutoToolTip = false
  29. };
  30. var img = Commons.Paths.ApplicationResourcesDir + "\\ToolBar\\标注信息.png";
  31. if (System.IO.File.Exists(img))
  32. bzBiaozhu.Image = System.Drawing.Image.FromFile(img);
  33. base.ToolStrip.Items.Add(bzBiaozhu); bzBiaozhu.Click += bzBiaozhu_Click;
  34. }
  35. private void ToolStripComboBoxLayer_SelectedIndexChanged(object sender, EventArgs e)
  36. {
  37. ComsStatic.SetLayersIsSelectableFalse(toolStripComboBoxLayer.ComboBox.SelectedValue.ToString(), true);
  38. }
  39. private void bzBiaozhu_Click(object sender, EventArgs e)
  40. {
  41. m_selection = MapControl.Map.FindSelection(true);
  42. if (m_selection is null || m_selection.Length != 1)
  43. {
  44. Sunny.UI.UIMessageTip.ShowError("没有选中任何管点元素"); return;
  45. }
  46. m_recordset = m_selection[0].ToRecordset();
  47. m_recordset.MoveFirst();
  48. GeoPoint g;
  49. TextPart m_TextPart = new TextPart();
  50. GeoText geoText;
  51. while (!m_recordset.IsEOF)
  52. {
  53. g = m_recordset.GetGeometry() as GeoPoint;
  54. m_TextPart.AnchorPoint = g.InnerPoint;
  55. m_TextPart.Text = m_recordset.GetFieldValue("fsw")?.ToString();
  56. geoText = new GeoText(m_TextPart, ComsStatic.textStyle_Brown_6mm_BottomLeft);
  57. MapControl.Map.TrackingLayer.Add(geoText, "geoText");
  58. m_recordset.MoveNext();
  59. }
  60. MapControl.Map.Refresh();
  61. }
  62. protected override void OnLoad(EventArgs e)
  63. {
  64. MapControl.Action = SuperMap.UI.Action.Select2;
  65. base.OnLoad(e);
  66. }
  67. public override void AfterClose()
  68. {
  69. ComsStatic.RecordsetDispose(m_recordset);
  70. base.AfterClose();
  71. }
  72. private void InitializeComponent()
  73. {
  74. this.SuspendLayout();
  75. //
  76. // ToolsConditions
  77. //
  78. this.Name = "坐标标注";
  79. this.ResumeLayout(false);
  80. }
  81. }
  82. }