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);
}
///
/// 加载矢量图层列表
///
/// 是否多选
/// 是否包括供水管线gsGuanXian图层
/// 默认为False,是MapLayers True表示是MapLayersUsed
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.gsGuanXian.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(10, 10 + 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(10, 10 + 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)
m_SelectLayers.Add(cBtn.Tag as Layer);
else
m_SelectLayers.Remove(cBtn.Tag as Layer);
}
private void RBtn_ValueChanged(object sender, bool value)
{
var rBtn = sender as UIRadioButton;
if (!rBtn.Checked) return;
m_SelectLayers.Clear(); m_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);
}
}
}