private void refresh() { if (isMoved) { flowLayoutPanel1.Enabled = false; } else { flowLayoutPanel1.Enabled = true; } for (int i = 0; i < TicTacToeController.DESK_SIZE; i++) { for (int j = 0; j < TicTacToeController.DESK_SIZE; j++) { foreach (Control control in flowLayoutPanel1.Controls) { Button temp = (Button)control; if (((int[])temp.Tag)[0] == i && ((int[])temp.Tag)[1] == j) { if (TicTacToeController.desk[i, j] != 0) { temp.Enabled = false; } if (TicTacToeController.desk[i, j] == 1) { temp.BackColor = Color.Red; temp.Text = "X"; } if (TicTacToeController.desk[i, j] == 2) { temp.BackColor = Color.Green; temp.Text = "O"; } } } } } if (!TicTacToeController.canMove() || labelTime.Text.Equals("0") || TicTacToeController.winnerNumber != 0) { aTimer.Stop(); if (TicTacToeController.winnerNumber == 1) { txtStatus.Invoke((MethodInvoker) delegate() { txtStatus.Text = "BẠN ĐÃ THUA"; }); } else if (TicTacToeController.winnerNumber == 2) { txtStatus.Invoke((MethodInvoker) delegate() { txtStatus.Text = "BẠN ĐÃ THẮNG"; }); } DialogResult rs = MessageBox.Show("Bạn có muốn chơi lại ko?", "Chơi tiếp?", MessageBoxButtons.YesNo); if (rs == DialogResult.Yes) { send("!endgame"); send("!newgame"); TicTacToeController.newGame(); newDesk(); } // return; } }
private void refresh() { if (isMoved) { flowLayoutPanel1.Enabled = false; } else { flowLayoutPanel1.Enabled = true; } for (int i = 0; i < TicTacToeController.DESK_SIZE; i++) { for (int j = 0; j < TicTacToeController.DESK_SIZE; j++) { foreach (Control control in flowLayoutPanel1.Controls) { Button temp = (Button)control; if (((int[])temp.Tag)[0] == i && ((int[])temp.Tag)[1] == j) { if (TicTacToeController.desk[i, j] != 0) { temp.Enabled = false; } if (TicTacToeController.desk[i, j] == 1) { temp.BackColor = Color.Red; temp.Text = "X"; } if (TicTacToeController.desk[i, j] == 2) { temp.BackColor = Color.Green; temp.Text = "O"; } } } } } if (!TicTacToeController.canMove() || endGame || TicTacToeController.winnerNumber != 0) { TicTacToeController.newGame(); endGame = false; aTimer.Stop(); if (newGame) { this.Invoke((MethodInvoker) delegate() { this.Enabled = true; }); newGame = false; newDesk(); } // return; } }