public int Minimum { get; set; }
public int Maximum { get; set; }
public int Value { get; set; }
public void Update()
{
// Calculate the Scrollbar Thumb height:
var viewable_ratio = ViewportHeight / ContentHeight;
var scrollbar_area = ViewportHeight - ( ArrowHeight * 2 );
this.ThumbHeight = scrollbar_area * viewable_ratio;
// Calculate the Scrollbar Thumb step:
var track_space = ContentHeight - ViewportHeight;
var thumb_space = ViewportHeight - ThumbHeight;
this.ThumbStep = track_space / thumb_space;
// TODO: Calculate the "Minimum" and "Maximum" values.
this.Minimum = ???
this.Maximum = ???
Point mouse = Input.MousePosition();
if(Thumb.Rectangle.Contains(mouse) && Input.MouseDown(0))
{
int x = Thumb.Position.x;
int y = ( mouse.y - Thumb.Position.y );
Thumb.Position = new Point(x, y);
if(Thumb.Position.y < Minimum) Thumb.Position.y = Minimum;
if(Thumb.Position.y > Maximum) Thumb.Position.y = Maximum;
// TODO: Set the "Value" property to the correct value when the Thumb is moved.
this.Value = ???
this.Content.Position.y = this.Value;
}
}