private void OnLowerRight(object sender, RoutedEventArgs e) { var bounds = board.GetBounds(); board = board.Shift(new Gomoku.Coordinate(14 - bounds.Maximum.Column, 14 - bounds.Maximum.Row)); RedrawAll(); }
private void OnUpperLeft(object sender, RoutedEventArgs e) { var bounds = board.GetBounds(); board = board.Shift(new Gomoku.Coordinate(-bounds.Minimum.Column, -bounds.Minimum.Row)); RedrawAll(); }
private void NewGame() { board = new Gomoku.Board(); RedrawAll(); WhiteMoves.Children.Clear(); BlackMoves.Children.Clear(); White = false; }
private void OnPlayCell(object sender, RoutedEventArgs e) { if (board.State == Gomoku.BoardState.InProgress) { var b = (Button)sender; int Col = int.Parse(b.Name.Substring(4, 2)); int Row = int.Parse(b.Name.Substring(6, 2)); if (board[Col, Row] == Gomoku.Stone.Empty) { if (White) { board = board.Put(new Gomoku.Coordinate(Col, Row), Gomoku.Stone.White); ((Image)b.Content).Source = ImageCache["White"]; WhiteMoves.Children.Add(new TextBlock() { Text = string.Format("{0},{1}", Col, Row) }); } else { board = board.Put(new Gomoku.Coordinate(Col, Row), Gomoku.Stone.Black); ((Image)b.Content).Source = ImageCache["Black"]; BlackMoves.Children.Add(new TextBlock() { Text = string.Format("{0},{1}", Col, Row) }); } White = !White; switch (board.State) { case Gomoku.BoardState.BlackWins: BlackMoves.Children.Add(new TextBlock() { Text = "Black wins!" }); break; case Gomoku.BoardState.WhiteWins: WhiteMoves.Children.Add(new TextBlock() { Text = "White wins!" }); break; case Gomoku.BoardState.Tie: var tb = new TextBlock() { Text = "Tie!" }; BlackMoves.Children.Add(tb); WhiteMoves.Children.Add(tb); break; } } } }
private void OnCenter(object sender, RoutedEventArgs e) { var bounds = board.GetBounds(); var right = 14 - bounds.Maximum.Column; var bottom = 14 - bounds.Maximum.Row; var avgC = (bounds.Minimum.Column + right) / 2; var avgR = (bounds.Minimum.Row + bottom) / 2; var shiftC = avgC - bounds.Minimum.Column; var shiftR = avgR - bounds.Minimum.Row; board = board.Shift(new Gomoku.Coordinate(shiftC, shiftR)); RedrawAll(); }
private void OnRotateCCW(object sender, RoutedEventArgs e) { board = board.RotateCounterClockwise(); RedrawAll(); }
private void OnFlipVertical(object sender, RoutedEventArgs e) { board = board.FlipVertical(); RedrawAll(); }
private void OnFlipHorizontal(object sender, RoutedEventArgs e) { board = board.FlipHorizontal(); RedrawAll(); }
private void OnShiftDown(object sender, RoutedEventArgs e) { board = board.Shift(new Gomoku.Coordinate(0, 1)); RedrawAll(); }