Smrf.NodeXL.Visualization.Wpf.DrawerBase.DrawLabelBackground C# (CSharp) Method

DrawLabelBackground() protected method

protected DrawLabelBackground ( System.Windows.Media.DrawingContext oDrawingContext, GraphDrawingContext oGraphDrawingContext, System.Windows.Media.FormattedText oFormattedText, Color oFormattedTextColor, Byte btBackgroundAlpha, Point oTextOrigin ) : void
oDrawingContext System.Windows.Media.DrawingContext
oGraphDrawingContext GraphDrawingContext
oFormattedText System.Windows.Media.FormattedText
oFormattedTextColor Color
btBackgroundAlpha Byte
oTextOrigin Point
return void
    DrawLabelBackground
    (
        DrawingContext oDrawingContext,
        GraphDrawingContext oGraphDrawingContext,
        FormattedText oFormattedText,
        Color oFormattedTextColor,
        Byte btBackgroundAlpha,
        Point oTextOrigin
    )
    {
        Debug.Assert(oDrawingContext != null);
        Debug.Assert(oGraphDrawingContext != null);
        Debug.Assert(oFormattedText != null);
        AssertValid();

        if (oFormattedText.Width == 0 || oFormattedText.Height == 0)
        {
            return;
        }

        // Note: Don't make the background any more opaque than the text, which
        // might be translucent itself.

        Color oBackgroundColor = WpfGraphicsUtil.SetWpfColorAlpha(
            oGraphDrawingContext.BackColor,
            Math.Min(btBackgroundAlpha, oFormattedTextColor.A) );

        SolidColorBrush oBackgroundBrush = CreateFrozenSolidColorBrush(
            oBackgroundColor);

        Rect oBackgroundRectangle = WpfGraphicsUtil.GetFormattedTextBounds(
            oFormattedText, oTextOrigin);

        // Draw a rounded rectangle with a small amount of padding.

        const Int32 Padding = 1;
        const Int32 Radius = 2;
        oBackgroundRectangle.Inflate(Padding, Padding);

        oDrawingContext.DrawRoundedRectangle(oBackgroundBrush, null,
            oBackgroundRectangle, Radius, Radius);
    }