LayerWithDataListPanel.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. using Sunny.UI;
  2. using SuperMap.Data;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Windows.Forms;
  6. using SuperMap.Mapping;
  7. using SuperMap.UI;
  8. namespace WWPipeLine.MapBasic
  9. {
  10. /// <summary>
  11. /// 数据图层列表:用于显示场景中的图层。
  12. /// </summary>
  13. public class LayerWithDataListPanel : Sunny.UI.UIFlowLayoutPanel
  14. {
  15. public LayerWithDataListPanel() : base()
  16. {
  17. InitializeComponent();
  18. this.Text = "LayerWithDataListPanel";
  19. this.Dock = DockStyle.Fill;
  20. this.RectSides = ToolStripStatusLabelBorderSides.None;//边框显示位置 没有边框
  21. this.RadiusSides = UICornerRadiusSides.None;//圆角显示位置 没有圆角
  22. this.Margin = new Padding(2);
  23. }
  24. /// <summary>
  25. /// 加载矢量图层列表
  26. /// </summary>
  27. /// <param name="multiSelect">是否多选</param>
  28. /// <param name="hasJSLK">是否包括供水管线dvJSLK图层</param>
  29. /// <param name="hasOther">默认为False,是MapLayers True表示是MapLayersALL</param>
  30. public void LoadToVector(bool multiSelect, bool hasJSLK, bool hasOther = false)
  31. {
  32. List<DatasetType> types = new List<DatasetType>() { DatasetType.Point, DatasetType.Line, DatasetType.Region };
  33. List<Layer> layerList = ComsStatic.MapLayers;
  34. if (hasOther) layerList = ComsStatic.MapLayersUsed;
  35. foreach (Layer lyr in layerList)
  36. {
  37. if (!hasJSLK && lyr.Dataset.Name == ComsStatic.dvJSLK.Name) continue;
  38. if (lyr.Dataset == null) continue;
  39. if (!types.Contains(lyr.Dataset.Type)) continue;
  40. if (multiSelect)
  41. {
  42. Sunny.UI.UICheckBox cBtn = new UICheckBox()
  43. {
  44. Name = lyr.Name,
  45. Text = lyr.Caption,
  46. Tag = lyr,
  47. Location = new System.Drawing.Point(20, 30 + this.Controls.Count * 28),
  48. Width = 120
  49. };
  50. this.Add(cBtn); cBtn.ValueChanged += CBtn_ValueChanged;
  51. }
  52. else
  53. {
  54. Sunny.UI.UIRadioButton rBtn = new UIRadioButton()
  55. {
  56. Name = lyr.Name,
  57. Text = lyr.Caption,
  58. Tag = lyr,
  59. Location = new System.Drawing.Point(20, 30 + this.Controls.Count * 28),
  60. Width = 120
  61. };
  62. this.Add(rBtn); rBtn.ValueChanged += RBtn_ValueChanged;
  63. }
  64. }
  65. }
  66. private void CBtn_ValueChanged(object sender, bool value)
  67. {
  68. var cBtn = sender as UICheckBox;
  69. if (cBtn.Checked)
  70. SelectLayers.Add(cBtn.Tag as Layer);
  71. else
  72. SelectLayers.Remove(cBtn.Tag as Layer);
  73. }
  74. private void RBtn_ValueChanged(object sender, bool value)
  75. {
  76. var rBtn = sender as UIRadioButton;
  77. if (!rBtn.Checked) return;
  78. SelectLayers.Clear(); SelectLayers.Add(rBtn.Tag as Layer);
  79. }
  80. private List<Layer> m_SelectLayers = new List<Layer>();
  81. /// <summary>
  82. /// 选择图层列表
  83. /// </summary>
  84. public List<Layer> SelectLayers { get => m_SelectLayers; }
  85. public void CheckedFirst()
  86. {
  87. try
  88. {
  89. UIRadioButton rBtn = this.Controls[2].Controls[0] as UIRadioButton;
  90. rBtn.Checked = true;
  91. }
  92. catch { }
  93. }
  94. private void InitializeComponent()
  95. {
  96. this.SuspendLayout();
  97. //
  98. // LayerWithDataListPanel
  99. //
  100. this.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(242)))), ((int)(((byte)(242)))), ((int)(((byte)(244)))));
  101. this.Name = "LayerWithDataListPanel";
  102. this.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(140)))), ((int)(((byte)(140)))), ((int)(((byte)(140)))));
  103. this.Size = new System.Drawing.Size(1, 1);
  104. this.Style = Sunny.UI.UIStyle.Gray;
  105. this.ResumeLayout(false);
  106. }
  107. }
  108. }