/// <summary> /// Default constructor. /// </summary> public SurfaceWindow1() { InitializeComponent(); // Add handlers for window availability events AddWindowAvailabilityHandlers(); TTTboard _new = new TTTboard(board_view); board_view.Items.Add(_new.getView()); }
private void change(object sender, RoutedEventArgs e) { SurfaceButton cur_ele = (SurfaceButton)sender; string content = cur_ele.Content.ToString(); if (content.Equals("") && (!win)) // if the cell is empty, and havn't found a winner yet. { int col = Grid.GetColumn(cur_ele); int row = Grid.GetRow(cur_ele); count++; cur_ele.Content = current; current = current.Equals("X") ? "O" : "X"; perGrid[row, col] = current; // set the cell content as marked sign win = winner_Checker(current); // check winner if (win || count == 9) { TTTboard _new = new TTTboard(main_view); main_view.Items.Add(_new.getView()); } } else if (content.Equals("") && (win)) // if the cell is empty, and found a winner. { cur_ele.IsEnabled = false;// disable the cell from marking new one. return; } }