using Hydro.Core.Model; using Hydro.Model; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Linq; using System.Numerics; using System.Text; using System.Threading; using System.Threading.Tasks; using static Hydro.MapView.MapViewEnum; namespace Hydro.MapView { public class NodeViewModel : NodeCalcModel, IBaseViewModel { public NodeViewModel() { } public NodeViewModel(PointF position) { Position = position; } public NodeViewModel(int X, int Y) { Position = new PointF(X, Y); } private PointF3D ToPointF3D() { return new PointF3D(X, Y, Elev); } [Browsable(false)] public PointF3D Position3D { get { return new PointF3D(X, Y, Elev); } set { Position = new PointF(value.X, value.Y); Elev = value.Z; } } [Category("2、计算参数")] [Description("需水量")] [DisplayName("需水量")] [Browsable(true)] public virtual float Demand { get; set; } /// /// 模式的编号 /// [Category("2、计算参数")] [Description("用水量模式的编号")] [DisplayName("模式编号")] [Browsable(true)] public virtual string PatternID { get; set; } [Category("1、基本信息")] [Description("口径")] [DisplayName("口径")] [Browsable(false)] public virtual float MaxDiameter { get; set; } = 0; [Category("4、其他参数")] [DisplayName("链表清单")] [Browsable(true)] [JsonIgnore] public List Links { get; set; } = new List(); //public string ToEmitterString() //{ // if (this is NozzleModel n) // { // if (n.Flow_coefficient > 0) // return $"{ID}\t{n.Flow_coefficient * Math.Pow(10 / 101.972, 0.5) / 1000 * 60}\r\n"; // } // return null; //} public void Move(Vector3 vector) { X += vector.X; Y += vector.Y; Elev += vector.Z; } //实际需水量 [Category("3、计算结果")] [DisplayName("1)实际需水量")] [Browsable(true)] public float EN_DEMAND { get; set; } = float.NaN; //实际需水量 [Category("3、计算结果")] [DisplayName("2)绝对水压")] [Browsable(true)] public float EN_HEAD { get; set; } = float.NaN; //实际需水量 [Category("3、计算结果")] [DisplayName("3)自由水压")] [Browsable(true)] public float EN_PRESSURE { get; set; } = float.NaN; //实际需水量 [Category("3、计算结果")] [DisplayName("4)水龄")] [Browsable(false)] public float EN_QUALITY { get; set; } = float.NaN; //EN_DEMAND 9 实际需水量 EN_HEAD 10 水力水头 EN_PRESSURE 11 压强 [Category("4、其他参数")] [Description("选中")] [DisplayName("选中")] [Browsable(false)] public bool Selected { get; set; } [Category("4、其他参数")] [Description("选中")] [DisplayName("位置信息")] [Browsable(false)] public PointF Position { get { return new PointF(X, Y); } set { if (value != null) X = value.X; Y = value.Y; } } [Browsable(false)] [JsonIgnore] public String regionName { get; set; } = null; [Category("1、基本信息")] [Description("X坐标")] [DisplayName("X坐标")] [Browsable(true)] public new float X { get { return base.X; } set { base.X = value; } } [Category("1、基本信息")] [Description("Y坐标")] [DisplayName("Y坐标")] [Browsable(true)] public new float Y { get { return base.Y; } set { base.Y = value; } } [Category("1、基本信息")] [Description("标高")] [DisplayName("标高")] [Browsable(true)] public new float Elev { get { return base.Elev; } set { base.Elev = 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; } public string ToEmitterString() { if (this is NozzleViewModel n) { if (n.FlowCoefficient > 0) return $"{ID}\t{n.FlowCoefficient * Math.Pow(10 / 101.972, 0.5) / 1000 * 60}\r\n"; } return null; } } }