| | |
| | | |
| | | namespace Hydro.MapView |
| | | { |
| | | [Serializable] |
| | | public class LinkViewModel : LinkCalcModel, IBaseViewModel |
| | | { |
| | | public LinkViewModel() |
| | |
| | | { |
| | | 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 new string Node1 |
| | | public string Node1 |
| | | { |
| | | get |
| | | { |
| | | if (StartNode != null && base.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 |
| | | public string Node2 |
| | | { |
| | | get |
| | | { |
| | | if (EndNode != null && base.Node2 != EndNode.ID) |
| | | { |
| | | base.Node2 = EndNode.ID; |
| | | } |
| | | return base.Node2; |
| | | } |
| | | set |
| | |
| | | [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; |
| | |
| | | } |
| | | 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) |
| | |
| | | } |
| | | set |
| | | { |
| | | Position = new PointF(value, Position.Y); |
| | | //Position = new PointF(value, Position.Y); |
| | | } |
| | | } |
| | | [Category("1、基本信息")] |
| | |
| | | } |
| | | set |
| | | { |
| | | Position = new PointF(Position.X, value); |
| | | //Position = new PointF(Position.X, value); |
| | | } |
| | | } |
| | | |