Ejemplo n.º 1
0
        private void InitGrid()
        {
            int elementsPerRow = 1;

            if (ClientSize.Width > 850 && ClientSize.Height > 850)
            {
                elementsPerRow = 3;
            }
            else if (ClientSize.Width > 450 && ClientSize.Height > 450)
            {
                elementsPerRow = 2;
            }

            if (_recentGames.Count <= 1)
            {
                elementsPerRow = 1;
            }
            else if (_recentGames.Count <= 4)
            {
                elementsPerRow = Math.Min(2, elementsPerRow);
            }

            if (_elementsPerRow == elementsPerRow)
            {
                return;
            }

            _elementsPerRow  = elementsPerRow;
            _elementsPerPage = elementsPerRow * elementsPerRow;

            _controls = new List <ctrlRecentGame>();
            tlpGrid.SuspendLayout();
            tlpGrid.ColumnCount = _elementsPerRow;
            tlpGrid.RowCount    = _elementsPerRow;
            tlpGrid.ColumnStyles.Clear();
            tlpGrid.RowStyles.Clear();
            tlpGrid.Controls.Clear();
            for (int j = 0; j < _elementsPerRow; j++)
            {
                tlpGrid.RowStyles.Add(new RowStyle(SizeType.Percent, 100F / _elementsPerRow));
                tlpGrid.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F / _elementsPerRow));
            }

            for (int j = 0; j < _elementsPerRow; j++)
            {
                for (int i = 0; i < _elementsPerRow; i++)
                {
                    ctrlRecentGame ctrl = new ctrlRecentGame();
                    ctrl.OnRecentGameLoaded += RecentGameLoaded;
                    ctrl.Dock   = DockStyle.Fill;
                    ctrl.Margin = new Padding(2);
                    tlpGrid.Controls.Add(ctrl, i, j);
                    _controls.Add(ctrl);
                }
            }
            tlpGrid.ResumeLayout();
            UpdateGameInfo();
        }
Ejemplo n.º 2
0
        private void InitGrid()
        {
            int columnCount = 1;

            if (ClientSize.Width > 850 && ClientSize.Height > 850)
            {
                columnCount = 3;
            }
            else if (ClientSize.Width > 450 && ClientSize.Height > 450)
            {
                columnCount = 2;
            }

            if (_recentGames.Count <= 1)
            {
                columnCount = 1;
            }
            else if (_recentGames.Count <= 4)
            {
                columnCount = Math.Min(2, columnCount);
            }

            int elementsPerPage = columnCount * columnCount;
            int rowCount        = columnCount;

            if (Mode != GameScreenMode.RecentGames)
            {
                elementsPerPage = 12;
                columnCount     = 4;
                rowCount        = 3;
            }

            if (_columnCount == columnCount && _elementsPerPage == elementsPerPage && _rowCount == rowCount)
            {
                return;
            }

            _columnCount     = columnCount;
            _rowCount        = rowCount;
            _elementsPerPage = elementsPerPage;

            _controls = new List <ctrlRecentGame>();
            tlpGrid.SuspendLayout();
            tlpGrid.ColumnCount = _columnCount;
            tlpGrid.RowCount    = _rowCount;
            tlpGrid.ColumnStyles.Clear();
            tlpGrid.RowStyles.Clear();
            tlpGrid.Controls.Clear();
            for (int j = 0; j < _columnCount; j++)
            {
                tlpGrid.RowStyles.Add(new RowStyle(SizeType.Percent, 100F / _columnCount));
                tlpGrid.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F / _columnCount));
            }

            for (int j = 0; j < _rowCount; j++)
            {
                for (int i = 0; i < _columnCount; i++)
                {
                    ctrlRecentGame ctrl = new ctrlRecentGame();
                    ctrl.OnRecentGameLoaded += RecentGameLoaded;
                    ctrl.Dock   = DockStyle.Fill;
                    ctrl.Margin = new Padding(2);
                    tlpGrid.Controls.Add(ctrl, i, j);
                    _controls.Add(ctrl);
                }
            }
            tlpGrid.ResumeLayout();
            UpdateGameInfo();

            picPrevGame.Visible = _recentGames.Count > _elementsPerPage;
            picNextGame.Visible = _recentGames.Count > _elementsPerPage;
        }