Ejemplo n.º 1
0
        private void initializeBoard()
        {
            int x = k_BoardStartPointHorizontal;
            int y = k_BoardStartPointVertical;

            for (int i = 0; i < m_NumOfRowsAndCol; i++)
            {
                for (int j = 0; j < m_NumOfRowsAndCol; j++)
                {
                    m_Buttons[i, j]           = new CellButton(i, j);
                    m_Buttons[i, j].Width     = k_ButtonSquareSize;
                    m_Buttons[i, j].Height    = k_ButtonSquareSize;
                    m_Buttons[i, j].Location  = new Point(x, y);
                    m_Buttons[i, j].BackColor = k_DefaultColor;
                    m_Buttons[i, j].Enabled   = false;
                    if (m_GameLogic.GameBoard.GameBoard[i, j].Color == eButtonColor.Black)
                    {
                        m_Buttons[i, j].BackColor = Color.Black;
                        m_Buttons[i, j].ForeColor = Color.White;
                        m_Buttons[i, j].Text      = "o";
                    }

                    if (m_GameLogic.GameBoard.GameBoard[i, j].Color == eButtonColor.White)
                    {
                        m_Buttons[i, j].BackColor = Color.White;
                        m_Buttons[i, j].ForeColor = Color.Black;
                        m_Buttons[i, j].Text      = "o";
                    }

                    if (m_GameLogic.GameBoard.GameBoard[i, j].Color == eButtonColor.Gray)
                    {
                        m_Buttons[i, j].BackColor = Color.Gray;
                        m_Buttons[i, j].ForeColor = Color.Black;
                        m_Buttons[i, j].Text      = "o";
                    }

                    x += k_ButtonSquareSize + k_SpaceBetweenButtonSize;
                    m_Buttons[i, j].Click += new EventHandler(OnGameButton_Click);
                    this.Controls.Add(m_Buttons[i, j]);
                }

                x  = k_BoardStartPointHorizontal;
                y += k_ButtonSquareSize + k_SpaceBetweenButtonSize;
            }

            this.AutoSize = true;
            UpDateGameBoard();
        }
Ejemplo n.º 2
0
        private void initializeBoard()
        {
            int x = k_BoardStartPointHorizontal;
            int y = k_BoardStartPointVertical;
            for (int i = 0; i < m_NumOfRowsAndCol; i++)
            {
                for (int j = 0; j < m_NumOfRowsAndCol; j++)
                {
                    m_Buttons[i, j] = new CellButton(i, j);
                    m_Buttons[i, j].Width = k_ButtonSquareSize;
                    m_Buttons[i, j].Height = k_ButtonSquareSize;
                    m_Buttons[i, j].Location = new Point(x, y);
                    m_Buttons[i, j].BackColor = k_DefaultColor;
                    m_Buttons[i, j].Enabled = false;
                    if(m_GameLogic.GameBoard.GameBoard[i, j].Color == eButtonColor.Black)
                    {
                        m_Buttons[i, j].BackColor = Color.Black;
                        m_Buttons[i, j].ForeColor = Color.White;
                        m_Buttons[i, j].Text = "o";
                    }

                    if(m_GameLogic.GameBoard.GameBoard[i, j].Color == eButtonColor.White)
                    {
                        m_Buttons[i, j].BackColor = Color.White;
                        m_Buttons[i, j].ForeColor = Color.Black;
                        m_Buttons[i, j].Text = "o";
                    }

                    if(m_GameLogic.GameBoard.GameBoard[i, j].Color == eButtonColor.Gray)
                    {
                        m_Buttons[i, j].BackColor = Color.Gray;
                        m_Buttons[i, j].ForeColor = Color.Black;
                        m_Buttons[i, j].Text = "o";
                    }

                    x += k_ButtonSquareSize + k_SpaceBetweenButtonSize;
                    m_Buttons[i, j].Click += new EventHandler(OnGameButton_Click);
                    this.Controls.Add(m_Buttons[i, j]);
                }

                x = k_BoardStartPointHorizontal;
                y += k_ButtonSquareSize + k_SpaceBetweenButtonSize;
            }

            this.AutoSize = true;
            UpDateGameBoard();
        }