Exemplo n.º 1
0
        /// <summary>
        /// Accept the content of the form
        /// </summary>
        /// <param name="sender">   Sender object</param>
        /// <param name="e">        Event argument</param>
        private void butOk_Click(object sender, RoutedEventArgs e)
        {
            string    strGame;
            string    strError;
            PgnParser parser;
            PgnGame   pgnGame;
            int       iSkip;
            int       iTruncated;

            strGame = textBox1.Text;
            if (String.IsNullOrEmpty(strGame))
            {
                MessageBox.Show("No PGN text has been pasted.");
            }
            else
            {
                parser = new PgnParser(false);
                parser.InitFromString(strGame);
                if (!parser.ParseSingle(false /*bIgnoreMoveListIfFen*/,
                                        out iSkip,
                                        out iTruncated,
                                        out pgnGame,
                                        out strError))
                {
                    MessageBox.Show("The specified board is invalid - " + (strError ?? ""));
                }
                else if (iSkip != 0)
                {
                    MessageBox.Show("The game is incomplete. Paste another game.");
                }
                else if (iTruncated != 0)
                {
                    MessageBox.Show("The selected game includes an unsupported pawn promotion (only pawn promotion to queen is supported).");
                }
                else if (pgnGame.MoveExtList.Count == 0 && pgnGame.StartingChessBoard == null)
                {
                    MessageBox.Show("Game is empty.");
                }
                else
                {
                    MoveList           = pgnGame.MoveExtList;
                    StartingChessBoard = pgnGame.StartingChessBoard;
                    StartingColor      = pgnGame.StartingColor;
                    WhitePlayerName    = pgnGame.WhitePlayer;
                    BlackPlayerName    = pgnGame.BlackPlayer;
                    WhitePlayerType    = pgnGame.WhiteType;
                    BlackPlayerType    = pgnGame.BlackType;
                    WhiteTimer         = pgnGame.WhiteSpan;
                    BlackTimer         = pgnGame.BlackSpan;
                    DialogResult       = true;
                    Close();
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Called when a game is selected
        /// </summary>
        /// <param name="bNoMove">  true to ignore the move list</param>
        private void GameSelected(bool bNoMove)
        {
            string         strGame;
            PgnParser      parser;
            PgnGame        pgnGame;
            List <MoveExt> listGame;
            string         strError;
            int            iSkip;
            int            iTruncated;

            strGame = GetSelectedGame();
            if (strGame != null)
            {
                listGame = new List <MoveExt>(256);
                parser   = new PgnParser(false);
                parser.InitFromString(strGame);
                if (!parser.ParseSingle(bNoMove,
                                        out iSkip,
                                        out iTruncated,
                                        out pgnGame,
                                        out strError))
                {
                    MessageBox.Show("The specified board is invalid - " + (strError ?? ""));
                }
                else if (iSkip != 0)
                {
                    MessageBox.Show("The game is incomplete. Select another game.");
                }
                else if (iTruncated != 0)
                {
                    MessageBox.Show("The selected game includes an unsupported pawn promotion (only pawn promotion to queen is supported).");
                }
                else if (pgnGame.MoveExtList.Count == 0 && pgnGame.StartingChessBoard == null)
                {
                    MessageBox.Show("Game is empty.");
                }
                else
                {
                    StartingChessBoard = pgnGame.StartingChessBoard;
                    StartingColor      = pgnGame.StartingColor;
                    WhitePlayerName    = pgnGame.WhitePlayer;
                    BlackPlayerName    = pgnGame.BlackPlayer;
                    WhitePlayerType    = pgnGame.WhiteType;
                    BlackPlayerType    = pgnGame.BlackType;
                    WhiteTimer         = pgnGame.WhiteSpan;
                    BlackTimer         = pgnGame.BlackSpan;
                    MoveList           = pgnGame.MoveExtList;
                    DialogResult       = true;
                    Close();
                }
            }
        }
        private void GameSelected(bool bNoMove)
        {
            string                      strGame;
            PgnParser                   parser;
            List<ChessBoard.MovePosS>   listGame;
            int                         iSkip;
            int                         iTruncated;
            ChessBoard                  chessBoard;
            ChessBoard.PlayerColorE     eStartingColor;
            string                      strWhitePlayerName;
            string                      strBlackPlayerName;
            PgnParser.PlayerTypeE       eWhiteType;
            PgnParser.PlayerTypeE       eBlackType;
            TimeSpan                    spanWhitePlayer;
            TimeSpan                    spanBlackPlayer;

            strGame = GetSelectedGame();
            if (strGame != null) {
                listGame    = new List<ChessBoard.MovePosS>(256);
                parser      = new PgnParser(false);
                if (!parser.ParseSingle(strGame,
                                        bNoMove,
                                        listGame,
                                        out iSkip,
                                        out iTruncated,
                                        out chessBoard,
                                        out eStartingColor,
                                        out strWhitePlayerName,
                                        out strBlackPlayerName,
                                        out eWhiteType,
                                        out eBlackType,
                                        out spanWhitePlayer,
                                        out spanBlackPlayer)) {
                    MessageBox.Show("The specified board is invalid.");
                } else if (iSkip != 0) {
                    MessageBox.Show("The game is incomplete. Select another game.");
                } else if (iTruncated != 0) {
                    MessageBox.Show("The selected game includes an unsupported pawn promotion (only pawn promotion to queen is supported).");
                } else if (listGame.Count == 0 && chessBoard == null) {
                    MessageBox.Show("Game is empty.");
                } else {
                    StartingChessBoard  = chessBoard;
                    StartingColor       = eStartingColor;
                    WhitePlayerName     = strWhitePlayerName;
                    BlackPlayerName     = strBlackPlayerName;
                    WhitePlayerType     = eWhiteType;
                    BlackPlayerType     = eBlackType;
                    WhiteTimer          = spanWhitePlayer;
                    BlackTimer          = spanBlackPlayer;
                    MoveList            = listGame;
                    DialogResult        = true;
                    Close();
                }
            }
        }
Exemplo n.º 4
0
        private void GameSelected(bool bNoMove)
        {
            string    strGame;
            PgnParser parser;
            List <ChessBoard.MovePosS> listGame;
            int        iSkip;
            int        iTruncated;
            ChessBoard chessBoard;

            ChessBoard.PlayerColorE eStartingColor;
            string strWhitePlayerName;
            string strBlackPlayerName;

            PgnParser.PlayerTypeE eWhiteType;
            PgnParser.PlayerTypeE eBlackType;
            TimeSpan spanWhitePlayer;
            TimeSpan spanBlackPlayer;

            strGame = GetSelectedGame();
            if (strGame != null)
            {
                listGame = new List <ChessBoard.MovePosS>(256);
                parser   = new PgnParser(false);
                if (!parser.ParseSingle(strGame,
                                        bNoMove,
                                        listGame,
                                        out iSkip,
                                        out iTruncated,
                                        out chessBoard,
                                        out eStartingColor,
                                        out strWhitePlayerName,
                                        out strBlackPlayerName,
                                        out eWhiteType,
                                        out eBlackType,
                                        out spanWhitePlayer,
                                        out spanBlackPlayer))
                {
                    MessageBox.Show("The specified board is invalid.");
                }
                else if (iSkip != 0)
                {
                    MessageBox.Show("The game is incomplete. Select another game.");
                }
                else if (iTruncated != 0)
                {
                    MessageBox.Show("The selected game includes an unsupported pawn promotion (only pawn promotion to queen is supported).");
                }
                else if (listGame.Count == 0 && chessBoard == null)
                {
                    MessageBox.Show("Game is empty.");
                }
                else
                {
                    StartingChessBoard = chessBoard;
                    StartingColor      = eStartingColor;
                    WhitePlayerName    = strWhitePlayerName;
                    BlackPlayerName    = strBlackPlayerName;
                    WhitePlayerType    = eWhiteType;
                    BlackPlayerType    = eBlackType;
                    WhiteTimer         = spanWhitePlayer;
                    BlackTimer         = spanBlackPlayer;
                    MoveList           = listGame;
                    DialogResult       = true;
                    Close();
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Accept the content of the form
        /// </summary>
        /// <param name="sender">   Sender object</param>
        /// <param name="e">        Event argument</param>
        private void butOk_Click(object sender, RoutedEventArgs e)
        {
            string    strGame;
            PgnParser parser;
            List <ChessBoard.MovePosS> listGame;
            int        iSkip;
            int        iTruncated;
            ChessBoard chessBoardStarting;

            ChessBoard.PlayerColorE eStartingColor;
            string strWhitePlayerName;
            string strBlackPlayerName;

            PgnParser.PlayerTypeE eWhiteType;
            PgnParser.PlayerTypeE eBlackType;
            TimeSpan spanWhitePlayer;
            TimeSpan spanBlackPlayer;

            strGame = textBox1.Text;
            if (String.IsNullOrEmpty(strGame))
            {
                MessageBox.Show("No PGN text has been pasted.");
            }
            else
            {
                listGame = new List <ChessBoard.MovePosS>(256);
                parser   = new PgnParser(false);
                if (!parser.ParseSingle(strGame,
                                        false,
                                        listGame,
                                        out iSkip,
                                        out iTruncated,
                                        out chessBoardStarting,
                                        out eStartingColor,
                                        out strWhitePlayerName,
                                        out strBlackPlayerName,
                                        out eWhiteType,
                                        out eBlackType,
                                        out spanWhitePlayer,
                                        out spanBlackPlayer))
                {
                    MessageBox.Show("The specified board is invalid.");
                }
                else if (iSkip != 0)
                {
                    MessageBox.Show("The game is incomplete. Paste another game.");
                }
                else if (iTruncated != 0)
                {
                    MessageBox.Show("The selected game includes an unsupported pawn promotion (only pawn promotion to queen is supported).");
                }
                else if (listGame.Count == 0 && chessBoardStarting == null)
                {
                    MessageBox.Show("Game is empty.");
                }
                else
                {
                    MoveList           = listGame;
                    StartingChessBoard = chessBoardStarting;
                    StartingColor      = eStartingColor;
                    WhitePlayerName    = strWhitePlayerName;
                    BlackPlayerName    = strBlackPlayerName;
                    WhitePlayerType    = eWhiteType;
                    BlackPlayerType    = eBlackType;
                    WhiteTimer         = spanWhitePlayer;
                    BlackTimer         = spanBlackPlayer;
                    DialogResult       = true;
                    Close();
                }
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Accept the content of the form
        /// </summary>
        /// <param name="sender">   Sender object</param>
        /// <param name="e">        Event argument</param>
        private void butOk_Click(object sender, RoutedEventArgs e)
        {
            string                      strGame;
            PgnParser                   parser;
            List<ChessBoard.MovePosS>   listGame;
            int                         iSkip;
            int                         iTruncated;
            ChessBoard                  chessBoardStarting;
            ChessBoard.PlayerColorE     eStartingColor;
            string                      strWhitePlayerName;
            string                      strBlackPlayerName;
            PgnParser.PlayerTypeE       eWhiteType;
            PgnParser.PlayerTypeE       eBlackType;
            TimeSpan                    spanWhitePlayer;
            TimeSpan                    spanBlackPlayer;

            strGame = textBox1.Text;
            if (String.IsNullOrEmpty(strGame)) {
                MessageBox.Show("No PGN text has been pasted.");
            } else {
                listGame    = new List<ChessBoard.MovePosS>(256);
                parser      = new PgnParser(false);
                if (!parser.ParseSingle(strGame,
                                        false,
                                        listGame,
                                        out iSkip,
                                        out iTruncated,
                                        out chessBoardStarting,
                                        out eStartingColor,
                                        out strWhitePlayerName,
                                        out strBlackPlayerName,
                                        out eWhiteType,
                                        out eBlackType,
                                        out spanWhitePlayer,
                                        out spanBlackPlayer)) {
                    MessageBox.Show("The specified board is invalid.");
                } else if (iSkip != 0) {
                    MessageBox.Show("The game is incomplete. Paste another game.");
                } else if (iTruncated != 0) {
                    MessageBox.Show("The selected game includes an unsupported pawn promotion (only pawn promotion to queen is supported).");
                } else if (listGame.Count == 0 && chessBoardStarting == null) {
                    MessageBox.Show("Game is empty.");
                } else {
                    MoveList            = listGame;
                    StartingChessBoard  = chessBoardStarting;
                    StartingColor       = eStartingColor;
                    WhitePlayerName     = strWhitePlayerName;
                    BlackPlayerName     = strBlackPlayerName;
                    WhitePlayerType     = eWhiteType;
                    BlackPlayerType     = eBlackType;
                    WhiteTimer          = spanWhitePlayer;
                    BlackTimer          = spanBlackPlayer;
                    DialogResult        = true;
                    Close();
                }
            }
        }