Esempio n. 1
0
 public void RemoveNode(DiagramNode diagramNode)
 {
     if (nodes.Contains(diagramNode))
     {
         nodes.Remove(diagramNode);
     }
 }
Esempio n. 2
0
 public void AddNode(DiagramNode diagramNode)
 {
     if (!nodes.Contains(diagramNode))
     {
         nodes.Add(diagramNode);
     }
 }
Esempio n. 3
0
 public DiagramNode GetNeighbourNode(DiagramNode diagramNode)
 {
     if (diagramNode == StartNode)
     {
         return(EndNode);
     }
     if (diagramNode == EndNode)
     {
         return(StartNode);
     }
     return(null);
 }
Esempio n. 4
0
        public bool HandleMouseLeftButtonDown(Point point)
        {
            DiagramNode hoveredNode = GetHoveredNode(point, out dragOffsetVector);

            if (hoveredNode != null)
            {
                currentMouseOperation           = MouseOperation.MouseLeftButtonDownOnNode;
                ActiveNode                      = hoveredNode;
                ActiveNode.IsPositionControlled = true;
                return(OnMouseLeftButtonDownOnNodeOverride(point));
            }
            currentMouseOperation = MouseOperation.MouseLeftButtonDownOnEmptySpace;
            return(OnMouseLeftButtonDownOnEmptySpaceOverride(point));
        }
Esempio n. 5
0
        public virtual double GetDistanceToNode(DiagramNode diagramNode)
        {
            return((Pos - diagramNode.Pos).Length);

            //return Math.Min(
            //    Math.Min(
            //        Math.Min(
            //            diagramNode.GetShortestDistanceToPoint(TopLeft),
            //            diagramNode.GetShortestDistanceToPoint(TopRight)
            //        ),
            //        diagramNode.GetShortestDistanceToPoint(BottomRight)
            //    ),
            //    diagramNode.GetShortestDistanceToPoint(BottomLeft)
            //);
        }
Esempio n. 6
0
 public DiagramLink(DiagramNode startNode, DiagramNode endNode)
 {
     StartNode = startNode;
     EndNode   = endNode;
 }
Esempio n. 7
0
        protected bool GetCurveOffsetForNode(DiagramNode dn, out double o0, out double o1)
        {
            double offset0;
            double offset1;
            double x0;
            double x1;
            double y0;
            double y1;

            o0 = double.NaN;
            o1 = double.NaN;
            bool r = false;

            if (SolveCurveOffsetForY(dn.TopLeft.Y, out offset0, out offset1, out x0, out x1))
            {
                if (IsBetweenZeroAndOne(offset0) && IsBetween(x0, dn.TopLeft.X, dn.TopRight.X))
                {
                    o0 = offset0;
                    r  = true;
                }
                if (IsBetweenZeroAndOne(offset1) && IsBetween(x1, dn.TopLeft.X, dn.TopRight.X))
                {
                    o1 = offset1;
                    r  = true;
                }
                if (r)
                {
                    return(true);
                }
            }
            if (SolveCurveOffsetForY(dn.BottomLeft.Y, out offset0, out offset1, out x0, out x1))
            {
                if (IsBetweenZeroAndOne(offset0) && IsBetween(x0, dn.TopLeft.X, dn.TopRight.X))
                {
                    o0 = offset0;
                    r  = true;
                }
                if (IsBetweenZeroAndOne(offset1) && IsBetween(x1, dn.TopLeft.X, dn.TopRight.X))
                {
                    o1 = offset1;
                    r  = true;
                }
                if (r)
                {
                    return(true);
                }
            }
            if (SolveCurveOffsetForX(dn.TopLeft.X, out offset0, out offset1, out y0, out y1))
            {
                if (IsBetweenZeroAndOne(offset0) && IsBetween(y0, dn.TopLeft.Y, dn.BottomLeft.Y))
                {
                    o0 = offset0;
                    r  = true;
                }
                if (IsBetweenZeroAndOne(offset1) && IsBetween(y1, dn.TopLeft.Y, dn.BottomLeft.Y))
                {
                    o1 = offset1;
                    r  = true;
                }
                if (r)
                {
                    return(true);
                }
            }
            if (SolveCurveOffsetForX(dn.TopRight.X, out offset0, out offset1, out x0, out x1))
            {
                if (IsBetweenZeroAndOne(offset0) && IsBetween(y0, dn.TopLeft.Y, dn.BottomLeft.Y))
                {
                    o0 = offset0;
                    r  = true;
                }
                if (IsBetweenZeroAndOne(offset1) && IsBetween(y1, dn.TopLeft.Y, dn.BottomLeft.Y))
                {
                    o1 = offset1;
                    r  = true;
                }
                if (r)
                {
                    return(true);
                }
            }
            return(false);
        }
 private double GetDefaultDamping(DiagramNode diagramNode)
 {
     return(0.85);
 }