年度变更建库软件5.0版本
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

276 lines
8.2 KiB

using Kingo.PluginServiceInterface.Model;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
namespace Kingo.PluginServiceInterface
{
[XmlRoot("LayerInfo")]
public class LayerCfg
{
[System.Xml.Serialization.XmlIgnore]
public int ID { get; private set; }
[System.Xml.Serialization.XmlIgnore]
public int PID { get; private set; }
[System.Xml.Serialization.XmlIgnore]
public Bitmap SymbolImg { get; set; }
[System.Xml.Serialization.XmlIgnore]
public object Data { get; set; }
[System.Xml.Serialization.XmlIgnore]
public bool IsEdit { get; set; }
[System.Xml.Serialization.XmlIgnore]
public int ImgIndex { get; set; }
[System.Xml.Serialization.XmlIgnore]
private bool _IsLoad;
public bool IsLoad
{
get
{
//_IsLoad = !string.IsNullOrWhiteSpace(FcPath);
return _IsLoad;
}
set
{
if (value && !string.IsNullOrWhiteSpace(FcPath))
{
_IsLoad = value;
}
else
{
_IsLoad = false;
}
}
}
/// <summary>
/// 图层名
/// </summary>
[XmlAttribute("LayerName")]
public string LayerName { get; set; }
/// <summary>
/// 表名
/// </summary>
[XmlAttribute("FcName")]
public string FcName { get; set; }
/// <summary>
/// 节点展开状态
/// </summary>
[XmlAttribute("Expanded")]
public bool Expanded { get; set; }
/// <summary>
/// 是否显示
/// </summary>
[XmlAttribute("Visible")]
public bool Visible { get; set; }
/// <summary>
/// 是否可选
/// </summary>
[XmlAttribute("Selectable")]
public bool Selectable { get; set; }
/// <summary>
/// 是否允许编辑
/// </summary>
[XmlAttribute("AllowEdit")]
public bool AllowEdit { get; set; }
/// <summary>
/// 图层透明度
/// </summary>
[XmlAttribute("Transparency")]
public int Transparency { get; set; }
/// <summary>
/// 是否必选图层
/// </summary>
[XmlAttribute("Required")]
public bool Required { get; set; }
/// <summary>
/// 图层路径
/// </summary>
public string FcPath { get; set; }
/// <summary>
/// 图层符号
/// </summary>
public string Symbol { get; set; }
/// <summary>
/// 图层标注
/// </summary>
public string Annotation { get; set; }
/// <summary>
/// 属性编辑时字段配置方案
/// </summary>
public string FieldEditCfg { get; set; }
/// <summary>
/// 绝对路径Data
/// </summary>
public string AbsolutePath { get; set; }
/// <summary>
/// 区分内外部数据
/// </summary>
public string AbsolutePathType { get; set; }
/// <summary>
/// 基础数据加载状态
/// </summary>
public TBState LoadLayerState { get; set; }
/// <summary>
/// 图层字段配置
/// </summary>
public List<FieldCfg> FieldsCfg
{
get
{
List<FieldCfg> result = new List<FieldCfg>();
if (_FieldsCfg != null)
{
for (int i = 0; i < _FieldsCfg.Count; i++)
{
_FieldsCfg[i].PID = this.ID;//layerCfg.ID
_FieldsCfg[i].ID = ID * 100 + i + 1;
//var subList = GetAllFields(_FieldsCfg[i]);
//if (subList != null && subList.Count > 0)
// result.AddRange(subList);
}
}
if (result.Count == 0)
return _FieldsCfg;
else
return result;
}
set
{
_FieldsCfg = value;
}
}
private List<FieldCfg> _FieldsCfg { get; set; }
/// <summary>
/// 图层类型
/// </summary>
[XmlAttribute("LayerType")]
public EnumLayerType LayerType { get; set; }
public List<LayerCfg> Layers { get; set; }
public int MinScale { get; set; }
public int MaxScale { get; set; }
public string DefinitionExpression { get; set; }
public LayerCfg()
{
PID = 0;
ID = 1;
Layers = new List<LayerCfg>();
}
public LayerCfg(LayerCfg pParentLayer)
{
Layers = new List<LayerCfg>();
if (pParentLayer == null) return;
PID = pParentLayer.ID;
ID = pParentLayer.ID * 1000 + pParentLayer.Layers.Count + 1;
}
public string FileSize { get; set; }
public bool IsChecked { get; set; }
/// <summary>
/// 将父子级数据结构转换为普通list
/// </summary>
/// <param name="list"></param>
/// <returns></returns>
public List<LayerCfg> GetAllItem()
{
List<LayerCfg> Resultlist = new List<LayerCfg>();
//foreach (var item in list)
//{
OperationChildData(Resultlist, this);
Resultlist.Add(this);
//}
return Resultlist;
}
//public List<FieldCfg> GetAllFields(FieldCfg pField)
public List<FieldCfg> GetAllFields()
{
List<FieldCfg> Resultlist = new List<FieldCfg>();
foreach (FieldCfg pField in this.FieldsCfg)
{
OperationChildDataForField(Resultlist, pField);
Resultlist.Add(pField);
}
return Resultlist;
}
/// <summary>
/// 递归子级数据
/// </summary>
/// <param name="treeDataList">树形列表数据</param>
/// <param name="parentItem">父级model</param>
private void OperationChildDataForField(List<FieldCfg> AllList, FieldCfg item)
{
if (item.Fields != null)
{
if (item.Fields.Count > 0)
{
foreach (var subItem in item.Fields)
{
//subItem.SetParentLayer(item);
AllList.Add(subItem);
OperationChildDataForField(AllList, subItem);
}
}
}
}
#region Private
/// <summary>
/// 递归子级数据
/// </summary>
/// <param name="treeDataList">树形列表数据</param>
/// <param name="parentItem">父级model</param>
private void OperationChildData(List<LayerCfg> AllList, LayerCfg item)
{
if (item.Layers != null)
{
if (item.Layers.Count > 0)
{
foreach (var subItem in item.Layers)
{
subItem.SetParentLayer(item);
AllList.Add(subItem);
OperationChildData(AllList, subItem);
}
}
}
}
private void SetParentLayer(LayerCfg pParent)
{
PID = pParent.ID;
ID = pParent.ID * 100 + pParent.Layers.IndexOf(this) + 1;
}
#endregion
}
public enum TBState
{
/// <summary>
/// 等待中
/// </summary>
Waiting = 0,
/// <summary>
/// 删除
/// </summary>
Delete = 1,
/// <summary>
/// 开始导入
/// </summary>
BeingImport = 2,
/// <summary>
/// 结束导入
/// </summary>
EndImport = 3
}
//public enum EnumLayerType
//{
// GroupLayer,
// FeatureLayer,
// RasterLayer,
// KOTilesLayer,
// Map
//}
}