Esempio n. 1
0
        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();
        }
Esempio n. 2
0
        private void OnUpperLeft(object sender, RoutedEventArgs e)
        {
            var bounds = board.GetBounds();

            board = board.Shift(new Gomoku.Coordinate(-bounds.Minimum.Column, -bounds.Minimum.Row));
            RedrawAll();
        }
Esempio n. 3
0
 private void NewGame()
 {
     board = new Gomoku.Board();
     RedrawAll();
     WhiteMoves.Children.Clear();
     BlackMoves.Children.Clear();
     White = false;
 }
Esempio n. 4
0
        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;
                    }
                }
            }
        }
Esempio n. 5
0
        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();
        }
Esempio n. 6
0
 private void OnRotateCCW(object sender, RoutedEventArgs e)
 {
     board = board.RotateCounterClockwise();
     RedrawAll();
 }
Esempio n. 7
0
 private void OnFlipVertical(object sender, RoutedEventArgs e)
 {
     board = board.FlipVertical();
     RedrawAll();
 }
Esempio n. 8
0
 private void OnFlipHorizontal(object sender, RoutedEventArgs e)
 {
     board = board.FlipHorizontal();
     RedrawAll();
 }
Esempio n. 9
0
 private void OnShiftDown(object sender, RoutedEventArgs e)
 {
     board = board.Shift(new Gomoku.Coordinate(0, 1));
     RedrawAll();
 }