using Hydro.CommonBase;
|
using Hydro.Inp;
|
using Newtonsoft.Json;
|
using System;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Drawing;
|
using System.IO;
|
using System.Linq;
|
using System.Runtime.Remoting.Metadata;
|
using System.Text;
|
using System.Threading.Tasks;
|
using static Hydro.MapView.MapViewEnum;
|
|
namespace Hydro.MapView
|
{
|
[Serializable]
|
public class Template
|
{
|
private string _ID;
|
[Category("1、基本信息")]
|
[Description("对象的ID唯一标识")]
|
[DisplayName("模板ID")]
|
[Browsable(true)]
|
public string ID { get { if (_ID == null || _ID == "") _ID = Guid.NewGuid().ToString(); return _ID; } set { _ID = value; } }
|
[Category("1、基本信息")]
|
[DisplayName("名称")]
|
public string 名称 { get; set; }
|
|
public MapOption mapOption { get; set; } = new MapOption();
|
|
private string _filePath = null;
|
|
[Category("2、计算参数")]
|
[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;
|
}
|
}
|
|
[Browsable(false)]
|
public PointF3D OffSet { get; set; } = new PointF3D(0, 0, 0);
|
//private string _BackGroundImg = null;
|
//[DisplayName("背景图片")]
|
//public string BackGroundImg
|
//{
|
// get
|
// {
|
// return _BackGroundImg;
|
// }
|
|
//}
|
|
[Browsable(false)]
|
public string BackGroundImg_FullPath
|
{
|
get
|
{
|
FileInfo fi = new FileInfo(FullPath);
|
return fi.FullName.Substring(0, fi.FullName.Length - fi.Extension.Length) + ".png";
|
}
|
}
|
|
public float BackGroundElev = 0;
|
|
public PointF BackGroundPoint1 = new PointF();
|
|
public PointF BackGroundPoint2 = new PointF();
|
[Browsable(false)]
|
public string FullPath
|
{
|
get
|
{
|
return Path.Combine(Directory.GetCurrentDirectory(), filePath == null ? "" : filePath);
|
}
|
}
|
|
[Browsable(false)]
|
public string ImportExcelPath { get; set; }
|
|
[Browsable(false)]
|
public int ImportExcelIndex { get; set; }
|
|
|
|
[Category("2、计算参数")]
|
[DisplayName("最高级数")]
|
public int MaxLevel { get; set; } = 99;
|
[Category("1、基本信息")]
|
[Description("类型")]
|
[DisplayName("类型")]
|
[Browsable(true)]
|
public TemplateType Type { get; set; }
|
|
//[Category("4、其他参数")]
|
//[Description("对象的ID唯一标识")]
|
//[Browsable(false)]
|
//[JsonIgnore]
|
//public List<Relation> 派生关系 { get; set; } = new List<Relation>();
|
public Template()
|
{
|
|
ID = new Guid().ToString();
|
名称 = "临时";
|
filePath = null;
|
|
}
|
public Template(string ID, string name, string address, TemplateType type)
|
{
|
if (ID == null)
|
this.ID = new Guid().ToString();
|
名称 = name;
|
filePath = address;
|
Type = type;
|
}
|
|
|
[Category("4、其他参数")]
|
[Description("对象的ID唯一标识")]
|
[Browsable(false)]
|
[NonSerialized]
|
public MapViewNetWork network = null;
|
|
|
|
[Category("5、楼层")]
|
[DisplayName("楼层")]
|
public List<TRegion> Regions { get; set; } = new List<TRegion>();
|
|
[Category("1、基本信息")]
|
[DisplayName("标高")]
|
[Browsable(false)]
|
public float Elev { get { return 0; } }
|
|
|
[Browsable(false)]
|
public float Diameter { get { return 0; } }
|
|
[Browsable(false)]
|
public float Level { get { return 0; } }
|
|
|
|
[Category("4、其他参数")]
|
[DisplayName("开始节点")]
|
public string Node1 { get; set; }
|
|
|
[Category("4、其他参数")]
|
[DisplayName("结束节点")]
|
public string Node2 { get; set; }
|
|
[Browsable(false)]
|
public string X { get; set; }
|
[Browsable(false)]
|
public string Y { get; set; }
|
|
[Browsable(false)]
|
public string Visible { get; set; }
|
|
[Category("4、默认视角")]
|
[DisplayName("视角")]
|
[Browsable(false)]
|
public MapDimensions view { get; set; } = null;
|
|
|
[Category("4、默认视角")]
|
[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("4、默认视角")]
|
[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("4、默认视角")]
|
[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("4、默认视角")]
|
[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("4、默认视角")]
|
[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 override string ToString()
|
{
|
return 名称;
|
}
|
public void Export(string path)
|
{
|
network.BuildToInp(path);
|
//SaveFileDialog saveFileDialog = new SaveFileDialog();
|
//saveFileDialog.Filter = "Temporary Files (*.temp)|*.temp";
|
//saveFileDialog.InitialDirectory = Directory.GetCurrentDirectory() + $@"\template\{类型}";
|
//saveFileDialog.FileName = 名称;
|
//if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
//{
|
// string filePath = saveFileDialog.FileName;
|
// // 使用 filePath 变量来保存文件
|
// //temp.路径 = filePath;
|
//}
|
}
|
|
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;
|
}
|
|
|
//public Trigger triggers;
|
}
|
}
|