static public void OpenWordProvider(string link, string word) { if (word.Length > 1) { word = HebrewAlphabet.SetFinal(word, true); } SystemManager.TryCatchManage(ShowExceptionMode.OnlyMessage, () => { var wordAnalyzed = RemoveNumberingAndDiacritics(word); var items = wordAnalyzed.Word.Split(' '); if (!wordAnalyzed.IsUnicode) { items = items.Select(w => HebrewAlphabet.ToUnicode(HebrewAlphabet.SetFinal(w, true))).ToArray(); } foreach (string item in items) { if (item.Length > 0) { string url = link.Replace("%CUSTOM%", HebrewGlobals.GetCustomWebSearchPattern?.Invoke() ?? string.Empty) .Replace("%WORD%", item) .Replace("%FIRSTLETTER%", item[0].ToString()); SystemManager.RunShell(url, item); Thread.Sleep(250); } } }); }
private void CreateSearchResults() { if (SelectSearchInBook.SelectedItem is null) { return; } ClearSearchResults(); // bool checkWordHebrew(WordRow row) => row.Hebrew.Contains(SearchWord1) || row.Hebrew.Contains(SearchWord2); bool checkTranslatedAll(VerseRow verse) => verse.HasTranslation; bool checkTranslatedAllFully(VerseRow verse) => verse.IsFullyTranslated; bool checkTranslatedAllPartially(VerseRow verse) => verse.IsPartiallyTranslated; bool checkTranslatedAllUntranslated(VerseRow verse) => !verse.HasTranslation; bool checkWordTranslation(WordRow row) => checkWordNoHebrew(row.Translation.ToLower().RemoveDiacritics()); bool checkVerseComment(VerseRow row) => checkWordNoHebrew(row.Comment.ToLower().RemoveDiacritics()); bool checkWordNoHebrew(string str) => SearchWord1.RawContains(SearchSeparatorString) ? SearchWord1.Split(SearchSeparatorChar).Select(item => item.Trim()).Any(item => item.Length >= 2 && str.RawContains(item)) : str.RawContains(SearchWord1); // if (SelectSearchType.SelectedTab == SelectSearchTypeHebrew) { SearchWord1 = EditSearchWord.TextBox.Text; SearchWord2 = HebrewAlphabet.SetFinal(SearchWord1, true); CheckWord = checkWordHebrew; } else if (SelectSearchType.SelectedTab == SelectSearchTypeTranslation) { SearchWord1 = EditSearchTranslation.Text.ToLower().RemoveDiacritics(); if (SelectSearchTranslationOnlyTranslations.Checked) { CheckWord = checkWordTranslation; CheckVerse = null; } else if (SelectSearchTranslationIncludeComments.Checked) { CheckWord = checkWordTranslation; CheckVerse = checkVerseComment; } else if (SelectSearchTranslationOnlyComments.Checked) { CheckWord = null; CheckVerse = checkVerseComment; } else { throw new AdvNotImplementedException(nameof(SelectSearchTypeTranslation)); } } else if (SelectSearchType.SelectedTab == SelectSearchTypeVerses) { if (SelectSearchRequestAllTranslated.Checked) { CheckVerse = checkTranslatedAll; } if (SelectSearchRequestAllFullyTranslated.Checked) { CheckVerse = checkTranslatedAllFully; } if (SelectSearchRequestAllPartiallyTranslated.Checked) { CheckVerse = checkTranslatedAllPartially; } if (SelectSearchRequestAllUntranslated.Checked) { CheckVerse = checkTranslatedAllUntranslated; } } else { throw new AdvNotImplementedException(SelectSearchType.SelectedTab.Text); } // int bookSelected = Settings.SearchInBookSelectedNumber; bool isBookSelected(int index) { return((Settings.SearchInTorah && index <= BooksBounds.Torah.Max) || (Settings.SearchInNeviim && index >= BooksBounds.Neviim.Min && index <= BooksBounds.Neviim.Max) || (Settings.SearchInKetouvim && index >= BooksBounds.Ketouvim.Min) || (index == bookSelected && !Settings.SearchInTorah && !Settings.SearchInNeviim && !Settings.SearchInKetouvim)); } // IEnumerable <ReferenceItem> createSearch(Func <VerseRow, WordRow, bool> check) => from book in ApplicationDatabase.Instance.Books from chapter in book.Chapters from verse in chapter.Verses from word in verse.Words where isBookSelected(book.Number) && chapter.BookID == book.ID && verse.ChapterID == chapter.ID && word.VerseID == verse.ID && check(verse, word) select new ReferenceItem(book, chapter, verse); // if (SearchWord1.Length >= 2 && CheckWord is not null && CheckVerse is not null) { SearchResults = createSearch((verse, word) => CheckWord(word) || CheckVerse(verse)); }