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;//圆角显示位置 没有圆角
}
///
/// 加载矢量图层列表
///
///
public void LoadToVector(bool multiSelect = false, bool hasJSLK = true)
{
var types = new List()
{
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 m_SelectLayers = new List();
///
/// 选择图层列表
///
public List 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);
}
}
}