Esempio n. 1
0
        /// <summary>
        /// Modifies the first and last point of a route to attach to the supplied source and target rect's perimeter.
        /// </summary>
        public Route AttachToSourceRectAndTargetRect(Rect2D sourceRect, Rect2D targetRect)
        {
            if (_routePoints == null || _routePoints.Count < 2)
            {
                throw new InvalidOperationException("AttachToSourceRectAndTargetRect requires a route with at least 2 points.");
            }

            var firstPoint = sourceRect.GetAttachPointToward(_routePoints[1]);
            var lastPoint  = targetRect.GetAttachPointToward(_routePoints[_routePoints.Count - 2]);

            return(new Route(firstPoint.Concat(_routePoints.Skip(1).TakeButLast()).Append(lastPoint)));
        }
Esempio n. 2
0
        /// <summary>
        /// Modifies the first and last point of a route to attach to the suppied source and target rect's perimeter.
        /// </summary>
        /// <param name="sourceRect"></param>
        /// <param name="targetRect"></param>
        public void AttachToSourceRectAndTargetRect(Rect2D sourceRect, Rect2D targetRect)
        {
            var routePointCount = _routePoints.Count;

            if (routePointCount < 2)
            {
                throw new InvalidOperationException("AttachToSourceRectAndTargetRect requires a route with at least 2 points.");
            }

            _routePoints[0] = sourceRect.GetAttachPointToward(_routePoints[1]);
            _routePoints[routePointCount - 1] = targetRect.GetAttachPointToward(_routePoints[routePointCount - 2]);
        }