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;
|
|
namespace Hydro.MapView
|
{
|
public class LinkViewModel : LinkModel, IBaseViewModel
|
{
|
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;
|
}
|
|
|
|
//private string Node1;
|
|
[Category("1、基本信息")]
|
[DisplayName("节点1")]
|
[Browsable(true)]
|
public new string Node1
|
{
|
get
|
{
|
if (StartNode != null && Node1 != StartNode.ID)
|
{
|
base.Node1 = StartNode.ID;
|
}
|
return base.Node1;
|
}
|
set
|
{
|
|
base.Node1 = value;
|
}
|
}
|
//private string Node2;
|
|
|
[Category("1、基本信息")]
|
[DisplayName("节点2")]
|
[Browsable(true)]
|
public new string Node2
|
{
|
get
|
{
|
if (EndNode != null && Node2 != EndNode.ID)
|
{
|
base.Node2 = EndNode.ID;
|
}
|
return base.Node2;
|
}
|
set
|
{
|
base.Node2 = value;
|
}
|
}
|
|
[Browsable(false)]
|
[JsonIgnore]
|
|
public NodeViewModel StartNode { get; set; }
|
[Browsable(false)]
|
[JsonIgnore]
|
|
public NodeViewModel EndNode { get; set; }
|
|
private PointF _position { get; set; } = new PointF(0, 0);
|
public PointF Position
|
{
|
get
|
{
|
//if (StartPoint.Position==new PointF(0,0) || EndPoint.Position == new PointF(0, 0))
|
//{
|
// return new PointF(0,0);
|
//}
|
//if (_position == new PointF(0, 0))
|
{
|
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
|
{
|
_position = value;
|
}
|
}
|
|
|
[Browsable(false)]
|
|
public List<PointF> Points { get; set; }
|
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("标高")]
|
[Browsable(true)]
|
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 new StatusType Status { 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("口径")]
|
[Browsable(true)]
|
public new float Diameter { get { return base.Diameter; } set { base.Diameter = value; } }
|
|
|
//实际需水量
|
[Category("3、计算结果")]
|
[DisplayName("1)流量")]
|
[Browsable(true)]
|
public float EN_FLOW { get; set; } = float.NaN;
|
|
//实际需水量
|
[Category("3、计算结果")]
|
[DisplayName("2)流速")]
|
[Browsable(true)]
|
public float EN_VELOCITY { get; set; } = float.NaN;
|
//实际需水量
|
[Category("3、计算结果")]
|
[DisplayName("水头损失")]
|
[Browsable(true)]
|
public float EN_HEADLOSS { get; set; } = float.NaN;
|
//实际需水量
|
[Category("3、计算结果")]
|
[DisplayName("当前状态")]
|
[Browsable(false)]
|
public float EN_STATUS { get; set; } = float.NaN;
|
//EN_DEMAND 9 实际需水量 EN_HEAD 10 水力水头 EN_PRESSURE 11 压强
|
|
[Category("4、其他参数")]
|
[Description("选中")]
|
[DisplayName("选中")]
|
[Browsable(false)]
|
public bool Selected { get; set; }
|
|
|
|
[Browsable(false)]
|
[JsonIgnore]
|
public String regionName { get; set; } = null;
|
|
[Category("1、基本信息")]
|
[Description("X坐标")]
|
[DisplayName("X坐标")]
|
[Browsable(true)]
|
public float X
|
{
|
get
|
{
|
return Position.X;
|
}
|
set
|
{
|
Position = new PointF(value, Position.Y);
|
}
|
}
|
[Category("1、基本信息")]
|
[Description("Y坐标")]
|
[DisplayName("Y坐标")]
|
[Browsable(true)]
|
public float Y
|
{
|
get
|
{
|
return Position.Y;
|
}
|
set
|
{
|
Position = new PointF(Position.X, value);
|
}
|
}
|
|
|
[Category("4、其他参数")]
|
[Description("对象的等级")]
|
[DisplayName("级别")]
|
|
|
public int Level { get; set; } = 0;
|
[Category("4、其他参数")]
|
[Description("对象的等级")]
|
[DisplayName("是否显示")]
|
public bool Visible { get; set; } = true;
|
|
|
[Category("1、基本信息")]
|
[Description("类型")]
|
[DisplayName("类型")]
|
public MapObjectType Type { get { return this.GetTypeString(); } }
|
|
|
[Category("4、其他参数")]
|
[Description("ID类型")]
|
[DisplayName("ID类型")]
|
[Browsable(false)]
|
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;
|
}
|
}
|
}
|