コード例 #1
0
        /// <summary>
        /// Function that is called by every button on the MainWindow representing a board square.
        /// </summary>
        /// <param name="sender">Button object of the button that was pressed</param>
        /// <param name="e"></param>
        private void Square_Pressed(object sender, RoutedEventArgs e)
        {
            Button        Sender           = (System.Windows.Controls.Button)sender;
            string        squarePressedUid = Sender.Uid;
            BoardLocation locationPressed;

            locationPressed = new BoardLocation(squarePressedUid[0], squarePressedUid[1]);

            if (turn == pieceColour.dark)
            {
                locationPressed.rotate180Degrees();
            }

            BoardSquare squarePressed = gameBoard.getSquare(locationPressed);

            if (this.liftedPiece == null)
            {
                attemptToLiftPiece(squarePressed);
            }
            else if (this.liftedPiece != null)
            {
                attemptToPlacePiece(squarePressed);
            }
        }