Search
Step 4: Override the DrawLocal method

Override the DrawLocal method of the base class to implement your own drawing logic.

C#  Copy Code

public override void DrawLocal(IGraphics graphics, RenderOptions options)
{
    Rectangle iconSizePixels = new Rectangle(
        0, 0, icon.Width, icon.Height);
    RectangleF imageSize = MindFusion.Utilities.DeviceToDoc(
        graphics, iconSizePixels);

    // Draw the icon at the top-middle
    graphics.DrawImage(icon,
        Bounds.X + Bounds.Width / 2 - imageSize.Width / 2, Bounds.Y);

    // Draw the label at the bottom
    RectangleF labelBounds = RectangleF.FromLTRB(
        Bounds.X, Bounds.Y + imageSize.Height,
        Bounds.Right, Bounds.Bottom);

    graphics.DrawString(label,
        Font, Brushes.Black, labelBounds, format);
}

Visual Basic  Copy Code

Public Overrides Sub DrawLocal(ByVal graphics As IGraphics, ByVal options As RenderOptions)

    Dim iconSizePixels As Rectangle = New Rectangle( _
        0, 0, fIcon.Width, fIcon.Height)
    Dim imageSize As RectangleF = MindFusion.Utilities.DeviceToDoc( _
        graphics, iconSizePixels)

    ' Draw the icon at the top-middle
    graphics.DrawImage(fIcon, _
        Bounds.X + Bounds.Width / 2 - imageSize.Width / 2, Bounds.Y)

    ' Draw the label at the bottom
    Dim labelBounds As RectangleF = RectangleF.FromLTRB( _
        Bounds.X, Bounds.Y + imageSize.Height, _
        Bounds.Right, Bounds.Bottom)

    graphics.DrawString(fLabel, _
        Font, Brushes.Black, labelBounds, format)

End Sub