private void HandleScroll(Orientation orientation, ScrollEventArgs e)
{
if (ScrollInfo != null) {
bool horizontal = orientation == Orientation.Horizontal;
double scrollable = horizontal ?
ScrollableWidth :
ScrollableHeight;
double offset = horizontal ?
ScrollInfo.HorizontalOffset :
ScrollInfo.VerticalOffset;
double viewportDimension = horizontal ?
ScrollInfo.ViewportWidth :
ScrollInfo.ViewportHeight;
// Calculate new offset
double newValue = Math.Min (scrollable, offset);
switch (e.ScrollEventType) {
case ScrollEventType.ThumbPosition:
case ScrollEventType.ThumbTrack:
SetScrollOffset (orientation, e.NewValue);
break;
case ScrollEventType.LargeDecrement:
if (horizontal)
ScrollInfo.PageLeft ();
else
ScrollInfo.PageUp ();
break;
case ScrollEventType.LargeIncrement:
if (horizontal)
ScrollInfo.PageRight ();
else
ScrollInfo.PageDown ();
break;
case ScrollEventType.SmallDecrement:
if (horizontal)
ScrollInfo.LineLeft ();
else
ScrollInfo.LineUp ();
break;
case ScrollEventType.SmallIncrement:
if (horizontal)
ScrollInfo.LineRight ();
else
ScrollInfo.LineDown ();
break;
case ScrollEventType.First:
SetScrollOffset (orientation, double.MinValue);
break;
case ScrollEventType.Last:
SetScrollOffset (orientation, double.MaxValue);
break;
}
}
}