public override void MouseMove(Point location, bool inComponent, bool amClipped) { base.MouseMove(location, inComponent, amClipped); if (downed) { // in order to move this trackbar, we need to change the offsetY of the controlled ScrollContainer appropriately float nowPos = orientation == Orientation.v ? location.Y : location.X; float want = topOriginal + (nowPos - downedOrigin); // |b1|-----| tack |-------|b2| // so we need to invert: top = b + frac*(total-2*b-tack) // that is (top-b1)/(total-b1-b2-tack) = frac float b1 = orientation == Orientation.v ? controlled.upButton.Size.height : controlled.leftButton.Size.width; float b2 = orientation == Orientation.v ? controlled.downButton.Size.height : controlled.rightButton.Size.width; float tot = orientation == Orientation.v ? controlled.verticalContainer.Size.height : controlled.horizontalContainer.Size.width; float tack = orientation == Orientation.v ? Size.height : Size.width; float fracWant = (want - b1) / (tot - b1 - b2 - tack); if (orientation == Orientation.v) { controlled.yOffset = fracWant * (controlled.ContentHeight - controlled.trimHeight); } if (orientation == Orientation.h) { controlled.xOffset = fracWant * (controlled.ContentWidth - controlled.trimWidth); } controlled.OnSizeChanged(); } }
void TimeCB(Object o) { switch (type) { case Direction.u: controlled.yOffset -= step; break; case Direction.d: controlled.yOffset += step; break; case Direction.l: controlled.xOffset -= step; break; case Direction.r: controlled.xOffset += step; break; } controlled.OnSizeChanged(); }