示例#1
0
        /// <summary>
        /// Draws a partially defined graph edge</summary>
        /// <param name="fromNode">Source node, or null</param>
        /// <param name="fromRoute">Source route, or null</param>
        /// <param name="toNode">Destination node, or null</param>
        /// <param name="toRoute">Destination route, or null</param>
        /// <param name="label">Edge label</param>
        /// <param name="endPoint">Endpoint to substitute for source or destination, if either is null</param>
        /// <param name="g">Graphics object</param>
        public override void Draw(
            TNode fromNode,
            BoundaryRoute fromRoute,
            TNode toNode,
            BoundaryRoute toRoute,
            string label,
            Point endPoint,
            D2dGraphics g)
        {
            // put endpoint into statechart space
            var inverse = g.Transform;

            inverse.Invert();
            PointF end = Matrix3x2F.TransformPoint(inverse, endPoint);

            PointF p1;
            PointF normal1;

            if (fromNode != null)
            {
                p1 = ParameterToPoint(fromNode.Bounds, fromRoute.Position, out normal1);
            }
            else
            {
                p1      = end;
                normal1 = new Point();
            }

            PointF p4;
            PointF normal2;

            if (toNode != null)
            {
                p4 = ParameterToPoint(toNode.Bounds, toRoute.Position, out normal2);
            }
            else
            {
                p4      = end;
                normal2 = new Point();
            }

            PointF p2, p3;
            float  d = GetTransitionPoints(p1, normal1, p4, normal2, out p2, out p3);

            DrawEdgeSpline(p1, p2, p3, p4, d, m_theme.OutlineBrush, g);

            if (!string.IsNullOrEmpty(label))
            {
                BezierCurve2F curve    = new BezierCurve2F(p1, p2, p3, p4);
                Vec2F         midpoint = curve.Evaluate(0.5f);
                g.DrawText(label, m_centerText, new PointF(midpoint.X, midpoint.Y), m_theme.TextBrush);
            }
        }
示例#2
0
        private void Draw(TEdge edge, Pen pen, Graphics g)
        {
            Point p1, p2, p3, p4;
            float d = GetTransitionPoints(edge, out p1, out p2, out p3, out p4);

            DrawEdgeSpline(p1, p2, p3, p4, d, pen, g);

            BezierCurve2F curve    = new BezierCurve2F(p1, p2, p3, p4);
            Vec2F         midpoint = curve.Evaluate(0.5f);

            midpoint.X += 2;
            g.DrawString(edge.Label, m_theme.Font, m_theme.TextBrush, new PointF(midpoint.X, midpoint.Y));
        }
示例#3
0
        /// <summary>
        /// Draws a partially defined graph edge</summary>
        /// <param name="fromNode">Source node, or null</param>
        /// <param name="fromRoute">Source route, or null</param>
        /// <param name="toNode">Destination node, or null</param>
        /// <param name="toRoute">Destination route, or null</param>
        /// <param name="label">Edge label</param>
        /// <param name="endPoint">Endpoint to substitute for source or destination, if either is null</param>
        /// <param name="g">Graphics object</param>
        public override void Draw(
            TNode fromNode,
            BoundaryRoute fromRoute,
            TNode toNode,
            BoundaryRoute toRoute,
            string label,
            Point endPoint,
            Graphics g)
        {
            // put endpoint into statechart space
            endPoint = GdiUtil.InverseTransform(g.Transform, endPoint);

            Point p1;
            Point normal1;

            if (fromNode != null)
            {
                p1 = ParameterToPoint(fromNode.Bounds, fromRoute.Position, out normal1);
            }
            else
            {
                p1      = endPoint;
                normal1 = new Point();
            }

            Point p4;
            Point normal2;

            if (toNode != null)
            {
                p4 = ParameterToPoint(toNode.Bounds, toRoute.Position, out normal2);
            }
            else
            {
                p4      = endPoint;
                normal2 = new Point();
            }

            Point p2, p3;
            float d = GetTransitionPoints(p1, normal1, p4, normal2, out p2, out p3);

            DrawEdgeSpline(p1, p2, p3, p4, d, m_theme.OutlinePen, g);

            BezierCurve2F curve    = new BezierCurve2F(p1, p2, p3, p4);
            Vec2F         midpoint = curve.Evaluate(0.5f);

            midpoint.X += 2;
            g.DrawString(label, m_theme.Font, m_theme.TextBrush, new PointF(midpoint.X, midpoint.Y));
        }
示例#4
0
        private void Draw(TEdge edge, D2dBrush brush, D2dGraphics g)
        {
            PointF p1, p2, p3, p4;
            float  d = GetTransitionPoints(edge, out p1, out p2, out p3, out p4);

            DrawEdgeSpline(p1, p2, p3, p4, d, brush, g);
            GdiUtil.MakeRectangle(p1, p2);

            BezierCurve2F curve    = new BezierCurve2F(p1, p2, p3, p4);
            Vec2F         midpoint = curve.Evaluate(0.5f);

            midpoint.X += 2;
            string label = edge.Label;

            if (!string.IsNullOrEmpty(label))
            {
                g.DrawText(edge.Label, m_theme.TextFormat, new PointF(midpoint.X, midpoint.Y), m_theme.TextBrush);
            }
        }