コード例 #1
0
        private void SendTelnetWordList(TelnetServerCommandEventArgs pEventArgs, string pSearchText)
        {
            bool tmpSearchAll   = false;
            bool tmpDoneListing = false;

            int tmpMatchCount = 0;

            MutiTimeSpan tmpSearchTimer = new MutiTimeSpan();

            if (pSearchText.ToUpper() == "ALL")
            {
                tmpSearchAll = true;
            }

            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);

                if (tmpSearchAll)
                {
                    _WordList.MoveFirst();
                }
                else
                {
                    tmpDoneListing = !_WordList.FindFirstByWord(pSearchText);
                }

                while (!tmpDoneListing)
                {
                    //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
                    tmpDoneListing = _WordList.EOL;

                    if (tmpSearchAll)
                    {
                        _WordList.MoveNext();
                    }
                    else
                    {
                        //This is to not display the last node if it isn't a match and we hit the EOL
                        tmpDoneListing = !_WordList.FindNextByWord(pSearchText);
                    }
                }

                _TelnetServer.SendData("==========================================================================-----", pEventArgs.Socket);
                _TelnetServer.SendLineFeed(pEventArgs.Socket);
                _TelnetServer.SendData(tmpMatchCount.ToString() + " Word(s) Matched the Pattern " + pSearchText, 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);
            }
        }