private void OnSearchTextChanged() { var controlsService = DependencyService.Get <IControlsService>(); List <ControlNameSearchResultViewModel> results = new List <ControlNameSearchResultViewModel>(); if (string.IsNullOrEmpty(this.SearchText)) { var controls = controlsService.GetAllControls(); foreach (var control in controls) { var highlightedText = new HighlightedTextInfo(control.Name, 0, 0); results.Add(new ControlNameSearchResultViewModel(SearchResultType.AllControls, control.Name, highlightedText)); } } else { var searchService = DependencyService.Get <ISearchService>(); var searchResults = searchService.Search(this.SearchText); foreach (var searchResult in searchResults) { var viewModel = this.searchResultTypeToViewModelConverter[searchResult.ResultType](searchResult); results.Add(viewModel); } } this.SearchResults = new ObservableCollection <ControlNameSearchResultViewModel>(results); }
private ExampleDescriptionSearchResultViewModel ExampleDescriptionSearchResultToViewModel(SearchResult result) { var controlsService = DependencyService.Get <IControlsService>(); var example = controlsService.GetControlExample(result.ControlName, result.ExampleName); var highlightedText = new HighlightedTextInfo(example.Description, result.FirstCharIndex, result.LastCharIndex); return(new ExampleDescriptionSearchResultViewModel(SearchResultType.ExampleDescription, result.ControlName, example.Name, example.Description, highlightedText)); }
private ControlDescriptionSearchResultViewModel ControlDescriptionSearchResultToViewModel(SearchResult result) { var controlsService = DependencyService.Get <IControlsService>(); var control = controlsService.GetControlByName(result.ControlName); var highlightedText = new HighlightedTextInfo(control.FullDescription, result.FirstCharIndex, result.LastCharIndex); return(new ControlDescriptionSearchResultViewModel(SearchResultType.ControlDescription, control.Name, control.FullDescription, highlightedText)); }
private void OnSearchTextChanged() { var controlsService = DependencyService.Get <IControlsService>(); List <ControlNameSearchResultViewModel> results = new List <ControlNameSearchResultViewModel>(); if (string.IsNullOrEmpty(this.SearchText)) { var controls = controlsService.GetAllControls(); foreach (var control in controls) { var highlightedText = new HighlightedTextInfo(control.DisplayName, 0, 0); results.Add(new ControlNameSearchResultViewModel(SearchResultType.AllControls, control.Name, control.DisplayName, highlightedText)); } } else { var searchService = DependencyService.Get <ISearchService>(); var searchResults = searchService.Search(this.SearchText); foreach (var searchResult in searchResults) { var viewModel = this.searchResultTypeToViewModelConverter[searchResult.ResultType](searchResult); results.Add(viewModel); } } this.HasResults = results.Count > 0; this.SearchResults = new ObservableCollection <ControlNameSearchResultViewModel>(results); if (!string.IsNullOrEmpty(this.SearchText) && this.SearchText.Contains(';') && this.SearchText.EndsWith("#") && this.SearchResults.Count() == 1) { this.SelectedSearchResult = this.SearchResults.First(); } }
private ExampleNameSearchResultViewModel ExampleSearchResultToViewMovel(SearchResult result) { var highlightedText = new HighlightedTextInfo(result.ExampleName, result.FirstCharIndex, result.LastCharIndex); return(new ExampleNameSearchResultViewModel(SearchResultType.Example, result.ControlName, result.ExampleName, highlightedText)); }
private ControlNameSearchResultViewModel ControlSearchResultToViewModel(SearchResult result) { var highlightedText = new HighlightedTextInfo(result.ControlName, result.FirstCharIndex, result.LastCharIndex); return(new ControlNameSearchResultViewModel(SearchResultType.Control, result.ControlName, highlightedText)); }
public ControlNameSearchResultViewModel(SearchResultType resultType, string controlName, string controlDisplayName, HighlightedTextInfo highlightedTextInfo) { this.ResultType = resultType; this.ResultTypeText = EnumToStringConverter.Convert(this.ResultType); this.ControlName = controlName; this.ControlDisplayName = controlDisplayName; this.HighlightedTextInfo = highlightedTextInfo; }