123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- using Sunny.UI;
- using SuperMap.Data;
- using System;
- using System.Collections.Generic;
- using System.Windows.Forms;
- using SuperMap.Mapping;
- using SuperMap.UI;
- namespace WWPipeLine.MapBasic
- {
- /// <summary>
- /// 数据图层列表:用于显示场景中的图层。
- /// </summary>
- public class LayerWithDataListPanel : Sunny.UI.UIFlowLayoutPanel
- {
- public LayerWithDataListPanel() : base()
- {
- InitializeComponent();
- this.Text = "LayerWithDataListPanel";
- this.Dock = DockStyle.Fill;
- this.RectSides = ToolStripStatusLabelBorderSides.None;//边框显示位置 没有边框
- this.RadiusSides = UICornerRadiusSides.None;//圆角显示位置 没有圆角
- }
- /// <summary>
- /// 加载矢量图层列表
- /// </summary>
- /// <param name="multiSelect"></param>
- public void LoadToVector(bool multiSelect = false, bool hasJSLK = true)
- {
- var types = new List<DatasetType>()
- {
- DatasetType.Point,
- DatasetType.Line,
- DatasetType.Region,
- DatasetType.Network,
- };
- foreach (Layer lyr in ComsStatic.MapLayers)
- {
- if (!hasJSLK && lyr.Dataset.Name == ComsStatic.dvJSLK.Name) continue;
- Dataset dataset = lyr.Dataset;
- if (dataset == null) continue;
- if (!types.Contains(dataset.Type)) continue;
- if (multiSelect)
- {
- Sunny.UI.UICheckBox cBtn = new UICheckBox()
- {
- Name = lyr.Name,
- Text = lyr.Caption,
- Tag = lyr,
- Location = new System.Drawing.Point(20, 40 + this.Controls.Count * 28),
- AutoSize = true
- };
- this.Add(cBtn);
- cBtn.ValueChanged += CBtn_ValueChanged;
- }
- else
- {
- Sunny.UI.UIRadioButton rBtn = new UIRadioButton()
- {
- Name = lyr.Name,
- Text = lyr.Caption,
- Tag = lyr,
- Location = new System.Drawing.Point(20, 40 + this.Controls.Count * 28),
- AutoSize = true
- };
- this.Add(rBtn);
- rBtn.ValueChanged += RBtn_ValueChanged;
- }
- }
- }
- private void CBtn_ValueChanged(object sender, bool value)
- {
- var cBtn = sender as UICheckBox;
- if (cBtn.Checked)
- SelectLayers.Add(cBtn.Tag as Layer);
- else
- SelectLayers.Remove(cBtn.Tag as Layer);
- }
- private void RBtn_ValueChanged(object sender, bool value)
- {
- var rBtn = sender as UIRadioButton;
- if (!rBtn.Checked) return;
- SelectLayers.Clear(); SelectLayers.Add(rBtn.Tag as Layer);
- }
- private List<Layer> m_SelectLayers = new List<Layer>();
- /// <summary>
- /// 选择图层列表
- /// </summary>
- public List<Layer> SelectLayers { get => m_SelectLayers; }
- private void InitializeComponent()
- {
- this.SuspendLayout();
- //
- // LayerWithDataListPanel
- //
- this.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(242)))), ((int)(((byte)(242)))), ((int)(((byte)(244)))));
- this.Name = "LayerWithDataListPanel";
- this.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(140)))), ((int)(((byte)(140)))), ((int)(((byte)(140)))));
- this.Size = new System.Drawing.Size(1, 1);
- this.Style = Sunny.UI.UIStyle.Gray;
- this.ResumeLayout(false);
- }
- }
- }
|