本文整理汇总了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
//.........这里部分代码省略.........
示例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);
}