Manina.Windows.Forms.ImageListViewLayoutManager.UpdateScrollBars C# (CSharp) Method

UpdateScrollBars() private method

Updates scroll bar parameters.
private UpdateScrollBars ( ) : void
return void
        private void UpdateScrollBars()
        {
            // Set scroll range
            if (mImageListView.Items.Count != 0)
            {
                // Horizontal scroll range
                if (mImageListView.ScrollOrientation == System.Windows.Forms.ScrollOrientation.HorizontalScroll)
                {
                    mImageListView.hScrollBar.Minimum = 0;
                    mImageListView.hScrollBar.Maximum = Math.Max(0, totalWidth - 1);
                    if (!mImageListView.IntegralScroll)
                        mImageListView.hScrollBar.LargeChange = mItemAreaBounds.Width;
                    else
                        mImageListView.hScrollBar.LargeChange = mItemSizeWithMargin.Width * mDisplayedCols;
                    mImageListView.hScrollBar.SmallChange = mItemSizeWithMargin.Width;
                }
                else
                {
                    mImageListView.hScrollBar.Minimum = 0;
                    mImageListView.hScrollBar.Maximum = mDisplayedCols * mItemSizeWithMargin.Width;
                    mImageListView.hScrollBar.LargeChange = mItemAreaBounds.Width;
                    mImageListView.hScrollBar.SmallChange = 1;
                }
                if (mImageListView.ViewOffset.X > mImageListView.hScrollBar.Maximum - mImageListView.hScrollBar.LargeChange + 1)
                {
                    mImageListView.hScrollBar.Value = mImageListView.hScrollBar.Maximum - mImageListView.hScrollBar.LargeChange + 1;
                    mImageListView.ViewOffset = new Point(mImageListView.hScrollBar.Value, mImageListView.ViewOffset.Y);
                }

                // Vertical scroll range
                if (mImageListView.ScrollOrientation == System.Windows.Forms.ScrollOrientation.HorizontalScroll)
                {
                    mImageListView.vScrollBar.Minimum = 0;
                    mImageListView.vScrollBar.Maximum = mDisplayedRows * mItemSizeWithMargin.Height;
                    mImageListView.vScrollBar.LargeChange = mItemAreaBounds.Height;
                    mImageListView.vScrollBar.SmallChange = 1;
                }
                else
                {
                    mImageListView.vScrollBar.Minimum = 0;
                    mImageListView.vScrollBar.Maximum = Math.Max(0, totalHeight - 1);
                    if (!mImageListView.IntegralScroll)
                        mImageListView.vScrollBar.LargeChange = mItemAreaBounds.Height;
                    else
                        mImageListView.vScrollBar.LargeChange = mItemSizeWithMargin.Height * mDisplayedRows;
                    mImageListView.vScrollBar.SmallChange = mItemSizeWithMargin.Height;
                }
                if (mImageListView.ViewOffset.Y > mImageListView.vScrollBar.Maximum - mImageListView.vScrollBar.LargeChange + 1)
                {
                    mImageListView.vScrollBar.Value = mImageListView.vScrollBar.Maximum - mImageListView.vScrollBar.LargeChange + 1;
                    mImageListView.ViewOffset = new Point(mImageListView.ViewOffset.X, mImageListView.vScrollBar.Value);
                }
            }
            else // if (mImageListView.Items.Count == 0)
            {
                // Zero out the scrollbars if we don't have any items
                mImageListView.hScrollBar.Minimum = 0;
                mImageListView.hScrollBar.Maximum = 0;
                mImageListView.hScrollBar.Value = 0;
                mImageListView.vScrollBar.Minimum = 0;
                mImageListView.vScrollBar.Maximum = 0;
                mImageListView.vScrollBar.Value = 0;
                mImageListView.ViewOffset = new Point(0, 0);
            }

            Rectangle bounds = mImageListView.ClientRectangle;
            if (mImageListView.BorderStyle != System.Windows.Forms.BorderStyle.None)
                bounds.Inflate(-1, -1);

            // Horizontal scrollbar position
            mImageListView.hScrollBar.Left = bounds.Left;
            mImageListView.hScrollBar.Top = bounds.Bottom - mImageListView.hScrollBar.Height;
            mImageListView.hScrollBar.Width = bounds.Width - (mImageListView.vScrollBar.Visible ? mImageListView.vScrollBar.Width : 0);
            // Vertical scrollbar position
            mImageListView.vScrollBar.Left = bounds.Right - mImageListView.vScrollBar.Width;
            mImageListView.vScrollBar.Top = bounds.Top;
            mImageListView.vScrollBar.Height = bounds.Height - (mImageListView.hScrollBar.Visible ? mImageListView.hScrollBar.Height : 0);
        }