コード例 #1
0
        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}"));
        }
コード例 #2
0
        /// <summary>
        /// If the link is attached, returns the same output as GetMiddleTargetX().
        /// Otherwise, returns the X value of link's ongoing position.
        /// </summary>
        /// <param name="link">The BaseLinkModel entity</param>
        public static double GetTargetX(this BaseLinkModel link)
        {
            if (!link.IsAttached)
            {
                return(link.OnGoingPosition !.X);
            }

            return(link.GetMiddleTargetX());
        }