Smrf.NodeXL.Visualization.Wpf.EdgeDrawer.DrawBezierCurve C# (CSharp) Method

DrawBezierCurve() protected method

protected DrawBezierCurve ( IEdge oEdge, GraphDrawingContext oGraphDrawingContext, System.Windows.Media.DrawingContext oDrawingContext, Point oEdgeEndpoint1, Point oEdgeEndpoint2, System.Boolean bDrawAsSelected, System.Boolean bDrawArrow, System.Windows.Media.Pen oPen, Color oColor, Double dWidth, VisibilityKeyValue eVisibility, String sLabel ) : void
oEdge IEdge
oGraphDrawingContext GraphDrawingContext
oDrawingContext System.Windows.Media.DrawingContext
oEdgeEndpoint1 Point
oEdgeEndpoint2 Point
bDrawAsSelected System.Boolean
bDrawArrow System.Boolean
oPen System.Windows.Media.Pen
oColor Color
dWidth Double
eVisibility VisibilityKeyValue
sLabel String
return void
    DrawBezierCurve
    (
        IEdge oEdge,
        GraphDrawingContext oGraphDrawingContext,
        DrawingContext oDrawingContext,
        Point oEdgeEndpoint1,
        Point oEdgeEndpoint2,
        Boolean bDrawAsSelected,
        Boolean bDrawArrow,
        Pen oPen,
        Color oColor,
        Double dWidth,
        VisibilityKeyValue eVisibility,
        String sLabel
    )
    {
        Debug.Assert(oEdge != null);
        Debug.Assert(oGraphDrawingContext != null);
        Debug.Assert(oDrawingContext != null);
        Debug.Assert(oPen != null);
        AssertValid();

        Point oBezierControlPoint = GetBezierControlPoint(oGraphDrawingContext,
            oEdgeEndpoint1, oEdgeEndpoint2, m_dBezierDisplacementFactor);

        if (bDrawArrow)
        {
            // When the edge is a Bezier curve, the arrow should be aligned
            // along the tangent of the curve at the second endpoint.  The
            // tangent runs from the second endpoint to the Bezier control
            // point.

            Double dArrowAngle = WpfGraphicsUtil.GetAngleBetweenPointsRadians(
                oBezierControlPoint, oEdgeEndpoint2);

            // Draw the arrow and set the second endpoint to the center of the
            // flat end of the arrow.  Note that in the Bezier case, moving the
            // second endpoint causes a small distortion of the Bezier curve.

            oEdgeEndpoint2 = DrawArrow(oDrawingContext, oEdgeEndpoint2,
                dArrowAngle, oColor, dWidth);
        }

        PathGeometry oBezierCurve =
            WpfPathGeometryUtil.GetQuadraticBezierCurve(oEdgeEndpoint1,
                oEdgeEndpoint2, oBezierControlPoint);

        oDrawingContext.DrawGeometry(null, oPen, oBezierCurve);

        if ( !String.IsNullOrEmpty(sLabel) )
        {
            DrawLabel(oEdge, oDrawingContext, oGraphDrawingContext,
                bDrawAsSelected, oColor, eVisibility, oEdgeEndpoint1,
                oEdgeEndpoint2, oBezierCurve, oBezierControlPoint, sLabel);
        }
    }