/// <summary> /// Handles the search by description completed event for the Terminology Provider Client. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="SearchByDescriptionCompletedEventArgs"/> instance containing the event data.</param> private static void TerminologyProviderClientSearchByDescriptionCompleted(object sender, SearchByDescriptionCompletedEventArgs e) { if (e.Error == null && e.Result != null && e.Result.Terms != null) { if (e.UserState != null && e.UserState is SearchState) { SearchState searchState = e.UserState as SearchState; switch (searchState.UserState) { case UserState.Normal: if (TerminologyManager.InputBoxSearchCompleted != null) { ObservableCollection <InputFieldResult> results = TerminologyManager.PrepareInputFieldResults(e.Result, false); TerminologyManager.InputBoxSearchCompleted(null, new InputFieldSearchCompletedEventArgs(searchState.SearchTextOriginal, results, TerminologyManager.MaximumNumberOfTerms, e.Result.ExceedsMaxTotal)); } break; case UserState.Negated: searchState.UserState = UserState.Combine; searchState.OriginalSearchResults = e.Result; terminologyProviderClient.SearchByDescriptionAsync(searchState.SearchTextOriginal, searchState.Domains, null, false, true, TerminologyManager.LocaleString, 1, 150, 150, searchState); break; case UserState.Combine: if (TerminologyManager.InputBoxSearchCompleted != null) { ObservableCollection <InputFieldResult> results = TerminologyManager.PrepareInputFieldResults(searchState.OriginalSearchResults, true, e.Result, false, TerminologyManager.NegationDisplayString, string.Empty); TerminologyManager.InputBoxSearchCompleted(null, new InputFieldSearchCompletedEventArgs(searchState.SearchTextOriginal, results, TerminologyManager.MaximumNumberOfTerms, e.Result.ExceedsMaxTotal)); } break; default: break; } } else { if (TerminologyManager.InputBoxSearchCompleted != null) { ObservableCollection <InputFieldResult> results = TerminologyManager.PrepareInputFieldResults(e.Result, false); TerminologyManager.InputBoxSearchCompleted(null, new InputFieldSearchCompletedEventArgs(null, results, TerminologyManager.MaximumNumberOfTerms, e.Result.ExceedsMaxTotal)); } } } else { if (TerminologyManager.InputBoxSearchCompleted != null) { SearchState searchState = e.UserState as SearchState; TerminologyManager.InputBoxSearchCompleted(null, new InputFieldSearchCompletedEventArgs(searchState.SearchTextOriginal, false)); } } }
/// <summary> /// Prepares the input field results. /// </summary> /// <param name="firstResults">The first results.</param> /// <param name="firstResultsNegated">If set to <c>true</c> [first results negated].</param> /// <param name="secondResults">The second results.</param> /// <param name="secondResultsNegated">If set to <c>true</c> [second results negated].</param> /// <param name="prefix">The prefix.</param> /// <param name="postfix">The postfix.</param> /// <returns>A list of prepared input field results.</returns> private static ObservableCollection <InputFieldResult> PrepareInputFieldResults(SearchResult firstResults, bool firstResultsNegated, SearchResult secondResults, bool secondResultsNegated, string prefix, string postfix) { ObservableCollection <InputFieldResult> preparedResults = TerminologyManager.PrepareInputFieldResults(firstResults, prefix, postfix, firstResultsNegated); foreach (InputFieldResult inputFieldResult in TerminologyManager.PrepareInputFieldResults(secondResults, secondResultsNegated)) { preparedResults.Add(inputFieldResult); } return(preparedResults); }
/// <summary> /// Prepares the input field results. /// </summary> /// <param name="searchResult">The search result.</param> /// <param name="isNegated">If set to <c>true</c> [is negated].</param> /// <returns>A list of prepared input field results.</returns> private static ObservableCollection <InputFieldResult> PrepareInputFieldResults(SearchResult searchResult, bool isNegated) { return(TerminologyManager.PrepareInputFieldResults(searchResult, string.Empty, string.Empty, isNegated)); }