Ejemplo n.º 1
0
        internal float GetEndSegmentLength(GoBoxPortLinkInfo info)
        {
            float endSegmentLength = EndSegmentLength;
            int   num = info.IndexOnSide;

            if (num < 0)
            {
                return(endSegmentLength);
            }
            int countOnSide = info.CountOnSide;

            if (countOnSide <= 1)
            {
                return(endSegmentLength);
            }
            IGoLink link = info.Link;

            if (!GoLink.IsOrtho(link))
            {
                return(endSegmentLength);
            }
            IGoPort otherPort = link.GetOtherPort(this);

            if (otherPort == null)
            {
                return(endSegmentLength);
            }
            GoObject goObject = otherPort.GoObject;

            if (goObject == null)
            {
                return(endSegmentLength);
            }
            PointF center  = goObject.Center;
            PointF center2 = base.Center;

            checked
            {
                if (info.Side == 256 || info.Side == 128)
                {
                    num = countOnSide - 1 - num;
                }
                float num2 = 8f;
                bool  flag = info.Side == 256 || info.Side == 64;
                if (flag ? (center.Y < center2.Y) : (center.X < center2.X))
                {
                    return(endSegmentLength + (float)num * num2);
                }
                if (flag ? (center.Y == center2.Y) : (center.X == center2.X))
                {
                    return(endSegmentLength);
                }
                return(endSegmentLength + (float)(countOnSide - 1 - num) * num2);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Determine the angle the port at the other end makes with this port.
        /// </summary>
        /// <param name="link"></param>
        /// <returns>the angle in degrees</returns>
        public virtual float GetAngle(IGoLink link)
        {
            if (link == null)
            {
                return(0f);
            }
            IGoPort goPort = link.GetOtherPort(this);

            if (goPort == null)
            {
                if (link.FromPort != null && link.FromPort.GoObject != null && link.FromPort.GoObject.Bounds == Bounds)
                {
                    goPort = link.ToPort;
                }
                else if (link.ToPort != null && link.ToPort.GoObject != null && link.ToPort.GoObject.Bounds == Bounds)
                {
                    goPort = link.FromPort;
                }
            }
            if (goPort == null)
            {
                return(0f);
            }
            GoObject goObject = goPort.GoObject;

            if (goObject == null)
            {
                return(0f);
            }
            PointF pointF = goObject.Center;
            PointF center = base.Center;
            GoLink goLink = link as GoLink;

            if (goLink == null)
            {
                GoLabeledLink goLabeledLink = link as GoLabeledLink;
                if (goLabeledLink != null)
                {
                    goLink = goLabeledLink.RealLink;
                }
            }
            if (goLink != null && goLink.PointsCount > 0)
            {
                pointF = ((goLink.FromPort != goPort) ? goLink.GetPoint(checked (goLink.PointsCount - 1)) : goLink.GetPoint(0));
            }
            return(GoStroke.GetAngle(pointF.X - center.X, pointF.Y - center.Y));
        }