Ejemplo n.º 1
0
        /// <summary>
        /// Build a list of puzzles using the PGN find in resource
        /// </summary>
        private void BuildPuzzleList()
        {
            string strPGN;
            int    iSkippedCount;


            strPGN = LoadPGN();
            m_pgnParser.InitFromString(strPGN);
            m_listPGNGame = m_pgnParser.GetAllRawPGN(true /*bAttrList*/, false /*bMove*/, out iSkippedCount);
        }
Ejemplo n.º 2
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();
                }
            }
        }
Ejemplo n.º 3
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();
                }
            }
        }