//Searches the dictionary to find the highlighted word public DictionaryItem SearchWordObject() { try { //If the word is found, the flag that it came from the clipboard is true; _wordFromClip = true; return(DictionaryTree.SearchReturnWord(ActiveDictionary.Dictionary.Root, _wordSearch)); } catch (NullReferenceException) { return(null); } }
//Sets the local variable _clipboardText public static void SetClipboadText() { if (HasContent()) { if (_clipboardText == "") { _clipboardText = Clipboard.GetText(TextDataFormat.Text); SetClipboardWords(); //Searches dictionary for all highlighted words Form1 form1 = new Form1(); foreach (string s in _clipboardWords) { if (DictionaryTree.HasWord(s, ActiveDictionary.Dictionary.Root)) { ActiveDictionary.ActiveSearchList.Add(DictionaryTree.SearchReturnWord(ActiveDictionary.Dictionary.Root, s)); } else { continue; } } form1.SearchStatus(Form1.StatusLabel, Form1.TextBoxSearch); ClearClipBoard(); } else { if (_wordSearch == "") { _wordSearch = Clipboard.GetText(TextDataFormat.Text); DictionaryEntry DEntryForm = new DictionaryEntry(); DEntryForm.Show(); } } } else { } }
//Calls the search methods from the DictionaryTree class //The marked string is a combinaton of the string to search plus a tag which refers to a category or word search public object Search(string MarkedSearchString, DictionaryItem DicItem) { List <DictionaryItem> CategoryItem = new List <DictionaryItem>(); DictionaryItem WordItem = new DictionaryItem(); try { string StringToSearch = MarkedSearchString.Split('/')[1]; string SearchCriteria = MarkedSearchString.Split('/')[0]; if (SearchCriteria == "(C)") { DictionaryItem dictionaryItem = new DictionaryItem(); return(CategoryItem); } else if (SearchCriteria == "(W)") { if (StringToSearch == DictionaryTree.SearchReturnWord(DicItem, StringToSearch).WordName) { WordItem = DictionaryTree.SearchReturnWord(DicItem, StringToSearch); } else { WordItem = null; } return(WordItem); } else { return(null); } } catch (IndexOutOfRangeException) { return(null); } }