using Hydro.Core.Model;
|
using System;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Drawing;
|
using System.Linq;
|
using System.Text;
|
using System.Threading;
|
using System.Threading.Tasks;
|
using static Hydro.MapView.MapViewEnum;
|
using System.Xml.Linq;
|
using Newtonsoft.Json;
|
using static Hydro.Core.ObjectEnum;
|
using System.Drawing.Design;
|
|
namespace Hydro.MapView
|
{
|
[Serializable]
|
public class LinkViewModel : LinkCalcModel, IBaseViewModel
|
{
|
#region 构造函数
|
|
|
public LinkViewModel()
|
{
|
|
}
|
public LinkViewModel(PointF startPoint, PointF endPoint)
|
{
|
StartNode = new NodeViewModel(startPoint);
|
EndNode = new NodeViewModel(endPoint);
|
//Points = new List<PointF>() { startPoint, endPoint };
|
}
|
public LinkViewModel(PointF startPoint, PointF endPoint, List<PointF> points)
|
{
|
StartNode = new NodeViewModel(startPoint);
|
EndNode = new NodeViewModel(endPoint);
|
//Points = points;
|
}
|
#endregion
|
#region 属性
|
|
|
[Category("1、基本信息")]
|
[DisplayName("1)编号")]
|
[Browsable(true)]
|
public new string ID { get { return base.ID; } set { base.ID = value; } }
|
|
[Category("1、基本信息")]
|
[DisplayName("2)名称")]
|
[Browsable(true)]
|
public new string Name { get { return base.Name; } set { base.Name = value; } }
|
|
[Category("1、基本信息")]
|
[DisplayName("9)起始节点")]
|
[Browsable(true)]
|
public string Node1
|
{
|
get
|
{
|
return base.Node1;
|
}
|
set
|
{
|
|
base.Node1 = value;
|
}
|
}
|
|
|
[Category("1、基本信息")]
|
[DisplayName("10)终止节点")]
|
[Browsable(true)]
|
public string Node2
|
{
|
get
|
{
|
return base.Node2;
|
}
|
set
|
{
|
base.Node2 = value;
|
}
|
}
|
|
[Browsable(false)]
|
[JsonIgnore]
|
|
public NodeViewModel StartNode { get { return (NodeViewModel)base.StartNode; } set { base.StartNode = value; } }
|
[Browsable(false)]
|
[JsonIgnore]
|
|
public NodeViewModel EndNode { get { return (NodeViewModel)base.EndNode; } set { base.EndNode = value; } }
|
|
private PointF _position { get; set; } = new PointF(0, 0);
|
public PointF Position
|
{
|
get
|
{
|
{
|
if (StartNode == null || EndNode == null) return _position;
|
var x = (StartNode.Position.X + EndNode.Position.X) / 2;
|
var y = (StartNode.Position.Y + EndNode.Position.Y) / 2;
|
_position = new PointF(x, y);
|
|
|
}
|
return _position;
|
}
|
set
|
{
|
}
|
|
}
|
|
|
[Browsable(false)]
|
[JsonIgnore]
|
public List<PointF> Points { get { return new List<PointF>() { StartNode.Position, EndNode.Position }; } }
|
public PointF[] ToArray(bool is3Dview = false)
|
{
|
if (!is3Dview)
|
return new PointF[] { new PointF((float)(StartNode.X), (float)(StartNode.Y)), new PointF((float)(EndNode.X), (float)(EndNode.Y)) };
|
else
|
return new PointF[] { new PointF((float)(StartNode.X), (float)(StartNode.Y - 2 * StartNode.Elev)), new PointF((float)(EndNode.X), (float)(EndNode.Y - 2 * EndNode.Elev)) };
|
}
|
|
|
[Category("1、基本信息")]
|
[DisplayName("标高(m)")]
|
[Browsable(false)]
|
public float Elev
|
{
|
get
|
{
|
if (StartNode == null || EndNode == null) return 0;
|
return (StartNode.Elev + EndNode.Elev) / 2;
|
}
|
set
|
{
|
|
}
|
}
|
|
[Category("2、计算参数")]
|
[DisplayName("1)初始状态")]
|
[Browsable(true)]
|
public StatusType Status
|
{
|
get { return base.Status; }
|
set { base.Status = value; }
|
}
|
//{ get; set; } = StatusType.DEFAULT;
|
|
|
//public string ToStatusString()
|
//{
|
// //string s = Status.ToUpper();
|
|
// //if (s == "CLOSED" || s=="CLOSE")
|
// if (Status == StatusType.CLOSED)
|
// {
|
// return $"{ID}\tCLOSED\r\n";
|
// }
|
// return "";
|
//}
|
|
[Category("1、基本信息")]
|
[DisplayName("4)口径(mm)")]
|
[Browsable(true)]
|
public new float Diameter { get { return base.Diameter; } set { base.Diameter = value; } }
|
|
[Category("1、基本信息")]
|
[DisplayName("5)长度(m)")]
|
[Browsable(true)]
|
/// <summary>
|
/// 长度
|
/// </summary>
|
public float Length
|
{
|
get
|
{
|
return base.Length;
|
|
}
|
set
|
{
|
base.Length = value;
|
}
|
}
|
|
//EN_DEMAND 9 实际需水量 EN_HEAD 10 水力水头 EN_PRESSURE 11 压强
|
|
|
|
|
|
[Browsable(false)]
|
[JsonIgnore]
|
public String regionName { get; set; } = null;
|
|
[Category("1、基本信息")]
|
[Description("X坐标")]
|
[DisplayName("7)X坐标")]
|
[Browsable(true)]
|
public float X
|
{
|
get
|
{
|
return Position.X;
|
}
|
set
|
{
|
//Position = new PointF(value, Position.Y);
|
}
|
}
|
[Category("1、基本信息")]
|
[Description("Y坐标")]
|
[DisplayName("8)Y坐标")]
|
[Browsable(true)]
|
public float Y
|
{
|
get
|
{
|
return Position.Y;
|
}
|
set
|
{
|
//Position = new PointF(Position.X, value);
|
}
|
}
|
|
|
[Category("其他参数")]
|
[Description("对象的等级")]
|
[DisplayName("级别")]
|
|
|
public int Level { get; set; } = 0;
|
[Category("其他参数")]
|
[Description("对象的等级")]
|
[DisplayName("是否显示")]
|
public bool Visible { get; set; } = true;
|
|
[Category("其他参数")]
|
[Description("标签")]
|
[DisplayName("标签")]
|
[Editor(typeof(MyEditor), typeof(UITypeEditor))]
|
public TagList Tags { get; set; } = null;
|
|
|
|
|
[Category("基本信息")]
|
[Description("类型")]
|
[DisplayName("3)类型")]
|
public MapObjectType Type { get { return this.GetTypeString(); } }
|
|
|
[Category("其他参数")]
|
[Description("ID类型")]
|
[DisplayName("ID类型")]
|
[Browsable(false)]
|
#endregion
|
#region 方法
|
|
|
public string IDType => Type.ToString() + "\t" + ID;
|
|
public MapObjectType GetTypeString()
|
{
|
if (this is JunctionViewModel) return MapObjectType.节点;
|
if (this is ReservoirViewModel) return MapObjectType.水库;
|
if (this is TankViewModel) return MapObjectType.水池;
|
if (this is MeterViewModel) return MapObjectType.水表;
|
if (this is NozzleViewModel) return MapObjectType.喷头;
|
if (this is ValveNodeViewModel) return MapObjectType.阀门点;
|
|
|
if (this is PipeViewModel) return MapObjectType.管线;
|
if (this is ValveViewModel) return MapObjectType.阀门;
|
if (this is RepeaterViewModel) return MapObjectType.重复器;
|
if (this is PumpViewModel) return MapObjectType.水泵;
|
if (this is PumpNodeViewModel) return MapObjectType.水泵点;
|
|
return MapObjectType.节点;
|
}
|
|
public bool isNode()
|
{
|
if (this is JunctionViewModel) return true;
|
if (this is ReservoirViewModel) return true;
|
if (this is TankViewModel) return true;
|
if (this is MeterViewModel) return true;
|
if (this is NozzleViewModel) return true;
|
return false;
|
}
|
#endregion
|
}
|
}
|