123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- 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;//圆角显示位置 没有圆角
- this.Margin = new Padding(2);
- }
- /// <summary>
- /// 加载矢量图层列表
- /// </summary>
- /// <param name="multiSelect">是否多选</param>
- /// <param name="hasJSLK">是否包括供水管线dvJSLK图层</param>
- /// <param name="hasOther">默认为False,是MapLayers True表示是MapLayersALL</param>
- public void LoadToVector(bool multiSelect, bool hasJSLK, bool hasOther = false)
- {
- List<DatasetType> types = new List<DatasetType>() { DatasetType.Point, DatasetType.Line, DatasetType.Region };
- List<Layer> layerList = ComsStatic.MapLayers;
- if (hasOther) layerList = ComsStatic.MapLayersUsed;
- foreach (Layer lyr in layerList)
- {
- if (!hasJSLK && lyr.Dataset.Name == ComsStatic.dvJSLK.Name) continue;
- if (lyr.Dataset == null) continue;
- if (!types.Contains(lyr.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, 30 + this.Controls.Count * 28),
- Width = 120
- };
- 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, 30 + this.Controls.Count * 28),
- Width = 120
- };
- 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; }
- public void CheckedFirst()
- {
- try
- {
- UIRadioButton rBtn = this.Controls[2].Controls[0] as UIRadioButton;
- rBtn.Checked = true;
- }
- catch { }
- }
- 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);
- }
- }
- }
|