Skip to main content

OverlayWindowOptions.CustomPainter Property

Gets or sets an object used to paint a form.

Namespace: DevExpress.XtraSplashScreen

Assembly: DevExpress.XtraEditors.v24.2.dll

Declaration

public IOverlayWindowPainter CustomPainter { get; set; }

Property Value

Type Description
DevExpress.XtraSplashScreen.IOverlayWindowPainter

An object that implements a custom paint logic.

Property Paths

You can access this nested property as listed below:

Library Object Type Path to CustomPainter
WinForms Controls OverlayWindowOptions
.Default .CustomPainter
XAF: Cross-Platform .NET App UI & Web API DefaultOverlayFormOptions
.Options .CustomPainter

Example

You can render an Overlay Form as follows:

  • Inherit from the OverlayWindowPainterBase class.
  • Override the Draw method.
  • Pass the created object as a parameter to the ShowOverlayForm method.

The code snippet below shows how to display a custom message as in the following figure:

OvelayForm_CustomDraw

using DevExpress.XtraSplashScreen;
using DevExpress.Utils.Drawing;
using System.Drawing;
//...
class CustomOverlayPainter : OverlayWindowPainterBase
{
    // Defines the string’s font.
    static readonly Font drawFont;
    static CustomOverlayPainter() {
        drawFont = new Font("Tahoma", 18);
    }
    protected override void Draw(OverlayWindowCustomDrawContext context)
    {
        //The Handled event parameter should be set to true. 
        //to disable the default drawing algorithm. 
        context.Handled = true;
        //Provides access to the drawing surface. 
        GraphicsCache cache = context.DrawArgs.Cache;
        //Adjust the TextRenderingHint option
        //to improve the image quality.
        cache.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
        //Overlapped control bounds. 
        Rectangle bounds = context.DrawArgs.Bounds;
        //Draws the default background. 
        context.DrawBackground();
        //Specify the string that will be drawn on the Overlay Form instead of the wait indicator.
        String drawString = "Please wait...";
        //Get the system's black brush.
        Brush drawBrush = Brushes.Black;
        //Calculate the size of the message string.
        SizeF textSize = cache.CalcTextSize(drawString, drawFont);
        //A point that specifies the upper-left corner of the rectangle where the string will be drawn.
        PointF drawPoint = new PointF(
            bounds.Left + bounds.Width / 2 - textSize.Width / 2,
            bounds.Top + bounds.Height / 2 - textSize.Height / 2
            );
        //Draw the string on the screen.
        cache.DrawString(drawString, drawFont, drawBrush, drawPoint);
    }
}
//...
IOverlaySplashScreenHandle handle = SplashScreenManager.ShowOverlayForm(this, customPainter: new CustomOverlayPainter());
See Also