Call the following in a timer. Set
startTime
to the time you started the timer.
private void TimerCalledMethod()
{
TimeSpan runningSpan = DateTime.Now - startTime;
float cycleFraction = runningSpan % timeSpanForOneCycle;
float scrollFraction;
if (cycleFraction < 0.5F)
{
scrollFraction = 2F * cycleFraction;
}
else
{
scrollFraction = 2F - (2F * cycleFraction);
}
ScrollBar.SetPosition(rtfHeight * scrollFraction);
}
[Edit]That's untested pseudo-code just coincidentally looking much like C#.[/Edit]