public void OnBoardClick(object sender, EventArgs e) { OthelloPictureBox temp = sender as OthelloPictureBox; if (m_Game.AvailableMoves[temp.Row, temp.Column] == true) { square_Click(temp.SquareLocation); } }
private void refreshBoard() { foreach (Control control in Controls) { OthelloPictureBox square = control as OthelloPictureBox; if (square != null) { square.Refresh(); } } }
private void restartBoard() { foreach (Control square in Controls) { OthelloPictureBox temp = square as OthelloPictureBox; if (m_Game.GameBoard.Matrix[temp.Row, temp.Column].Color != ' ') { temp.Image = m_Game.GameBoard.Matrix[temp.Row, temp.Column].Color == 'X' ? Properties.Resources.Black : Properties.Resources.White; } else { temp.Image = null; } } }
private void initializeBoard(int i_BoardSize) { int top = this.Score.Height + k_FormMargin; int left = k_FormMargin; for (int Row = 0; Row < i_BoardSize; Row++) { for (int Column = 0; Column < i_BoardSize; Column++) { OthelloPictureBox BoardSquare = new OthelloPictureBox(); BoardSquare.BackColor = System.Drawing.Color.MediumSeaGreen; BoardSquare.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; BoardSquare.Location = new System.Drawing.Point(left, top); BoardSquare.Name = string.Format("Square{0}", (Row * m_GameSettings.BoardSize) + Column); BoardSquare.Size = new System.Drawing.Size(k_SquareSize, k_SquareSize); BoardSquare.TabIndex = (Row * m_GameSettings.BoardSize) + Column; BoardSquare.TabStop = false; BoardSquare.InitLocation(m_GameSettings.BoardSize); BoardSquare.Click += OnBoardClick; m_Game.m_FlipOccured += BoardSquare.OnFlip; BoardSquare.m_Fliped += this.OnFlip; if (m_Game.GameBoard.Matrix[Row, Column].Color == k_BlackCoinValueInLogic) { BoardSquare.Image = Properties.Resources.Black; } else if (m_Game.GameBoard.Matrix[Row, Column].Color == k_WhiteCoinValueInLogic) { BoardSquare.Image = Properties.Resources.White; } Controls.Add(BoardSquare); left += k_SquareSize + k_SquaresDistance; } left = k_FormMargin; top += k_SquareSize + k_SquaresDistance; } this.ClientSize = new System.Drawing.Size(top - this.Score.Height + k_FormMargin - k_SquaresDistance, top + k_FormMargin - k_SquaresDistance); this.Score.Location = new System.Drawing.Point(this.Width / 2 - this.Score.Width / 2 - k_FormMargin + k_SquaresDistance, 5); this.White.Location = new System.Drawing.Point(this.ClientSize.Width - this.White.Width - k_FormMargin, k_FormMargin); }
private void updateAvailableMoves() { foreach (Control square in Controls) { OthelloPictureBox temp = square as OthelloPictureBox; if (temp != null) { if (m_Game.AvailableMoves[temp.Row, temp.Column] == true) { temp.Image = Properties.Resources.Available; } else if (m_Game.GameBoard.Matrix[temp.Row, temp.Column].Color != k_BlackCoinValueInLogic && m_Game.GameBoard.Matrix[temp.Row, temp.Column].Color != k_WhiteCoinValueInLogic) { temp.Image = null; } } } }