namespace HydroUI { [Serializable] public class Template { private string _ID; [Description("对象的ID唯一标识")] [DisplayName("模板ID")] [Browsable(true)] public string ID { get { if (_ID == null || _ID == "") _ID = Guid.NewGuid().ToString(); return _ID; } set { _ID = value; } } [DisplayName("名称")] public string Name { get; set; } public MapOption mapOption { get; set; } = new MapOption(); private string _filePath = null; [Category("计算参数")] [DisplayName("路径INP")] public string filePath { get { return _filePath; } set { var filePath = value; var CurDir = Directory.GetCurrentDirectory(); if (filePath != null && filePath.IndexOf(CurDir) >= 0) { filePath = filePath.Replace(CurDir, ""); if (filePath[0] == '\\') filePath = filePath.Substring(1); } _filePath = filePath; } } public PointF3D OffSet { get; set; } = new PointF3D(0, 0, 0); private string _BackGroundImg_FullPath; public string BackGroundImg_FullPath { get { if (string.IsNullOrEmpty(_BackGroundImg_FullPath)) { FileInfo fi = new FileInfo(FullPath); return fi.FullName.Substring(0, fi.FullName.Length - fi.Extension.Length) + ".png"; } else return _BackGroundImg_FullPath; } set { _BackGroundImg_FullPath = value; } } public float BackGroundElev = 0; /// 底图X public float BackGroundImgX = 0; /// 底图Y public float BackGroundImgY = 0; /// 底图高度 public float BackGroundImgHeight = 0; /// 底图宽度 public float BackGroundImgWidth = 0; /// 底图旋转角度 public float BackGroundImgRotaAngle = 0; public PointF BackGroundPoint1 = new PointF(); public PointF BackGroundPoint2 = new PointF(); public string FullPath { get { if (filePath != null) filePath = filePath.TrimStart('\\'); return Path.Combine(Directory.GetCurrentDirectory(), (filePath == null ? "" : filePath)); } } public string ImportExcelPath { get; set; } public int ImportExcelIndex { get; set; } [Category("计算参数")] [DisplayName("最高级数")] public int MaxLevel { get; set; } = 99; [Browsable(true)] public PBS.eModelTemplateType Type { get; set; } public Template() { ID = new Guid().ToString(); Name = "临时"; filePath = null; } public Template(string ID, string name, string address, PBS.eModelTemplateType type) { if (ID == null) this.ID = new Guid().ToString(); Name = name; filePath = address; Type = type; } [Description("对象的ID唯一标识")] [NonSerialized] public MapViewNetWork network = null; [DisplayName("标高")] public float Elev { get { return 0; } } public float Diameter { get { return 0; } } public float Level { get { return 0; } } [DisplayName("开始节点")] public string Node1 { get; set; } [DisplayName("结束节点")] public string Node2 { get; set; } public string X { get; set; } public string Y { get; set; } public string Visible { get; set; } [Category("默认视角")] [DisplayName("视角")] public MapDimensions view { get; set; } = new MapDimensions(); [Category("默认视角")] [DisplayName("中心X")] [Browsable(true)] public float CenterX { get { if (view != null) return view.Center.X; else return 0; } set { if (view == null) view = new MapDimensions(); view.Center = new PointF(value, view.Center.Y); } } [Category("默认视角")] [DisplayName("中心Y")] [Browsable(true)] public float CenterY { get { if (view != null) return view.Center.Y; else return 0; } set { if (view == null) view = new MapDimensions(); view.Center = new PointF(view.Center.X, value); } } [Category("默认视角")] [DisplayName("缩放")] [Browsable(true)] public float zoom { get { if (view != null) return view.zoom; else return 1f; } set { if (view == null) view = new MapDimensions(); view.zoom = value; } } [Category("默认视角")] [DisplayName("旋转角度")] [Browsable(true)] public double rotation { get { if (view != null) return view.rotation; else return 0; } set { if (view == null) view = new MapDimensions(); view.rotation = value; } } [Category("默认视角")] [DisplayName("俯视角度")] [Browsable(true)] public double rotationF { get { if (view != null) return view.rotationF; else return 90; } set { if (view == null) view = new MapDimensions(); view.rotationF = value; } } public bool loadInpFile() { network = new MapViewNetWork(); var result = network.BuildFromInp(FullPath); if (result) { network.MapObjects.ForEach(o => { if (o.Level > MaxLevel) o.Visible = false; else o.Visible = true; }); return true; } else return false; } [DisplayName("颜色分级方案")] public List Colours { get; set; } = new List(); public void Export(string path) { network.BuildToInp(path); } } }