Пример #1
0
        private GoLink DrawEdge(GoNodeWrapper nodeWrapper, GoView myView, InstructionNode backNode, GoLayer layer, Pen pen)
        {
            GoLink link            = new GoLink();
            var    backNodeWrapper = GetNodeWrapper(backNode);

            link.Pen    = pen;
            link.ToPort = nodeWrapper.Node.LeftPort;
            if (backNodeWrapper.Node == nodeWrapper.Node)
            {
                link.FromPort = backNodeWrapper.Node.RightPort;
                link.Style    = GoStrokeStyle.Bezier;
                link.CalculateRoute();
                foreach (int index in new[] { 1, 2 })
                {
                    link.SetPoint(index, new PointF(link.GetPoint(index).X, link.GetPoint(index).Y - 40));
                }
            }
            else
            {
                link.FromPort = backNodeWrapper.Node.RightPort;
            }
            layer.Add(link);
            link.PenWidth = 3;
            return(link);
        }
Пример #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));
        }