LayerWithDataListPanel.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. }
  23. /// <summary>
  24. /// 加载矢量图层列表
  25. /// </summary>
  26. /// <param name="multiSelect"></param>
  27. public void LoadToVector(bool multiSelect = false, bool hasJSLK = true)
  28. {
  29. var types = new List<DatasetType>()
  30. {
  31. DatasetType.Point,
  32. DatasetType.Line,
  33. DatasetType.Region,
  34. DatasetType.Network,
  35. };
  36. foreach (Layer lyr in ComsStatic.MapLayers)
  37. {
  38. if (!hasJSLK && lyr.Dataset.Name == ComsStatic.dvJSLK.Name) continue;
  39. Dataset dataset = lyr.Dataset;
  40. if (dataset == null) continue;
  41. if (!types.Contains(dataset.Type)) continue;
  42. if (multiSelect)
  43. {
  44. Sunny.UI.UICheckBox cBtn = new UICheckBox()
  45. {
  46. Name = lyr.Name,
  47. Text = lyr.Caption,
  48. Tag = lyr,
  49. Location = new System.Drawing.Point(20, 40 + this.Controls.Count * 28),
  50. AutoSize = true
  51. };
  52. this.Add(cBtn);
  53. cBtn.ValueChanged += CBtn_ValueChanged;
  54. }
  55. else
  56. {
  57. Sunny.UI.UIRadioButton rBtn = new UIRadioButton()
  58. {
  59. Name = lyr.Name,
  60. Text = lyr.Caption,
  61. Tag = lyr,
  62. Location = new System.Drawing.Point(20, 40 + this.Controls.Count * 28),
  63. AutoSize = true
  64. };
  65. this.Add(rBtn);
  66. rBtn.ValueChanged += RBtn_ValueChanged;
  67. }
  68. }
  69. }
  70. private void CBtn_ValueChanged(object sender, bool value)
  71. {
  72. var cBtn = sender as UICheckBox;
  73. if (cBtn.Checked)
  74. SelectLayers.Add(cBtn.Tag as Layer);
  75. else
  76. SelectLayers.Remove(cBtn.Tag as Layer);
  77. }
  78. private void RBtn_ValueChanged(object sender, bool value)
  79. {
  80. var rBtn = sender as UIRadioButton;
  81. if (!rBtn.Checked) return;
  82. SelectLayers.Clear(); SelectLayers.Add(rBtn.Tag as Layer);
  83. }
  84. private List<Layer> m_SelectLayers = new List<Layer>();
  85. /// <summary>
  86. /// 选择图层列表
  87. /// </summary>
  88. public List<Layer> SelectLayers { get => m_SelectLayers; }
  89. private void InitializeComponent()
  90. {
  91. this.SuspendLayout();
  92. //
  93. // LayerWithDataListPanel
  94. //
  95. this.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(242)))), ((int)(((byte)(242)))), ((int)(((byte)(244)))));
  96. this.Name = "LayerWithDataListPanel";
  97. this.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(140)))), ((int)(((byte)(140)))), ((int)(((byte)(140)))));
  98. this.Size = new System.Drawing.Size(1, 1);
  99. this.Style = Sunny.UI.UIStyle.Gray;
  100. this.ResumeLayout(false);
  101. }
  102. }
  103. }