예제 #1
0
        private void Recalculate(bool resetScrollbar)
        {
            _scrollBar.Location  = new Point(Width - _scrollBar.Width - 2, 1);
            _scrollBar.Size      = new System.Drawing.Size(_scrollBar.Width, Height - 2);
            _visibleColumnsCount = Math.Max(0, (((Width - _scrollBar.Width) - 1) / MAX_WIDTH));
            _visibleRowsCount    = Math.Max(0, ((Height - 1) / MAX_HEIGHT));

            if (_visibleColumnsCount == 0)
            {
                _scrollBar.Maximum = 0;
                return;
            }

            if (_artworkFactory == null)
            {
                return;
            }

            if (_artworkControlType == Forms.Controls.ArtworkControlType.Land)
            {
                var count = _artworkFactory.GetLandTileCount <Bitmap>() / _visibleColumnsCount;

                if (_artworkFactory.GetStaticTileCount <Bitmap>() % _visibleColumnsCount > 0)
                {
                    count++;
                }

                _scrollBar.Maximum = count;
            }
            else
            {
                var count = _artworkFactory.GetStaticTileCount <Bitmap>() / _visibleColumnsCount;

                if (_artworkFactory.GetStaticTileCount <Bitmap>() % _visibleColumnsCount > 0)
                {
                    count++;
                }

                _scrollBar.Maximum = count;
            }

            if (resetScrollbar)
            {
                _scrollBar.Value = 0;
            }
        }