using System; using System.Linq; using System.Windows; using System.Windows.Controls; using System.Windows.Media; namespace TicTacToe { /// /// Interaction logic for MainWindow.xaml /// public partial class MainWindow : Window { #region Private Members /// /// Holds the current results of cells in the active game /// private MarkType[] mResults; /// /// True if it is player 1's turn (X) or player 2's turn (O) /// private bool mPlayer1Turn; /// /// True if the game has ended /// private bool mGameEnded; #endregion #region Constructor /// /// Default constructor /// public MainWindow() { InitializeComponent(); NewGame(); } #endregion /// /// Starts a new game and clears all values back to the start /// private void NewGame() { // Create a new blank array of free cells mResults = new MarkType[9]; for (var i = 0; i < mResults.Length; i++) mResults[i] = MarkType.Free; // Make sure Player 1 starts the game mPlayer1Turn = true; // Interate every button on the grid... Container.Children.Cast