Example #1
0
        protected virtual RectangleF GetScrollThumbRectangle()
        {
            int   areaLength  = GeometryHelper.GetDimension(ClientRectangle, Orientation) - 2 * GeometryHelper.GetDimension(ButtonSize, Orientation);
            float thumbLength = areaLength * areaLength / (float)ScrollDistance;
            float offset      = ScrollValue / (float)ScrollDistance * (areaLength - thumbLength) + GeometryHelper.GetDimension(ButtonSize, Orientation);

            switch (Orientation)
            {
            case Orientation.Horizontal:
                return(new RectangleF(
                           ClientRectangle.Left + offset,
                           ClientRectangle.Top,
                           thumbLength,
                           Thickness
                           ));

            case Orientation.Vertical:
                return(new RectangleF(
                           ClientRectangle.Left,
                           ClientRectangle.Top + offset,
                           Thickness,
                           thumbLength
                           ));
            }
            throw new NotSupportedException();
        }
Example #2
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            if (isDragging)
            {
                int pixelDistance = GeometryHelper.GetDimension(e.Location, Orientation) - GeometryHelper.GetDimension(lastDraggingPoint, Orientation);
                int areaLength    = GeometryHelper.GetDimension(ClientSize, Orientation) - 2 * GeometryHelper.GetDimension(ButtonSize, Orientation);
                int scrollDelta   = (int)(pixelDistance / (float)areaLength * ScrollDistance);

                ScrollValue       = Math.Min(Math.Max(ScrollValue + scrollDelta, MinimumValue), MaximumValue);
                lastDraggingPoint = e.Location;
            }
            base.OnMouseMove(e);
        }