コード例 #1
0
        private void SendTelnetAlphaWordList(TelnetServerCommandEventArgs pEventArgs, string pSearchString)
        {
            bool tmpListingCompleted = false;

            int tmpMatchCount = 0;

            MutiTimeSpan tmpSearchTimer = new MutiTimeSpan();

            if (_WordList.Count > 0)
            {
                _TelnetServer.SendData(" Word List:", pEventArgs.Socket);
                _TelnetServer.SendLineFeed(pEventArgs.Socket);
                _TelnetServer.SendData("--- Number - Word ------------------------------- Alphagram -------------=====", pEventArgs.Socket);
                _TelnetServer.SendLineFeed(pEventArgs.Socket);

                tmpListingCompleted = !_WordList.FindFirstByAlphagram(pSearchString);

                while (!tmpListingCompleted)
                {
                    //This display function is assuming that the words are no longer than 28 characters which is safe for scrabble words
                    _TelnetServer.SendData(String.Format(" {0,8}.   {1,-32}     {2}", _WordList.CurrentItemKey, _WordList.CurrentWord, _WordList.CurrentWordAlphagram), pEventArgs.Socket);
                    _TelnetServer.SendLineFeed(pEventArgs.Socket);
                    tmpMatchCount++;

                    //Bail out of the listing if it's the end of the list
                    tmpListingCompleted = _WordList.EOL;

                    //This is to not display the last node if it isn't a match and we hit the EOL
                    tmpListingCompleted = !_WordList.FindNextByAlphagram(pSearchString);
                }

                _TelnetServer.SendData("==========================================================================-----", pEventArgs.Socket);
                _TelnetServer.SendLineFeed(pEventArgs.Socket);
                _TelnetServer.SendData(tmpMatchCount.ToString() + " Word(s) Matched the Pattern " + pSearchString, pEventArgs.Socket);
                _TelnetServer.SendLineFeed(pEventArgs.Socket);

                tmpSearchTimer.TimeStamp();

                _TelnetServer.SendData("Effective Time To Search: " + tmpSearchTimer.TimeDifference.ToString() + "ms", pEventArgs.Socket);
                _TelnetServer.SendLineFeed(pEventArgs.Socket);
            }
            else
            {
                _TelnetServer.SendData("The word list is empty.", pEventArgs.Socket);
                _TelnetServer.SendLineFeed(pEventArgs.Socket);
            }
        }