当前位置: 首页>>代码示例>>C#>>正文


C# IMainWindow.SearchBoxSuggestions方法代码示例

本文整理汇总了C#中IMainWindow.SearchBoxSuggestions方法的典型用法代码示例。如果您正苦于以下问题:C# IMainWindow.SearchBoxSuggestions方法的具体用法?C# IMainWindow.SearchBoxSuggestions怎么用?C# IMainWindow.SearchBoxSuggestions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IMainWindow的用法示例。


在下文中一共展示了IMainWindow.SearchBoxSuggestions方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: searchString

        public void searchString(string originalSearch, BackEndInitializer _backend, IMainWindow _view)
        {
            PresenterFolder.ReferenceList referenceList = new PresenterFolder.ReferenceList(); // list of references to display
            List<string> suggestionList = new List<string>(); // list of what user might want to type next
            string searchPhrase = "";

            string[] text = originalSearch.Replace(";", " ; ").Split(' ');  // put to space seperated array and seperate the ;'s
            text = PreSearchStringBuilder.FixBookNumberTitlesInSearchArray(text);
            text = PreSearchStringBuilder.CombineHyphenAndDashInArray(text);

            bool foundBook = false; // keeps track of whether this is part way into a reference ie. just found the a book name
            string lastFoundBook = "";
            for (int i = 0; i < text.Count(); i++)
            {
                if (text[i] == ";") // end of reference
                {
                    foundBook = false;
                }
                // look for a whole book name
                else if (!foundBook && _index.ContainsBook(text[i]))
                {
                    foundWholeBookName( ref lastFoundBook, ref text, ref i, ref suggestionList, ref _view, ref originalSearch, ref referenceList);
                    foundBook = true;
                }
                // look for -
                else if (text[i] == "-") // found a book range reference
                {
                    referenceList.CurrentReference.Range = true;
                    foundBook = false;
                }
                // look for part of a book name if last item in text[]
                else if (!foundBook)
                {
                    suggestionList = _backend.CurrentBooks.ToList().StartsWithInList(text[i]);
                    if (suggestionList != null && i == text.Count() - 1) // found part of a book name
                    {
                        _view.SearchBoxSuggestions(suggestionList, originalSearch);
                    }
                    // not a refernce so do a search of the index
                    else
                    {
                        if (i >= text.Count() - 1 && !_backend.WordExists(text[i].ToLower())) // last term
                        {
                            _view.SearchBoxSuggestions(_backend.WordsThatStartWith(text[i].ToLower()),
                                originalSearch);
                        }
                        else
                        {
                            searchPhrase += text[i].ToLower() + " ";
                        }
                    }
                }
                // look for reference numbers
                else if (foundBook)
                {
                    foundBook = false;
                    int chapNumber;
                    if ((int.TryParse(text[i], out chapNumber))) // just a number
                    {
                        if (referenceList.CurrentReference.StartChapter == null) // check if start chap is empty
                        {
                            referenceList.CurrentReference.StartChapter = chapNumber;
                        }
                        else // start chap already has something in it
                        {
                            referenceList.CurrentReference.EndChapter = chapNumber;
                        }
                    }
                    else if (text[i].Contains(':') && !(text[i].Contains('-'))) // just :
                    {
                        if (text[i].EndsWith(":")) // only chap listed return possible verses
                        {
                            // return a list of possible verses for indicated chapter
                            suggestionList = _index.GetPossibleVerses(lastFoundBook, text[i].Substring(0, text[i].Length - 1));
                            suggestionList = suggestionList.AddPrefixToList(originalSearch);
                            _view.SearchBoxSuggestions(suggestionList, originalSearch);
                        }
                        else // chap & verse so store full refence
                        {
                            string[] temp = text[i].Split(':');
                            if (referenceList.CurrentReference.StartChapter == null)
                            {
                                referenceList.CurrentReference.StartChapter = Convert.ToInt32(temp[0]);
                                referenceList.CurrentReference.StartVerse = Convert.ToInt32(temp[1]);
                            }
                            else
                            {
                                referenceList.CurrentReference.EndChapter = Convert.ToInt32(temp[0]);
                                referenceList.CurrentReference.EndVerse = Convert.ToInt32(temp[1]);
                            }
                        }
                    }// end -- // just :
                    else if (text[i].Contains('-') && !(text[i].Contains(':'))) // just - so dealing with chapters only
                    {
                        string[] temp = text[i].Split('-');
                        referenceList.CurrentReference.StartChapter = Convert.ToInt16(temp[0]);
                        referenceList.CurrentReference.EndChapter = Convert.ToInt16(temp[1]);
                        referenceList.CurrentReference.Range = true;
                    } // end  --  // just - so dealing with chapters only
                } // end --// look for reference numbers
//.........这里部分代码省略.........
开发者ID:sorvis,项目名称:Fast-Script,代码行数:101,代码来源:searchParsing.cs

示例2: foundWholeBookName

        private void foundWholeBookName(ref string lastFoundBook, ref string[] text, 
            ref int i, ref List<string> suggestionList,  ref IMainWindow _view,
            ref string originalSearch, ref ReferenceList refList)
        {
            lastFoundBook = text[i].CapitalizeWord();
            if (i < text.Count() - 1) //something after book
            {

            }
            else // nothing after book
            {
                // return a list of possible chapters for the book
                suggestionList = _index.GetPossibleChapters(lastFoundBook).AddPrefixToList(originalSearch + " ");
                _view.SearchBoxSuggestions(suggestionList, originalSearch);
            }

            // save book reference
            if (refList.CurrentReference == null || refList.CurrentReference.Range == false)
            {
                refList.AddReference(lastFoundBook);
            }
            else // if expecting another book reference
            {
                refList.CurrentReference.EndBook = lastFoundBook;
                refList.AddReference(null);
            }

            //foundBook(text, originalSearch);
        }
开发者ID:sorvis,项目名称:Fast-Script,代码行数:29,代码来源:searchParsing.cs


注:本文中的IMainWindow.SearchBoxSuggestions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。