ComponentFactory.Krypton.Toolkit.ViewLayoutViewport.MoveDirection C# (CSharp) Method

MoveDirection() private method

private MoveDirection ( bool next ) : void
next bool
return void
        private void MoveDirection(bool next)
        {
            // Begin by using the current offset
            Point offset = _offset;

            // Are we scrolling in the horizontal?
            if ((Orientation == VisualOrientation.Top) ||
                (Orientation == VisualOrientation.Bottom))
            {
                // Find the distance to move horizontally
                int change = Math.Max((int)(ClientSize.Width * _scrollPercentage), _scrollMinimum);

                switch (AlignmentRTL)
                {
                    case RelativePositionAlign.Near:
                    case RelativePositionAlign.Center:
                        if (next)
                            offset.X -= change;
                        else
                            offset.X += change;
                        break;
                    case RelativePositionAlign.Far:
                        if (next)
                            offset.X += change;
                        else
                            offset.X -= change;
                        break;
                }
            }
            else
            {
                // Find the distance to move vertically
                int change = Math.Max((int)(ClientSize.Height * _scrollPercentage), _scrollMinimum);

                switch (AlignmentRTL)
                {
                    case RelativePositionAlign.Near:
                    case RelativePositionAlign.Center:
                        if (next)
                            offset.Y -= change;
                        else
                            offset.Y += change;
                        break;
                    case RelativePositionAlign.Far:
                        if (next)
                            offset.Y += change;
                        else
                            offset.Y -= change;
                        break;
                }
            }

            // Enforce the offset back to the limits
            offset.X = Math.Min(Math.Max(offset.X, _limit.X), 0);
            offset.Y = Math.Min(Math.Max(offset.Y, _limit.Y), 0);

            // If not allowed to animate, or there is no animation needed
            if (!_animateChange || _offset.Equals(offset))
            {
                // Use the new offset
                _offset = offset;
            }
            else
            {
                // Use a timer to scroll to new offset
                _animationTimer.Stop();
                _animationOffset = offset;
                _animationTimer.Start();
            }
        }