コード例 #1
0
        /// <summary>
        /// Initialize the form with the content of the PGN file
        /// </summary>
        /// <param name="strFileName">  PGN file name</param>
        /// <returns>
        /// true if at least one game has been found.
        /// </returns>
        public bool InitForm(string strFileName)
        {
            bool   bRetVal;
            int    iIndex;
            string strDesc;
            int    iSkippedCount;

            bRetVal = m_pgnParser.InitFromFile(strFileName);
            if (bRetVal)
            {
                m_pgnGames = m_pgnParser.GetAllRawPGN(true /*bAttrList*/, false /*bMoveList*/, out iSkippedCount);
                if (m_pgnGames.Count < 1)
                {
                    MessageBox.Show("No games found in the PGN File '" + strFileName + "'");
                    bRetVal = false;
                }
                else
                {
                    iIndex = 0;
                    foreach (PgnGame pgnGame in m_pgnGames)
                    {
                        strDesc = (iIndex + 1).ToString().PadLeft(5, '0') + " - " + GetGameDesc(pgnGame);
                        listBoxGames.Items.Add(new PGNGameDescItem(strDesc, iIndex));
                        iIndex++;
                    }
                    listBoxGames.SelectedIndex = 0;
                    bRetVal = true;
                }
            }
            return(bRetVal);
        }
コード例 #2
0
        /// <summary>
        /// Load the PGN games from the specified file
        /// </summary>
        /// <returns></returns>
        private bool LoadPGN()
        {
            bool bRetVal;

            try {
                m_iTotalSkipped   = 0;
                m_iTotalTruncated = 0;
                m_strError        = null;
                m_ePhase          = ParsingPhaseE.None;
                m_pgnParser       = new PgnParser(false /*bDiagnose*/);
                bRetVal           = m_pgnParser.InitFromFile(m_strFileName);
                if (bRetVal)
                {
                    m_pgnGames = m_pgnParser.GetAllRawPGN(true /*bAttrList*/,
                                                          false /*bMoveList*/,
                                                          out m_iTotalSkipped,
                                                          (cookie, ePhase, iFileIndex, iFileCount, strFileName, iGameProcessed, iGameCount) => { ProgressCallBack(cookie, ePhase, iFileIndex, iFileCount, strFileName, iGameProcessed, iGameCount); },
                                                          this);
                    bRetVal = m_pgnGames != null;
                }
            } catch (System.Exception ex) {
                MessageBox.Show(ex.Message);
                bRetVal = false;
            }
            m_bResult = bRetVal;
            ProgressCallBack(this, ParsingPhaseE.Finished, 0, 0, null, 0, 0);
            return(bRetVal);
        }