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

CalculateAlignedOffset() private method

private CalculateAlignedOffset ( RelativePositionAlign alignment, int posRect, int posRectLength, int offset, int extent, int limit ) : int
alignment RelativePositionAlign
posRect int
posRectLength int
offset int
extent int
limit int
return int
        private int CalculateAlignedOffset(RelativePositionAlign alignment,
                                           int posRect,
                                           int posRectLength,
                                           int offset,
                                           int extent,
                                           int limit)
        {
            switch (alignment)
            {
                case RelativePositionAlign.Near:
                    // Position at the near side of the viewport
                    return posRect + offset;
                case RelativePositionAlign.Center:
                    // If there is no need for any scrolling then center, otherwise place near
                    if (limit == 0)
                        return posRect + (posRectLength - extent) / 2;
                    else
                        return posRect + offset;
                case RelativePositionAlign.Far:
                    // Position against the far side
                    return posRect + posRectLength - extent - offset;
                default:
                    // Should never happen!
                    Debug.Assert(false);
                    return 0;
            }
        }