private void addButtonsToTable() { m_ButtonsWidth = tableLayoutPanelBoard.Width / m_BoardColumns; m_ButtonsHeight = tableLayoutPanelBoard.Height / m_BoardRows; generateCharImageDict(m_Game.GetRandomObjects()); CellButton cellButton = null; for (int i = 0; i < tableLayoutPanelBoard.RowCount; i++) { for (int j = 0; j < tableLayoutPanelBoard.ColumnCount; j++) { if (m_HasInternetConnection) { cellButton = new ImageCellButton(i, j, (PictureBox)m_CharImageDict[m_Game.GetCellValue(i, j, true)]); cellButton = createCellButton(ref cellButton); tableLayoutPanelBoard.Controls.Add(cellButton, j, i); } else { cellButton = new CellButton(i, j); cellButton = createCellButton(ref cellButton); tableLayoutPanelBoard.Controls.Add(cellButton, j, i); } } } }
private CellButton createCellButton(ref CellButton io_CellButton) { io_CellButton.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); io_CellButton.Location = new System.Drawing.Point(3, 3); io_CellButton.Name = string.Format("Button {0}, {1}", io_CellButton.RowIndex, io_CellButton.ColumnIndex); io_CellButton.Size = new System.Drawing.Size(m_ButtonsWidth, m_ButtonsHeight); io_CellButton.TabIndex = tableLayoutPanelBoard.TabIndex + io_CellButton.RowIndex + io_CellButton.ColumnIndex; io_CellButton.Text = ""; io_CellButton.BackColor = sr_DefaultBoardButtonBackColor; io_CellButton.ForeColor = sr_DefaultBoardButtonForeColor; io_CellButton.UseVisualStyleBackColor = true; io_CellButton.Value = m_Game.GetCellValue(io_CellButton.RowIndex, io_CellButton.ColumnIndex, true); io_CellButton.Click += new EventHandler(cellButton_Click); return(io_CellButton); }