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
{
///
/// 数据图层列表:用于显示场景中的图层。
///
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);
}
///
/// 加载矢量图层列表
///
/// 是否多选
/// 是否包括供水管线dvJSLK图层
/// 默认为False,是MapLayers True表示是MapLayersALL
public void LoadToVector(bool multiSelect, bool hasJSLK, bool hasOther = false)
{
List types = new List() { DatasetType.Point, DatasetType.Line, DatasetType.Region };
List 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 m_SelectLayers = new List();
///
/// 选择图层列表
///
public List 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);
}
}
}