protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
if (Capture & e.Button == MouseButtons.Left)
{
var set = ScrollEventType.ThumbPosition;
Point pt = e.Location;
int margin = thumbSize.Width >> 1;
int p = pt.X - margin;
float coef = (float)(barMaximum - barMinimum) /
(ClientSize.Width - 2 * margin);
trackerValue = (int)(p * coef + barMinimum);
if (trackerValue <= barMinimum)
{
trackerValue = barMinimum;
set = ScrollEventType.First;
}
else if (trackerValue >= barMaximum)
{
trackerValue = barMaximum;
set = ScrollEventType.Last;
}
if (Scroll != null) Scroll(this, new ScrollEventArgs(set, trackerValue));
if (ValueChanged != null) ValueChanged(this, new EventArgs());
}
Invalidate();
}