cloudflight
2023-12-26 5fa6947054206e2e781eadd4effdcdf52eda28c4
Hydro.MapView/Base/LinkViewModel.cs
@@ -14,7 +14,8 @@
namespace Hydro.MapView
{
    public class LinkViewModel : LinkModel, IBaseViewModel
    [Serializable]
    public class LinkViewModel : LinkCalcModel, IBaseViewModel
    {
        public LinkViewModel()
        {
@@ -24,79 +25,63 @@
        {
            StartNode = new NodeViewModel(startPoint);
            EndNode = new NodeViewModel(endPoint);
            Points = new List<PointF>() { startPoint, 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;
            //Points = points;
        }
        //private string Node1;
        [Category("1、基本信息")]
        [DisplayName("节点1")]
        [Browsable(true)]
        public override string Node1
        public string Node1
        {
            get
            {
                if (StartNode != null && Node1 != StartNode.ID)
                {
                    Node1 = StartNode.ID;
                }
                return Node1;
                return base.Node1;
            }
            set
            {
                Node1 = value;
                base.Node1 = value;
            }
        }
        //private string Node2;
        [Category("1、基本信息")]
        [DisplayName("节点2")]
        [Browsable(true)]
        public override string Node2
        public string Node2
        {
            get
            {
                if (EndNode != null && Node2 != EndNode.ID)
                {
                    Node2 = EndNode.ID;
                }
                return Node2;
                return base.Node2;
            }
            set
            {
                Node2 = value;
                base.Node2 = value;
            }
        }
        [Browsable(false)]
        [JsonIgnore]
        public NodeViewModel StartNode { get; set; }
        public NodeViewModel StartNode { get { return (NodeViewModel)base.StartNode; } set { base.StartNode = value; } }
        [Browsable(false)]
        [JsonIgnore]
        public NodeViewModel EndNode { get; set; }
        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 (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;
@@ -107,16 +92,16 @@
                }
                return _position;
            }
            set
            {
                _position = value;
            set
            {
            }
        }
        [Browsable(false)]
        public List<PointF> Points { get; set; }
        public List<PointF> Points { get { return new List<PointF>() { StartNode.Position, EndNode.Position }; } }
        public PointF[] ToArray(bool is3Dview = false)
        {
            if (!is3Dview)
@@ -145,7 +130,12 @@
        [Category("2、计算参数")]
        [DisplayName("1)初始状态")]
        [Browsable(true)]
        public override  StatusType Status { get; set; } = StatusType.DEFAULT;
        public StatusType Status
        {
            get { return base.Status; }
            set { base.Status = value; }
        }
        //{ get; set; } = StatusType.DEFAULT;
        //public string ToStatusString()
@@ -163,7 +153,7 @@
        [Category("1、基本信息")]
        [DisplayName("口径")]
        [Browsable(true)]
        public override float Diameter { get { return base.Diameter; } set { base.Diameter = value; } }
        public new float Diameter { get { return base.Diameter; } set { base.Diameter = value; } }
        //实际需水量
@@ -213,7 +203,7 @@
            }
            set
            {
                Position = new PointF(value, Position.Y);
                //Position = new PointF(value, Position.Y);
            }
        }
        [Category("1、基本信息")]
@@ -228,7 +218,7 @@
            }
            set
            {
                Position = new PointF(Position.X, value);
                //Position = new PointF(Position.X, value);
            }
        }