LayerWithDataListPanel.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. public class LayerWithDataListPanel : Sunny.UI.UIFlowLayoutPanel
  11. {
  12. public LayerWithDataListPanel() : base()
  13. {
  14. InitializeComponent();
  15. this.Text = "LayerWithDataListPanel";
  16. this.Dock = DockStyle.Fill;
  17. this.RectSides = ToolStripStatusLabelBorderSides.None;
  18. this.RadiusSides = UICornerRadiusSides.None;
  19. this.Margin = new Padding(2);
  20. }
  21. /// <summary>
  22. /// 加载矢量图层列表
  23. /// </summary>
  24. /// <param name="multiSelect">是否多选</param>
  25. /// <param name="hasJSLK">是否包括供水管线gsGuanXian图层</param>
  26. /// <param name="hasOther">默认为False,是MapLayers True表示是MapLayersUsed</param>
  27. public void LoadToVector(bool multiSelect, bool hasJSLK, bool hasOther = false)
  28. {
  29. //List<DatasetType> types = new List<DatasetType>() { DatasetType.Point, DatasetType.Line, DatasetType.Region };
  30. List<Layer> layerList = ComsStatic.MapLayers;
  31. if (hasOther) layerList = ComsStatic.MapLayersUsed;
  32. foreach (Layer lyr in layerList)
  33. {
  34. if (!hasJSLK && lyr.Dataset.Name == ComsStatic.gsGuanXian.Name) continue;
  35. //if (lyr.Dataset == null) continue;
  36. //if (!types.Contains(lyr.Dataset.Type)) continue;
  37. if (multiSelect)
  38. {
  39. Sunny.UI.UICheckBox cBtn = new UICheckBox()
  40. {
  41. Name = lyr.Name,
  42. Text = lyr.Caption,
  43. Tag = lyr,
  44. Location = new System.Drawing.Point(10, 10 + this.Controls.Count * 28),
  45. Width = 120
  46. };
  47. this.Add(cBtn); cBtn.ValueChanged += CBtn_ValueChanged;
  48. }
  49. else
  50. {
  51. Sunny.UI.UIRadioButton rBtn = new UIRadioButton()
  52. {
  53. Name = lyr.Name,
  54. Text = lyr.Caption,
  55. Tag = lyr,
  56. Location = new System.Drawing.Point(10, 10 + this.Controls.Count * 28),
  57. Width = 120
  58. };
  59. this.Add(rBtn); rBtn.ValueChanged += RBtn_ValueChanged;
  60. }
  61. }
  62. }
  63. private void CBtn_ValueChanged(object sender, bool value)
  64. {
  65. var cBtn = sender as UICheckBox;
  66. if (cBtn.Checked)
  67. m_SelectLayers.Add(cBtn.Tag as Layer);
  68. else
  69. m_SelectLayers.Remove(cBtn.Tag as Layer);
  70. }
  71. private void RBtn_ValueChanged(object sender, bool value)
  72. {
  73. var rBtn = sender as UIRadioButton;
  74. if (!rBtn.Checked) return;
  75. m_SelectLayers.Clear(); m_SelectLayers.Add(rBtn.Tag as Layer);
  76. }
  77. private List<Layer> m_SelectLayers = new List<Layer>();
  78. public List<Layer> SelectLayers { get => m_SelectLayers; }
  79. private void InitializeComponent()
  80. {
  81. this.SuspendLayout();
  82. //
  83. // LayerWithDataListPanel
  84. //
  85. this.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(242)))), ((int)(((byte)(242)))), ((int)(((byte)(244)))));
  86. this.Name = "LayerWithDataListPanel";
  87. this.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(140)))), ((int)(((byte)(140)))), ((int)(((byte)(140)))));
  88. this.Size = new System.Drawing.Size(1, 1);
  89. this.Style = Sunny.UI.UIStyle.Gray;
  90. this.ResumeLayout(false);
  91. }
  92. }
  93. }