Ejemplo n.º 1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Button b = (Button)sender;

            //var vm = FindResource("vm") as ChessViewModel;
            //var hist = vm.history();
            //int h = hist.Count - 1;

            ChessMove cm;

            if (b.Tag.Equals("k"))
            {
                cm = new ChessMove(hist.EndPosition, new BoardPosition(-1, (int)ChessPieceType.Knight), ChessMoveType.PawnPromote);
            }
            else if (b.Tag.Equals("b"))
            {
                cm = new ChessMove(hist.EndPosition, new BoardPosition(-1, (int)ChessPieceType.Bishop), ChessMoveType.PawnPromote);
            }
            else if (b.Tag.Equals("r"))
            {
                cm = new ChessMove(hist.EndPosition, new BoardPosition(-1, (int)ChessPieceType.RookPawn), ChessMoveType.PawnPromote);
            }
            else //if (b.Tag.Equals("q"))
            {
                cm = new ChessMove(hist.EndPosition, new BoardPosition(-1, (int)ChessPieceType.Queen), ChessMoveType.PawnPromote);
            }
            vm.ApplyMove(cm);

            this.Close();
        }
Ejemplo n.º 2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Button    b = (Button)sender;
            ChessMove cm;

            if (b.Tag.Equals("k"))
            {
                cm = new ChessMove(hist.EndPosition, new BoardPosition(-1, (int)ChessPieceType.Knight), ChessMoveType.PawnPromote);
            }
            else if (b.Tag.Equals("b"))
            {
                cm = new ChessMove(hist.EndPosition, new BoardPosition(-1, (int)ChessPieceType.Bishop), ChessMoveType.PawnPromote);
            }
            else if (b.Tag.Equals("r"))
            {
                cm = new ChessMove(hist.EndPosition, new BoardPosition(-1, (int)ChessPieceType.RookPawn), ChessMoveType.PawnPromote);
            }
            else //if (b.Tag.Equals("q"))
            {
                cm = new ChessMove(hist.EndPosition, new BoardPosition(-1, (int)ChessPieceType.Queen), ChessMoveType.PawnPromote);
            }
            vm.ApplyMove(cm);

            this.Close();
        }