protected override void OnPaint(PaintEventArgs e)
{
string beginDrawError = this.BeginDraw();
if (string.IsNullOrEmpty(beginDrawError))
{
// Draw the control using the GraphicsDevice.
this.Draw();
this.EndDraw();
}
else
{
// If BeginDraw failed, show an error message using System.Drawing.
this.PaintUsingSystemDrawing(e.Graphics, beginDrawError);
}
}