public Image GetNextFrame()
{
// Only pass the next frame if the proper amount of time has passed
if ((DateTime.Now - _lastRequest).Milliseconds > _delay)
{
CurrentFrame += _step;
_lastRequest = DateTime.Now;
}
//if the animation reaches a boundary...
if (CurrentFrame < FrameCount && CurrentFrame >= 1)
return GetFrame(CurrentFrame);
if (ReverseAtEnd)
{
_step *= -1; //...reverse the count
CurrentFrame += _step; //apply it
}
else
CurrentFrame = 0; //...or start over
return GetFrame(CurrentFrame);
}