public static string GenerateCurvedPath(this BaseLinkModel link) { var sX = link.GetMiddleSourceX(); var sY = link.GetMiddleSourceY(); double tX, tY; if (link.IsAttached) { tX = link.GetMiddleTargetX(); tY = link.GetMiddleTargetY(); } else { tX = link.OnGoingPosition !.X; tY = link.OnGoingPosition.Y; } var cX = (sX + tX) / 2; var cY = (sY + tY) / 2; var curvePointA = GetCurvePoint(sX, sY, cX, cY, link.SourcePort.Alignment); var curvePointB = GetCurvePoint(tX, tY, cX, cY, link.TargetPort?.Alignment); return(FormattableString.Invariant($"M {sX} {sY} C {curvePointA}, {curvePointB}, {tX} {tY}")); }
/// <summary> /// If the link is attached, returns the same output as GetMiddleTargetY(). /// Otherwise, returns the Y value of link's ongoing position. /// </summary> /// <param name="link">The BaseLinkModel entity</param> public static double GetTargetY(this BaseLinkModel link) { if (!link.IsAttached) { return(link.OnGoingPosition !.Y); } return(link.GetMiddleTargetY()); }