Exemple #1
0
        /// <summary>
        /// OK button handler
        /// </summary>
        /// <param name="sender">Ignored</param>
        /// <param name="e">Ignored</param>
        private void buttonOk_Click(object sender, EventArgs e)
        {
            // Capture the elements needed for the game
            // 1] Player Color
            PieceColor  playerColor  = PieceColor.White;
            RadioButton playerButton = RadioButtonHelper.GetCheckedRadio(groupBoxPlayerColor);

            // There are only 2 options, so change if it's black
            if (playerButton == radioButtonBlack)
            {
                playerColor = PieceColor.Black;
            }

            // 2] Think time for chess engine
            int engineThinkTime = (int)numericUpDownThinkTime.Value;

            newGameInfo = new NewGameInfo(playerColor, engineThinkTime);

            // 3] Optional FEN
            if (dialogType == NewGameType.PositionalFEN)
            {
                newGameInfo.FEN = textBoxFEN.Text;
            }
            Close();
        }
Exemple #2
0
        /// <summary>
        /// Ok button click handler
        /// </summary>
        /// <param name="sender">Ignored</param>
        /// <param name="e">Ignored</param>
        private void buttonOk_Click(object sender, EventArgs e)
        {
            // Get the checked button in the group box (only 1)
            RadioButton checkedButton = RadioButtonHelper.GetCheckedRadio(groupBoxPromotion);

            if (checkedButton == radioButtonQueen)
            {
                job = PieceClass.Queen;
            }
            else if (checkedButton == radioButtonRook)
            {
                job = PieceClass.Rook;
            }
            else if (checkedButton == radioButtonBishop)
            {
                job = PieceClass.Bishop;
            }
            else if (checkedButton == radioButtonKnight)
            {
                job = PieceClass.Knight;
            }
            else
            {
                throw new ArgumentOutOfRangeException();
            }

            // Close the form, selection has been made
            Close();
        }