public override void Update(UpdateState state)
{
base.Update(state);
if (m_ThumbDown)
{
/** Dragging the thumb **/
var mousePosition = this.GetMousePosition(state.MouseState);
mousePosition.X -= m_ThumbMouseOffset.X;
mousePosition.Y -= m_ThumbMouseOffset.Y;
var layout = m_LayoutCache.Calculate(
"layout",
x => CalculateLayout()
);
float trackSize;
float percent;
if (Orientation == 0)
{ //horizontal
trackSize = m_Width - layout.ThumbFrom.Width;
percent = mousePosition.X / trackSize;
}
else
{ //vertical
trackSize = m_Height - layout.ThumbFrom.Height;
percent = mousePosition.Y / trackSize;
}
percent = Math.Min(Math.Max(0, percent), 1);
var newValue = m_MinValue + ((m_MaxValue - m_MinValue) * percent);
Value = newValue;
}
}