Smrf.NodeXL.Visualization.Wpf.FormattedTextManager.CreateFormattedText C# (CSharp) Method

CreateFormattedText() public method

public CreateFormattedText ( String text, Color color, Double graphScale ) : System.Windows.Media.FormattedText
text String
color Color
graphScale Double
return System.Windows.Media.FormattedText
    CreateFormattedText
    (
        String text,
        Color color,
        Double graphScale
    )
    {
        Debug.Assert(text != null);
        Debug.Assert(graphScale > 0);

        return ( CreateFormattedText(text, color, m_dFontSize, graphScale) );
    }

Same methods

FormattedTextManager::CreateFormattedText ( String text, Color color, Double dFontSize, Double graphScale ) : System.Windows.Media.FormattedText

Usage Example

    DrawPlusSign
    (
        VertexShape eVertexShape,
        Color oVertexColor,
        GraphDrawingContext oGraphDrawingContext,
        DrawingContext oDrawingContext,
        Double dGraphScale,
        VertexLabelDrawer oVertexLabelDrawer,
        FormattedTextManager oFormattedTextManager,
        VertexDrawingHistory oVertexDrawingHistory
    )
    {
        Debug.Assert(oGraphDrawingContext != null);
        Debug.Assert(oDrawingContext != null);
        Debug.Assert(dGraphScale >= GraphDrawer.MinimumGraphScale);
        Debug.Assert(dGraphScale <= GraphDrawer.MaximumGraphScale);
        Debug.Assert(oVertexLabelDrawer != null);
        Debug.Assert(oFormattedTextManager != null);
        Debug.Assert(oVertexDrawingHistory != null);
        AssertValid();

        Color oFillColor;

        switch (eVertexShape)
        {
            case VertexShape.Circle:
            case VertexShape.Square:
            case VertexShape.Diamond:
            case VertexShape.Triangle:

                // The fill color is the color of the background.  Adjust the
                // fill color for the opacity of the vertex.

                oFillColor = WpfGraphicsUtil.SetWpfColorAlpha(
                    oGraphDrawingContext.BackColor, oVertexColor.A);

                break;

            default:

                oFillColor = oVertexColor;
                break;
        }

        Color oContrastingColor =
            WpfGraphicsUtil.GetContrastingColor(oFillColor);

        // The font size used below was chosen so that it is large enough to be
        // easily readable, but small enough to fit within the smallest
        // collapsed group vertex created by this class.

        oVertexLabelDrawer.DrawLabel(oDrawingContext, oGraphDrawingContext,
            oVertexDrawingHistory, VertexLabelPosition.MiddleCenter,

            oFormattedTextManager.CreateFormattedText("+", oContrastingColor,
                15.0, dGraphScale),

            oContrastingColor, false);
    }