protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
if (e.Button == MouseButtons.Left)
{
if (thumbClicked)
{
int oldScrollValue = curValue;
int pos = metroOrientation == MetroScrollOrientation.Vertical ? e.Location.Y : e.Location.X;
int thumbSize = metroOrientation == MetroScrollOrientation.Vertical ? (pos / Height) / thumbHeight : (pos / Width) / thumbWidth;
if (pos <= (thumbTopLimit + thumbPosition))
{
ChangeThumbPosition(thumbTopLimit);
curValue = minimum;
Invalidate();
}
else if (pos >= (thumbBottomLimitTop + thumbPosition))
{
ChangeThumbPosition(thumbBottomLimitTop);
curValue = maximum;
Invalidate();
}
else
{
ChangeThumbPosition(pos - thumbPosition);
int pixelRange, thumbPos;
if (Orientation == MetroScrollOrientation.Vertical)
{
pixelRange = Height - thumbSize;
thumbPos = thumbRectangle.Y;
}
else
{
pixelRange = Width - thumbSize;
thumbPos = thumbRectangle.X;
}
float perc = 0f;
if (pixelRange != 0)
{
perc = (thumbPos)/(float) pixelRange;
}
curValue = Convert.ToInt32((perc * (maximum - minimum)) + minimum);
}
if (oldScrollValue != curValue)
{
OnScroll(ScrollEventType.ThumbTrack, oldScrollValue, curValue, scrollOrientation);
Refresh();
}
}
}
else if (!ClientRectangle.Contains(e.Location))
{
ResetScrollStatus();
}
else if (e.Button == MouseButtons.None)
{
if (thumbRectangle.Contains(e.Location))
{
Invalidate(thumbRectangle);
}
else if (ClientRectangle.Contains(e.Location))
{
Invalidate();
}
}
}