private void EndPerformanceCount(PaintEventArgs e)
{
double time = TimeCounter.Finish();
_totalTime += time;
string debugText = string.Format("FPS {0:0.0}; Avg. FPS {1:0.0}",
1 / time, 1 / (_totalTime / _paintCount));
e.Graphics.FillRectangle(Brushes.White, new Rectangle(DisplayRectangle.Width - 150, DisplayRectangle.Height - 20, 150, 20));
e.Graphics.DrawString(debugText, Control.DefaultFont, Brushes.Gray,
new PointF(DisplayRectangle.Width - 150, DisplayRectangle.Height - 20));
}