protected virtual void OnNeedPaint(object sender, NeedLayoutEventArgs e)
{
Debug.Assert(e != null);
// Validate incoming reference
if (e == null) throw new ArgumentNullException("e");
// If required, layout the control
if (e.NeedLayout && !_layoutDirty)
_layoutDirty = true;
if (IsHandleCreated && (!_refreshAll || !e.InvalidRect.IsEmpty))
{
// Always request the repaint immediately
if (e.InvalidRect.IsEmpty)
{
_refreshAll = true;
Invalidate();
}
else
Invalidate(e.InvalidRect);
// Do we need to use an Invoke to force repaint?
if (!_refresh && EvalInvokePaint)
BeginInvoke(_refreshCall);
// A refresh is outstanding
_refresh = true;
}
}