Esempio n. 1
0
        private void OnSearchPaneSuggestionsRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs args)
        {
            var request          = args.Request;
            var matches          = _cities.Where(x => x.Name.StartsWith(args.QueryText, StringComparison.OrdinalIgnoreCase)).Take(10);
            var matchesTimeZones = _cities.GroupBy(x => x.TimeZoneId).Where(x => x.Key.StartsWith(args.QueryText, StringComparison.OrdinalIgnoreCase)).Take(10);

            request.SearchSuggestionCollection.AppendQuerySuggestions(matches.Select(m => m.Name));
            request.SearchSuggestionCollection.AppendQuerySuggestions(matchesTimeZones.Select(m => m.Key));

            var resultSuggestion = matches.Where(x => x.Name.Equals(args.QueryText, StringComparison.OrdinalIgnoreCase)).Take(5);

            if (!resultSuggestion.Any())
            {
                return;
            }

            var image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/city.png"));

            foreach (var match in resultSuggestion)
            {
                request.SearchSuggestionCollection.AppendResultSuggestion(match.Name,
                                                                          match.CountryName + ", " + match.State,
                                                                          match.Id.ToString(), image, match.CountryName);
            }
        }
Esempio n. 2
0
        private async void SearchProductGroupAc(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs args)
        {
            if (sender.QueryText.Length >= 2)
            {
                var deferral = args.Request.GetDeferral();

                var productGroupAcs = await ProductGroupManager.SearchAutoCompletePgAsync(sender.QueryText, 10);

                var suggestions = args.Request.SearchSuggestionCollection;

                foreach (var pg in productGroupAcs)
                {
                    var productImagesDirFormat = (string)Application.Current.Resources["ProductImagesDirFormat"];
                    var imageUrl = string.Format(productImagesDirFormat, pg.ImageUrl);                                                  //PL: http://localhost:50308/Content/Images/ProductImages/P-Kemiai-elemek-687268.jpg
                    var image    = RandomAccessStreamReference.CreateFromUri(new Uri(imageUrl));

                    suggestions.AppendResultSuggestion(pg.Title, pg.SubTitle, pg.FriendlyUrl, image, pg.Title);
                }

                if (suggestions.Size == 0)
                {
                    var uriMock = RandomAccessStreamReference.CreateFromUri(new Uri("http://valid-uri"));
                    suggestions.AppendResultSuggestion("Nincs találat", "", " ", uriMock, "");
                }

                deferral.Complete();
            }
        }
Esempio n. 3
0
        void SearchPaneSuggestionsRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs args)
        {
            var vm          = ((DashboardViewModel)DataContext);
            var suggestions = vm.SearchSuggestiongsAsync(args.QueryText);

            args.Request.SearchSuggestionCollection.AppendQuerySuggestions(suggestions.Result);
        }
Esempio n. 4
0
 void searchPane_SuggestionsRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs args)
 {
     args.Request.SearchSuggestionCollection.AppendQuerySuggestions((from el in App.MainViewModel.repos
                                                                     where el.name.ToLower().StartsWith(args.QueryText.ToLower())
                                                                     orderby el.name ascending
                                                                     select el.name).Take(5));
 }
Esempio n. 5
0
        //Providing search suggestions - creates a self populated list from the dogs.txt file
        void OnSuggestionsRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs args)
        {
            Dictionary <string, List <BreedDataItem> > _results = new Dictionary <string, List <BreedDataItem> >();
            List <string> termList = new List <string>();
            var           groups   = BreedDataSource.GetGroups("AllGroups");
            string        query    = args.QueryText.ToLower();
            var           all      = new List <BreedDataItem>();

            _results.Add("All", all);

            foreach (var group in groups)
            {
                var items = new List <BreedDataItem>();
                _results.Add(group.ShortTitle, items);

                foreach (var item in group.Items)
                {
                    termList.Add(item.ShortTitle.ToLower());
                }
            }
            foreach (var term in termList)
            {
                if (term.StartsWith(query.ToLower()))
                {
                    args.Request.SearchSuggestionCollection.AppendQuerySuggestion(term);
                }
            }
        }
        // Module 12 - Generating Revenue with your App

        async void App_SuggestionsRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs args)
        {
            //var deferral = args.Request.GetDeferral();

            //var query = args.QueryText;

            //var pos = await GeopositionDataFetcher.Instance.GetLocationAsync();
            //var possibleDestinations = await LocationsDataFetcher.Instance.SearchLocationsAsync(query);
            //var currentSource = await LocationsDataFetcher.Instance.GetLocationByCountryCodeAsync(pos.CivicAddress.Country);

            //if (currentSource != null)
            //{

            //    foreach (var destination in possibleDestinations)
            //    {
            //        var title = string.Format("{0} to {1}", currentSource.Country, destination.Country);
            //        var detail = string.Format("{0} to {1}", currentSource.City, destination.City);

            //        var img = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/BlueYonderGraphics/flightIcon.png"));
            //        args.Request.SearchSuggestionCollection.AppendResultSuggestion(title,
            //                                                                       detail,
            //                                                                       string.Format("{0}|{1}",
            //                                                                       currentSource.LocationId,
            //                                                                       destination.LocationId),
            //                                                                       img,
            //                                                                       "no image");
            //    }
            //}
            //deferral.Complete();
        }
 void searchPane_SuggestionsRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs args)
 {
     args.Request.SearchSuggestionCollection.AppendQuerySuggestions((from el in elements
                                                                     where el.Name.ToLower().StartsWith(args.QueryText.ToLower()) || el.Symbol.ToLower().StartsWith(args.QueryText.ToLower())
                                                                     orderby el.Name ascending
                                                                     select el.Name).Take(5));
 }
Esempio n. 8
0
        /// <summary>
        /// Called when search pane suggestions are requested.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="SearchPaneSuggestionsRequestedEventArgs"/> instance containing the event data.</param>
        private async void OnSearchPaneSuggestionsRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs e)
        {
            var queryText = e.QueryText;

            if (!string.IsNullOrEmpty(queryText))
            {
                // The deferral object is used to supply suggestions asynchronously for example when fetching suggestions from a web service.
                var deferral = e.Request.GetDeferral();
                try
                {
                    Debug.WriteLine("Requesting suggestions for query: " + queryText);
                    ListResponse <string> suggestions = await ApiClient.GetSearchSuggestionsAsync(queryText, 5);

                    if (suggestions.Result != null)
                    {
                        e.Request.SearchSuggestionCollection.AppendQuerySuggestions(suggestions.Result);
                        Debug.WriteLine("Suggestions provided for query: " + queryText);
                    }
                    else
                    {
                        Debug.WriteLine("No suggestions provided for query: " + queryText + " error: " + suggestions.Error.Message);
                    }
                }
                catch (Exception)
                {
                    Debug.WriteLine("Suggestions could not be displayed");
                }
                finally
                {
                    deferral.Complete();
                }
            }
        }
Esempio n. 9
0
        private async void OnSearchSuggestionRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs args)
        {
            var deferral    = args.Request.GetDeferral();
            var suggestions = await SuggestionProvider.GetSuggestionsAsync(args.QueryText);

            args.Request.SearchSuggestionCollection.AppendQuerySuggestions(suggestions);
            deferral.Complete();
        }
Esempio n. 10
0
        private void MainPage_SuggestionsRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs args)
        {
            SearchSuggestionCollection coll = args.Request.SearchSuggestionCollection;

            if (args.QueryText.StartsWith("c", StringComparison.CurrentCultureIgnoreCase))
            {
                coll.AppendQuerySuggestion("Carolla");
                coll.AppendQuerySuggestion("Carmy carolla");
                coll.AppendQuerySuggestion("Carmy Highbrid");
                coll.AppendQuerySuggestion("Concept vehicles");
            }
            else if (args.QueryText.StartsWith("4", StringComparison.CurrentCultureIgnoreCase))
            {
                coll.AppendQuerySuggestion("4 Runner");
                coll.AppendQuerySuggestion("Runner Flat");
            }
            else if (args.QueryText.StartsWith("h", StringComparison.CurrentCultureIgnoreCase))
            {
                coll.AppendQuerySuggestion("High Lander");
                coll.AppendQuerySuggestion("High Lander Brid");
            }
            else if (args.QueryText.StartsWith("l", StringComparison.CurrentCultureIgnoreCase))
            {
                coll.AppendQuerySuggestion("Land Cruiser");
                coll.AppendQuerySuggestion("Runner Flat");
            }
            else if (args.QueryText.StartsWith("t", StringComparison.CurrentCultureIgnoreCase))
            {
                coll.AppendQuerySuggestion("Tacoma");
                coll.AppendQuerySuggestion("Tundra");
            }
            else if (args.QueryText.StartsWith("r", StringComparison.CurrentCultureIgnoreCase))
            {
                coll.AppendQuerySuggestion("Rav 4");
            }
            else if (args.QueryText.StartsWith("s", StringComparison.CurrentCultureIgnoreCase))
            {
                coll.AppendQuerySuggestion("Sienna");
                coll.AppendQuerySuggestion("Sequaio");
            }
            else if (args.QueryText.StartsWith("a", StringComparison.CurrentCultureIgnoreCase))
            {
                coll.AppendQuerySuggestion("Avalon");
                coll.AppendQuerySuggestion("Avalon Hybrid");
            }
            else if (args.QueryText.StartsWith("p", StringComparison.CurrentCultureIgnoreCase))
            {
                coll.AppendQuerySuggestion("Prius");
                coll.AppendQuerySuggestion("Prius C");
                coll.AppendQuerySuggestion("Prius V");
            }
            else if (args.QueryText.StartsWith("y", StringComparison.CurrentCultureIgnoreCase))
            {
                coll.AppendQuerySuggestion("Yaris");
                coll.AppendQuerySuggestion("Yaris C");
                coll.AppendQuerySuggestion("Yaris V");
            }
        }
        /// <summary>
        /// Return Search results based on search value
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args">SearchPaneSuggestionsRequestedEventArgs contains QueryText of the search value</param>
        void SearchPaneSuggestionsRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs args)
        {
            var items = NotesDataSource.Search(args.QueryText);

            foreach (NoteDataCommon item in items)
            {
                args.Request.SearchSuggestionCollection.AppendQuerySuggestion(string.Format("{0}{1}{2}", item.NoteBook.Title, Consts.SearchSplitter, item.Title));
            }
        }
Esempio n. 12
0
        private async void OnSearchPaneSuggestionsRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs e)
        {
            var queryText = e.QueryText;

            if (string.IsNullOrEmpty(queryText))
            {
                MainPage.Current.NotifyUser("Use the search pane to submit a query", NotifyType.StatusMessage);
            }
            else if (string.IsNullOrEmpty(UrlTextBox.Text))
            {
                MainPage.Current.NotifyUser("Please enter the web service URL", NotifyType.StatusMessage);
            }
            else
            {
                // The deferral object is used to supply suggestions asynchronously for example when fetching suggestions from a web service.
                var request  = e.Request;
                var deferral = request.GetDeferral();

                try
                {
                    // Use the web service Url entered in the UrlTextBox that supports OpenSearch Suggestions in order to see suggestions come from the web service.
                    // See http://www.opensearch.org/Specifications/OpenSearch/Extensions/Suggestions/1.0 for details on OpenSearch Suggestions format.
                    // Replace "{searchTerms}" of the Url with the query string.
                    Task  task = GetSuggestionsAsync(Regex.Replace(UrlTextBox.Text, "{searchTerms}", Uri.EscapeDataString(queryText)), request.SearchSuggestionCollection);
                    await task;

                    if (task.Status == TaskStatus.RanToCompletion)
                    {
                        if (request.SearchSuggestionCollection.Size > 0)
                        {
                            MainPage.Current.NotifyUser("Suggestions provided for query: " + queryText, NotifyType.StatusMessage);
                        }
                        else
                        {
                            MainPage.Current.NotifyUser("No suggestions provided for query: " + queryText, NotifyType.StatusMessage);
                        }
                    }
                }
                catch (TaskCanceledException)
                {
                    // We have canceled the task.
                }
                catch (FormatException)
                {
                    MainPage.Current.NotifyUser(@"Suggestions could not be retrieved, please verify that the URL points to a valid service (for example http://contoso.com?q={searchTerms}", NotifyType.ErrorMessage);
                }
                catch (Exception)
                {
                    MainPage.Current.NotifyUser("Suggestions could not be displayed, please verify that the service provides valid OpenSearch suggestions", NotifyType.ErrorMessage);
                }
                finally
                {
                    deferral.Complete();
                }
            }
        }
        private async void OnSearchPaneSuggestionsRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs e)
        {
            var queryText = e.QueryText;

            if (string.IsNullOrEmpty(queryText))
            {
                MainPage.Current.NotifyUser("Use the search pane to submit a query", NotifyType.StatusMessage);
            }
            else
            {
                var url = "http://en.wikipedia.org/w/api.php?action=opensearch&format=json&search={searchTerms}";

                // The deferral object is used to supply suggestions asynchronously for example when fetching suggestions from a web service.
                var request  = e.Request;
                var deferral = request.GetDeferral();

                try
                {
                    Task task = GetSuggestionsAsync(Regex.Replace(url, "{searchTerms}", Uri.EscapeDataString(queryText)), request.SearchSuggestionCollection);
                    //Debug.WriteLine("* created task {0}    query: {1}", task.Id, queryText);

                    await task;
                    //Debug.WriteLine("@ await returned, id {0}    status {1} ", task.Id, task.Status);

                    if (task.Status == TaskStatus.RanToCompletion)
                    {
                        if (request.SearchSuggestionCollection.Size > 0)
                        {
                            MainPage.Current.NotifyUser("Suggestions provided for query: " + queryText, NotifyType.StatusMessage);
                        }
                        else
                        {
                            MainPage.Current.NotifyUser("No suggestions provided for query: " + queryText, NotifyType.StatusMessage);
                        }
                    }
                }
                catch (TaskCanceledException)
                {
                    // We have canceled the task.
                }
                catch (FormatException)
                {
                    MainPage.Current.NotifyUser(@"Suggestions could not be retrieved, please verify that the URL points to a valid service (for example http://contoso.com?q={searchTerms}", NotifyType.ErrorMessage);
                }
                catch (Exception)
                {
                    MainPage.Current.NotifyUser("Suggestions could not be displayed, please verify that the service provides valid OpenSearch suggestions", NotifyType.ErrorMessage);
                }
                finally
                {
                    deferral.Complete();
                }
            }
        }
        private void OnSearchSuggestionsRequested(
            SearchPane sender, SearchPaneSuggestionsRequestedEventArgs e)
        {
            var queryText = e.QueryText;

            if (string.IsNullOrEmpty(queryText))
            {
                NotifyUser("Use the search pane to submit a query");
            }
            else
            {
                var  request = e.Request;
                bool isRecommendationFound = false;

                var match = suggestionList
                            .Where(x => x.CompareTo(queryText) == 0)
                            .Select(x => x).FirstOrDefault();

                if (match != null)
                {
                    RandomAccessStreamReference image =
                        RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/windows-sdk.png"));
                    isRecommendationFound = true;
                    string item = match.ToString();
                    request.SearchSuggestionCollection
                    .AppendResultSuggestion(
                        item,                         // text to display
                        item,                         // details
                        item,                         // tags usable when called back by ResultSuggestionChosen event
                        image,                        // image if any
                        "image of " + item);
                }
                else
                {
                    var results = suggestionList
                                  .Where(x => x.StartsWith(queryText, StringComparison.CurrentCultureIgnoreCase))
                                  .Select(x => x).Take(SEARCH_PANE_MAX_SUGGESTIONS);
                    foreach (var itm in results)
                    {
                        request.SearchSuggestionCollection
                        .AppendQuerySuggestion(itm);
                    }
                }
                if (request.SearchSuggestionCollection.Size > 0)
                {
                    string prefix = isRecommendationFound ? "* " : "";
                    NotifyUser(prefix + "Suggestions provided for query: " + queryText);
                }
                else
                {
                    NotifyUser("No suggestions provided for query: " + queryText);
                }
            }
        }
Esempio n. 15
0
        void OnSuggestionsRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs args)
        {
            string query = args.QueryText.ToLower();

            foreach (var term in termList)
            {
                if (term.StartsWith(query))
                {
                    args.Request.SearchSuggestionCollection.AppendQuerySuggestion(term);
                }
            }
        }
Esempio n. 16
0
        private async void OnSearchPaneSuggestionsRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs e)
        {
            var queryText = e.QueryText;

            if (string.IsNullOrEmpty(queryText))
            {
                MainPage.Current.NotifyUser("Use the search pane to submit a query", NotifyType.StatusMessage);
            }
            else
            {
                var url = "http://en.wikipedia.org/w/api.php?action=opensearch&format=xml&search={searchTerms}";

                // The deferral object is used to supply suggestions asynchronously for example when fetching suggestions from a web service.
                var request  = e.Request;
                var deferral = request.GetDeferral();

                try
                {
                    // Use the web service Url entered in the UrlTextBox that supports XML Search Suggestions in order to see suggestions come from the web service.
                    // See http://msdn.microsoft.com/en-us/library/cc848863(v=vs.85).aspx for details on XML Search Suggestions format.
                    // Replace "{searchTerms}" of the Url with the query string.
                    Task  task = GetSuggestionsAsync(Regex.Replace(url, "{searchTerms}", Uri.EscapeDataString(queryText)), request.SearchSuggestionCollection);
                    await task;
                    if (task.Status == TaskStatus.RanToCompletion)
                    {
                        if (request.SearchSuggestionCollection.Size > 0)
                        {
                            MainPage.Current.NotifyUser("Suggestions provided for query: " + queryText, NotifyType.StatusMessage);
                        }
                        else
                        {
                            MainPage.Current.NotifyUser("No suggestions provided for query: " + queryText, NotifyType.StatusMessage);
                        }
                    }
                }
                catch (TaskCanceledException)
                {
                    // Previous suggestion request was canceled.
                }
                catch (FormatException)
                {
                    MainPage.Current.NotifyUser("Suggestions could not be retrieved, please verify that the URL points to a valid service (for example http://contoso.com?q={searchTerms})", NotifyType.ErrorMessage);
                }
                catch (Exception)
                {
                    MainPage.Current.NotifyUser("Suggestions could not be displayed, please verify that the service provides valid XML Search Suggestions.", NotifyType.ErrorMessage);
                }
                finally
                {
                    deferral.Complete();
                }
            }
        }
Esempio n. 17
0
        void App_SuggestionsRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs args)
        {
            string query = args.QueryText.ToLower();

            string[] terms = { "salt", "pepper", "water", "egg", "vinegar", "flour", "rice", "sugar", "oil", "bacon", "lots of bacon" };
            foreach (string term in terms)
            {
                if (term.Contains(query))
                {
                    args.Request.SearchSuggestionCollection.AppendQuerySuggestion(term);
                }
            }
        }
Esempio n. 18
0
        async void search_SuggestionsRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs args)
        {
            var deferral = args.Request.GetDeferral();

            try
            {
                await SearchInteractionHelper.PopulateSuggestionsAsync(args.QueryText, args.Request.SearchSuggestionCollection);
            }
            finally
            {
                deferral.Complete();
            }
        }
Esempio n. 19
0
        private void OnSuggestionsRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs args)
        {
            var searchPaneSuggestionsRequestDeferral = args.Request.GetDeferral();

            this.SearchAsync(args)
            .ContinueWith(
                async x =>
            {
                foreach (var item in x.Result)
                {
                    if (args.Request.IsCanceled)
                    {
                        break;
                    }

                    if (item.ItemType == SearchItemType.Title)
                    {
                        args.Request.SearchSuggestionCollection.AppendSearchSeparator(((SearchTitle)item).Title);
                    }
                    else
                    {
                        var searchResult = (SearchResult)item;

                        IRandomAccessStreamReference randomAccessStreamReference = null;
                        if (searchResult.AlbumArtUrl != null)
                        {
                            var pathToImage = await this.albumArtCacheService.GetCachedImageAsync(searchResult.AlbumArtUrl, size: 116);
                            if (string.IsNullOrEmpty(pathToImage))
                            {
                                randomAccessStreamReference = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/SmallLogo.png"));
                            }
                            else
                            {
                                randomAccessStreamReference = RandomAccessStreamReference.CreateFromUri(AlbumArtUrlExtensions.ToLocalUri(pathToImage));
                            }
                        }
                        else
                        {
                            randomAccessStreamReference =
                                RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/SmallLogo.png"));
                        }

                        args.Request.SearchSuggestionCollection.AppendResultSuggestion(
                            searchResult.Title, searchResult.Details, searchResult.Tag, randomAccessStreamReference, "gMusicW");
                    }
                }

                searchPaneSuggestionsRequestDeferral.Complete();
            },
                TaskScheduler.FromCurrentSynchronizationContext());
        }
Esempio n. 20
0
        void OnSuggestionsRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs args)
        {
            string query = args.QueryText.ToLower();

            string[] terms = { "salt", "pepper", "water", "egg", "vinegar", "flour", "rice", "sugar", "oil" };

            foreach (var term in terms)
            {
                if (term.StartsWith(query))
                {
                    args.Request.SearchSuggestionCollection.AppendQuerySuggestion(term);
                }
            }
        }
Esempio n. 21
0
        private void OnSearchPaneSuggestionsRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs e)
        {
            var queryText = e.QueryText;

            if (!string.IsNullOrWhiteSpace(queryText))
            {
                var request = e.Request;

                // Add suggestion to Search Pane
                request.SearchSuggestionCollection.AppendQuerySuggestions(
                    elements.Where(t =>
                                   t.Name.StartsWith(queryText, StringComparison.CurrentCultureIgnoreCase)).Take(5).Select(t => t.Name));
            }
        }
Esempio n. 22
0
        private async void searchPane_SuggestionsRequested(SearchPane sender,
                                                           SearchPaneSuggestionsRequestedEventArgs args)
        {
            if (args.QueryText.Length >= 2)
            {
                var linkService = ServiceLocator.Current.GetInstance <ILinkService>();
                SearchPaneSuggestionsRequestDeferral deferral = args.Request.GetDeferral();
                List <Link> results = await linkService.Search(args.QueryText);

                List <string> searchResults = results.Select(s => s.Name).ToList();
                args.Request.SearchSuggestionCollection.AppendQuerySuggestions(searchResults);
                deferral.Complete();
            }
        }
Esempio n. 23
0
        private async Task <List <ISearchItem> > SearchAsync(SearchPaneSuggestionsRequestedEventArgs args)
        {
            var result = new List <ISearchItem>();

            var types = new[] { PlaylistType.Artist, PlaylistType.Album, PlaylistType.Genre };

            foreach (var playlistType in types)
            {
                var playlists = (await this.playlistsService.SearchAsync(playlistType, args.QueryText, (uint?)(MaxResults - result.Count))).ToList();
                if (playlists.Count > 0)
                {
                    this.AddResults(result, playlists, playlistType);
                }

                if (result.Count >= MaxResults)
                {
                    break;
                }
            }

            if (result.Count < MaxResults)
            {
                var songs = await this.songsRepository.SearchAsync(args.QueryText, (uint?)(MaxResults - result.Count));

                if (songs.Count > 0)
                {
                    result.Add(new SearchTitle(this.resources.GetString("Model_Song_Plural_Title")));
                    foreach (var song in songs)
                    {
                        result.Add(new SearchResult(
                                       song.Title,
                                       song.GetSongArtist(),
                                       song.SongId.ToString(),
                                       song.AlbumArtUrl));
                    }
                }
            }

            if (result.Count < MaxResults)
            {
                var playlists = (await this.playlistsService.SearchAsync(PlaylistType.UserPlaylist, args.QueryText, (uint?)(MaxResults - result.Count))).ToList();
                if (playlists.Count > 0)
                {
                    this.AddResults(result, playlists, PlaylistType.UserPlaylist);
                }
            }

            return(result);
        }
Esempio n. 24
0
        async void searchPane_SuggestionsRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs args)
        {
            var request  = args.Request;
            var defferal = request.GetDeferral();
            var query    = args.QueryText;

            var suggestions = await serelex.GetSuggestions(query);

            if (suggestions.Count > 0)
            {
                request.SearchSuggestionCollection.AppendQuerySuggestions(suggestions);
            }

            defferal.Complete();
        }
Esempio n. 25
0
        private void SuggestionsRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs args)
        {
            SearchSuggestionCollection search = args.Request.SearchSuggestionCollection;

            if (args.QueryText.StartsWith("a", StringComparison.CurrentCultureIgnoreCase))
            {
                search.AppendQuerySuggestion("Apple");
                search.AppendQuerySuggestion("Almonds");
                search.AppendQuerySuggestion("Anmimals");
            }
            else if (args.QueryText.StartsWith("b", StringComparison.CurrentCultureIgnoreCase))
            {
                search.AppendQuerySuggestion("Banana");
                search.AppendQuerySuggestion("Bat");
            }
        }
        void searchPane_SuggestionsRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs args)
        {
            foreach (ForumItem forumItem in viewModel.ForumItemList)
            {
                string suggestion = forumItem.Name;

                if (suggestion.StartsWith(args.QueryText, StringComparison.CurrentCultureIgnoreCase))
                {
                    args.Request.SearchSuggestionCollection.AppendQuerySuggestion(suggestion);
                }
                if (args.Request.SearchSuggestionCollection.Size >= 5)
                {
                    break;
                }
            }
        }
Esempio n. 27
0
        private void DoWikipediaSearch(SearchPaneSuggestionsRequestedEventArgs request)
        {
            MainPage.Current.NotifyUser("Searching for: " + request.QueryText, NotifyType.StatusMessage);

            var deferral = request.Request.GetDeferral();

            request.Request.SearchSuggestionCollection.AppendQuerySuggestion("FOoo");

            //var resultArray = await SearchWikipediaAsync(request.QueryText);

            //addToSearchResults(
            //    resultArray,
            //    request.Request.SearchSuggestionCollection,
            //    MainPage.SearchPaneMaxSuggestions);
            deferral.Complete();
        }
Esempio n. 28
0
        void OnSuggestionsRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs args)
        {
            string query = args.QueryText.ToLower();

            List <string> termList = new List <string> {
                "beagle", "dachshund", "jack russel terrier", "pug", "west highland white terrier", "yorkshire terrier", "australian shepherd", "basset hound", "border collie",
                "bulldog", "shar pei", "springer spaniel", "dalmatian", "doberman pinscher", "german shepherd", "golden retriever", "great dane", "irish seter"
            };

            foreach (var term in termList)
            {
                if (term.StartsWith(query))
                {
                    args.Request.SearchSuggestionCollection.AppendQuerySuggestion(term);
                }
            }
        }
Esempio n. 29
0
        private void OnSearchPaneSuggestionsRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs e)
        {
            var queryText = e.QueryText;

            if (string.IsNullOrEmpty(queryText))
            {
                MainPage.Current.NotifyUser("Use the search pane to submit a query", NotifyType.StatusMessage);
            }
            else
            {
                var request           = e.Request;
                var linguisticDetails = e.LinguisticDetails;
                foreach (string alternative in linguisticDetails.QueryTextAlternatives)
                {
                    foreach (string suggestion in suggestionList)
                    {
                        if (suggestion.StartsWith(alternative, StringComparison.CurrentCultureIgnoreCase))
                        {
                            // Add suggestion to Search Pane
                            request.SearchSuggestionCollection.AppendQuerySuggestion(suggestion);

                            // Break since the Search Pane can show at most 5 suggestions
                            if (request.SearchSuggestionCollection.Size >= MainPage.SearchPaneMaxSuggestions)
                            {
                                break;
                            }
                        }
                    }

                    // Break since the Search Pane can show at most 5 suggestions
                    if (request.SearchSuggestionCollection.Size >= MainPage.SearchPaneMaxSuggestions)
                    {
                        break;
                    }
                }

                if (request.SearchSuggestionCollection.Size > 0)
                {
                    MainPage.Current.NotifyUser("Suggestions provided for query: " + queryText, NotifyType.StatusMessage);
                }
                else
                {
                    MainPage.Current.NotifyUser("No suggestions provided for query: " + queryText, NotifyType.StatusMessage);
                }
            }
        }
Esempio n. 30
0
        async void searchPane_SuggestionsRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs args)
        {
            var    stationService = SimpleIoc.Default.GetInstance <IStationService>();
            string queryText      = args.QueryText;

            if (stationService != null && !string.IsNullOrEmpty(queryText))
            {
                var all = await stationService.GetStations("NL");

                var filtered = all.Where(x => x.Name.StartsWith(queryText, StringComparison.CurrentCultureIgnoreCase)).Take(5);

                foreach (var r in filtered)
                {
                    args.Request.SearchSuggestionCollection.AppendQuerySuggestion(r.Name);
                }
            }
        }