Example #1
0
        private void CheckNewSearchString()
        {
            if (forceNewSearch || SearchString != localSearchString && !currentlySearching)
            {
                forceNewSearch     = false;
                currentlySearching = true;
                localSearchString  = SearchString;
                var sw = new Stopwatch();
                sw.Start();
                SelectedIndex = -1;
                List <RunItem> list = Indexing.Search(localSearchString);
                Application.Current.Dispatcher.Invoke(() =>
                {
                    SearchSuggestions.RaiseListChangedEvents = false;
                    SearchSuggestions.Clear();
                    foreach (var item in list)
                    {
                        SearchSuggestions.Add(item);
                    }

                    SearchSuggestions.RaiseListChangedEvents = true;
                    SearchSuggestions.ResetBindings();
                }, DispatcherPriority.Background);

                sw.Stop();
                RenderingTime      = (int)sw.ElapsedMilliseconds;
                currentlySearching = false;
            }
        }
Example #2
0
        /// <summary>
        /// Get a list of search query suggestions.
        /// </summary>
        public async Task GetSearchSuggestions()
        {
            var query = Query != null?Query.Trim() : null;

            if (String.IsNullOrWhiteSpace(query))
            {
                return;
            }
            var suggestions = await searchService.GetSearchSuggestionsAsync(Query);

            SearchSuggestions.Clear();
            foreach (var suggestion in suggestions)
            {
                SearchSuggestions.Add(suggestion.Value);
            }
        }
Example #3
0
        private async Task PullSearchSuggestionAsync(bool userChangedQuery)
        {
            if (!userChangedQuery)
            {
                return;
            }

            var query = SearchQuery;

            if (string.IsNullOrEmpty(query))
            {
                SearchResultsAvailable = false;
                SearchSuggestions.Clear();
                SearchSuggestions.Add(new TraktShow {
                    Title = "No result"
                });
                return;
            }

            var searchResults = await _client.Search.GetTextQueryResultsAsync(TraktSearchResultType.Show, query);

            var tasks = searchResults
                        .Select(result => result.Show.Ids.Trakt.ToString())
                        .Select(showId => _client.Shows.GetShowAsync(showId, new TraktExtendedOption {
                Full = true, Images = true
            }))
                        .ToList();

            var fullShows = await Task.WhenAll(tasks);

            if (fullShows.Any())
            {
                SearchSuggestions.Clear();
                SearchSuggestions.AddRange(fullShows);
            }
            else
            {
                SearchSuggestions.Clear();
                SearchSuggestions.Add(new TraktShow {
                    Title = "No result"
                });
            }
        }