private async void Location_SuggestionsRequested(SearchBox sender, SearchBoxSuggestionsRequestedEventArgs args)
		{
			if (geocodeTcs != null)
				geocodeTcs.Cancel();
			geocodeTcs = new CancellationTokenSource();

			if (args.QueryText.Length > 3)
			{
				try
				{
					var geo = new OnlineLocatorTask(serviceUri);
					var deferral = args.Request.GetDeferral();
					var result = await geo.FindAsync(new OnlineLocatorFindParameters(args.QueryText)
					{
						MaxLocations = 5,
						OutSpatialReference = SpatialReferences.Wgs84
					}, geocodeTcs.Token);
					if (result.Any() && !args.Request.IsCanceled)
					{
						var imageSource = Windows.Storage.Streams.RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/blank.png"));
						foreach (var item in result)
							args.Request.SearchSuggestionCollection.AppendResultSuggestion(item.Name, "", item.Extent.ToJson(), imageSource, "");
					}
					deferral.Complete();
				}
				catch { }
			}
		}
Beispiel #2
0
        /// <summary>
        /// Populates SearchBox with Suggestions when user enters text
        /// </summary>
        /// <param name="sender">The Xaml SearchBox</param>
        /// <param name="args">Event when user changes text in SearchBox</param>
        private async void SearchBoxEventsSuggestionsRequested(SearchBox sender, SearchBoxSuggestionsRequestedEventArgs args)
        {
            string queryText = args.QueryText;

            if (string.IsNullOrEmpty(queryText))
            {
                return;
            }

            Windows.ApplicationModel.Search.SearchSuggestionCollection suggestionCollection = args.Request.SearchSuggestionCollection;
            if (this.suggestionList == null)
            {
                this.suggestionList = await DataManager.JobDataSource.GetAllJobs();
            }

            foreach (var suggestion in this.suggestionList)
            {
                if (suggestion.Title.ToUpper().Contains(queryText.ToUpper()))
                {
                    suggestionCollection.AppendQuerySuggestion(suggestion.Title);
                }

                if (suggestion.Id.Contains(queryText))
                {
                    suggestionCollection.AppendQuerySuggestion(suggestion.Id);
                }

                if (suggestion.Customer.FullName.ToUpper().Contains(queryText.ToUpper()))
                {
                    suggestionCollection.AppendQuerySuggestion(suggestion.Customer.FullName);
                }
            }
        }
        private async void SearchBox_OnSuggestionsRequested(SearchBox sender, SearchBoxSuggestionsRequestedEventArgs args)
        {
            if (string.IsNullOrWhiteSpace(args.QueryText))
            {
                return;
            }

            var deferral = args.Request.GetDeferral();

            SearchRepositoryResult result = await Util.Search(args.QueryText);

            foreach (Repository item in result.Items)
            {
                if (args.Request.IsCanceled)
                {
                    return;
                }

                args.Request.SearchSuggestionCollection.AppendResultSuggestion(
                    item.FullName,
                    item.Description ?? "No description",
                    item.Id.ToString(),
                    RandomAccessStreamReference.CreateFromUri(new Uri(item.Owner.AvatarUrl)),
                    "NoImage"
                    );
            }

            deferral.Complete();
        }
Beispiel #4
0
        private void Search_SuggestionsRequested(SearchBox sender, SearchBoxSuggestionsRequestedEventArgs args)
        {
            string queryText = args.QueryText;

            if (!string.IsNullOrWhiteSpace(queryText))
            {
                var suggestionCollection = args.Request.SearchSuggestionCollection;

                // result suggestions
                var searchResults = SampleDataSource.Search(queryText, true);
                foreach (var result in searchResults.SelectMany(p => p.Items).Take(2))
                {
                    var imageUri    = new Uri("ms-appx:///" + result.TileImagePath);
                    var imageSource = Windows.Storage.Streams.RandomAccessStreamReference.CreateFromUri(imageUri);
                    suggestionCollection.AppendResultSuggestion(result.Title, result.Description, result.UniqueId, imageSource, result.Description);
                }

                // separator
                suggestionCollection.AppendSearchSeparator("Suggestions");

                // query suggestions
                string[] suggestionList = { "米兰的小铁匠", "七里香", "乔克叔叔", "搁浅" };

                foreach (string suggestion in suggestionList)
                {
                    if (suggestion.StartsWith(queryText, StringComparison.CurrentCultureIgnoreCase))
                    {
                        suggestionCollection.AppendQuerySuggestion(suggestion);
                    }
                }
            }
        }
Beispiel #5
0
        async private void filterBox_SuggestionsRequested(SearchBox sender, SearchBoxSuggestionsRequestedEventArgs args)
        {
            var deferral = args.Request.GetDeferral();

            if (!string.IsNullOrEmpty(args.QueryText))
            {
                if (!isCached)
                {
                    await Util.WriteToDiskAsync(JsonConvert.SerializeObject(this.detailsGrid.ItemsSource), "DetailsItemsSourceFile.txt");

                    isCached = true;
                }

                var searchSuggestionList = new List <string>();
                foreach (var task in await Util.ReadFromDiskAsync <Pithline.FMS.BusinessLogic.Task>("DetailsItemsSourceFile.txt"))
                {
                    foreach (var propInfo in task.GetType().GetRuntimeProperties())
                    {
                        if (propInfo.PropertyType.Name.Equals(typeof(System.Boolean).Name) || propInfo.PropertyType.Name.Equals(typeof(BindableValidator).Name) || propInfo.Name.Equals("Address"))
                        {
                            continue;
                        }
                        var propVal = Convert.ToString(propInfo.GetValue(task));
                        if (propVal.ToLowerInvariant().Contains(args.QueryText))
                        {
                            searchSuggestionList.Add(propVal);
                        }
                    }
                }
                args.Request.SearchSuggestionCollection.AppendQuerySuggestions(searchSuggestionList);
            }
            deferral.Complete();
        }
Beispiel #6
0
        private async void Location_SuggestionsRequested(SearchBox sender, SearchBoxSuggestionsRequestedEventArgs args)
        {
            if (geocodeTcs != null)
            {
                geocodeTcs.Cancel();
            }
            geocodeTcs = new CancellationTokenSource();

            if (args.QueryText.Length > 3)
            {
                try
                {
                    var geo      = new LocatorTask(serviceUri);
                    var deferral = args.Request.GetDeferral();
                    var result   = await geo.GeocodeAsync(args.QueryText, new GeocodeParameters()
                    {
                        MaxResults             = 5,
                        OutputSpatialReference = SpatialReferences.Wgs84
                    }, geocodeTcs.Token);

                    if (result.Any() && !args.Request.IsCanceled)
                    {
                        var imageSource = Windows.Storage.Streams.RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/blank.png"));
                        foreach (var item in result)
                        {
                            args.Request.SearchSuggestionCollection.AppendResultSuggestion(item.Label, "", item.Extent.ToJson(), imageSource, "");
                        }
                    }
                    deferral.Complete();
                }
                catch { }
            }
        }
Beispiel #7
0
        public async static void SearchBox_SuggestionsRequested(SearchBox sender, SearchBoxSuggestionsRequestedEventArgs args)
        {
            // This object lets us edit the SearchSuggestionCollection asynchronously.
            var deferral = args.Request.GetDeferral();

            try
            {
                var suggestions = args.Request.SearchSuggestionCollection;
                var groups      = await AppUIBasics.Data.ControlInfoDataSource.GetGroupsAsync();

                foreach (var group in groups)
                {
                    var matchingItems = group.Items.Where(
                        item => item.Title.StartsWith(args.QueryText, StringComparison.CurrentCultureIgnoreCase));

                    foreach (var item in matchingItems)
                    {
                        suggestions.AppendQuerySuggestion(item.Title);
                    }
                }

                foreach (string alternative in args.LinguisticDetails.QueryTextAlternatives)
                {
                    if (alternative.StartsWith(
                            args.QueryText, StringComparison.CurrentCultureIgnoreCase))
                    {
                        suggestions.AppendQuerySuggestion(alternative);
                    }
                }
            }
            finally
            {
                deferral.Complete();
            }
        }
Beispiel #8
0
        private async void OnSuggestionsRequested(SearchBox sender, SearchBoxSuggestionsRequestedEventArgs args)
        {
            if (args.QueryText.Length <= 3)
            {
                return;
            }

            var deferral = args.Request.GetDeferral();

            var results = await searchService.SearchAsync(args.QueryText);

            foreach (var result in results.Take(5))
            {
                IRandomAccessStreamReference image = null;

                if (result.HasSmallThumbnail)
                {
                    image = RandomAccessStreamReference.CreateFromUri(new Uri(result.SmallThumbnail, UriKind.Absolute));
                }
                else
                {
                    image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///resources/images/mm_50x50.scale-100.jpg"));
                }

                args.Request.SearchSuggestionCollection.AppendResultSuggestion(
                    result.Title,
                    result.Authors,
                    result.ItemLink,
                    image,
                    result.Title);
            }

            deferral.Complete();
        }
        /// <summary>
        /// Populates SearchBox with Suggestions when user enters text
        /// </summary>
        /// <param name="sender">Xaml SearchBox</param>
        /// <param name="e">Event when user changes text in SearchBox</param>
        private void SearchBoxEventsSuggestionsRequested(object sender, SearchBoxSuggestionsRequestedEventArgs e)
        {
            string queryText = e.QueryText;

            if (!string.IsNullOrEmpty(queryText))
            {
                Windows.ApplicationModel.Search.SearchSuggestionCollection suggestionCollection = e.Request.SearchSuggestionCollection;
                foreach (string suggestion in suggestionList)
                {
                    if (suggestion.StartsWith(queryText, StringComparison.CurrentCultureIgnoreCase))
                    {
                        suggestionCollection.AppendQuerySuggestion(suggestion);
                    }
                }
            }

            if (e.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);
            }
        }
Beispiel #10
0
        private async void SearchBoxEventsSuggestionsRequested(SearchBox box, SearchBoxSuggestionsRequestedEventArgs e)
        {
            if ( ! string.IsNullOrEmpty(e.QueryText))
            {
                var suggestions = (await pollItunesWithNewQuery(box.QueryText)).ToList();

                DefaultViewModel["Items"] = suggestions;
            }
        }
        /// <summary>
        /// Populates SearchBox with Suggestions when user enters text
        /// </summary>
        /// <param name="sender">Xaml SearchBox</param>
        /// <param name="e">Event when user changes text in SearchBox</param>
        private async void SearchBoxEventsSuggestionsRequested(Object sender, SearchBoxSuggestionsRequestedEventArgs e)
        {
            var queryText = e.QueryText;

            if (string.IsNullOrEmpty(queryText))
            {
                MainPage.Current.NotifyUser("Use the search control 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 void SearchBox_OnSuggestionsRequested(SearchBox sender, SearchBoxSuggestionsRequestedEventArgs args)
        {
            var imageUri = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appdata://Assets/ModernKeePass-SmallLogo.scale-80.png"));
            var results  = Model.SubEntries.Where(e => e.Name.IndexOf(args.QueryText, StringComparison.OrdinalIgnoreCase) >= 0).Take(5);

            foreach (var result in results)
            {
                args.Request.SearchSuggestionCollection.AppendResultSuggestion(result.Name, result.ParentGroup.Name, result.Id, imageUri, string.Empty);
            }
        }
        private async void EntrySearchBox_OnSuggestionsRequested(SearchBox sender, SearchBoxSuggestionsRequestedEventArgs args)
        {
            var imageUri = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appdata:/Assets/ModernKeePass-SmallLogo.scale-80.png"));
            var results  = (await Model.Search(args.QueryText)).Take(5);

            foreach (var result in results)
            {
                args.Request.SearchSuggestionCollection.AppendResultSuggestion(result.Title.Value, result.ParentGroupName, result.Id, imageUri, string.Empty);
            }
        }
        /// <summary>
        /// Populates SearchBox with Suggestions when user enters text
        /// </summary>
        /// <param name="sender">Xaml SearchBox</param>
        /// <param name="e">Event when user changes text in SearchBox</param>
        private async void SearchBoxEventsSuggestionsRequested(Object sender, SearchBoxSuggestionsRequestedEventArgs e)
        {
            var queryText = e.QueryText;
            if (string.IsNullOrEmpty(queryText))
            {
                MainPage.Current.NotifyUser("Use the search control 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();
                }
            }
        }
Beispiel #15
0
        /// <summary>
        /// Populates SearchBox with Suggestions when user enters text
        /// </summary>
        /// <param name="sender">Xaml SearchBox</param>
        /// <param name="e">Event when user changes text in SearchBox</param>
        private async void SearchBoxEventsSuggestionsRequested(Object sender, SearchBoxSuggestionsRequestedEventArgs e)
        {
            var queryText = e.QueryText;

            if (string.IsNullOrEmpty(queryText))
            {
                //MainPage.Current.NotifyUser("Use the search control to submit a query", NotifyType.StatusMessage);
            }
            else
            {
                Random random     = new Random();
                int    r          = random.Next();
                string key        = System.Net.WebUtility.UrlEncode(queryText);
                string requestUrl = "http://replatform.cloudapp.net:8000/getsearchrec?v={0}&uuid={1}&type={2}&from={3}&to={4}&r={5}";
                requestUrl = String.Format(requestUrl, key, App.gDeviceName, App.gDeviceType, App.NavigationRoadmap.GetFrom(), App.NavigationRoadmap.GetTo(), r);

                // 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(requestUrl, request.SearchSuggestionCollection);
                    await task;

                    if (task.Status == TaskStatus.RanToCompletion)
                    {
                        if (request.SearchSuggestionCollection.Size > 0)
                        {
                            //
                        }
                        else
                        {
                            //
                        }
                    }
                }
                catch (TaskCanceledException)
                {
                    // We have canceled the task.
                }
                catch (FormatException)
                {
                    //
                }
                catch (Exception)
                {
                    //
                }
                finally
                {
                    deferral.Complete();
                }
            }
        }
Beispiel #16
0
        /// <summary>
        /// Populates SearchBox with Suggestions when user enters text
        /// </summary>
        /// <param name="sender">Xaml SearchBox</param>
        /// <param name="e">Event when user changes text in SearchBox</param>
        private async void SearchBoxEventsSuggestionsRequested(Object sender, SearchBoxSuggestionsRequestedEventArgs e)
        {
            var queryText = e.QueryText;

            if (string.IsNullOrEmpty(queryText))
            {
                MainPage.Current.NotifyUser("Use the search control to submit a query", NotifyType.StatusMessage);
            }
            else if (string.IsNullOrEmpty(UrlTextBox.Text))
            {
                MainPage.Current.NotifyUser("Please enter the web service URL", NotifyType.StatusMessage);
            }
            else
            {
                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(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)
                {
                    // 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();
                }
            }
        }
 /// <summary>
 /// Called to append a list of suggestions to the SearchSuggestionCollection, if the prefix matches one in the suggestionList
 /// </summary>
 /// <param name="textToMatch">String to compare with suggestions in the suggestionList</param>
 /// <param name="e">Event when user submits query</param>
 private void AppendSuggestion(string textToMatch, SearchBoxSuggestionsRequestedEventArgs e)
 {
     foreach (string suggestion in suggestionList)
     {
         if (suggestion.StartsWith(textToMatch, StringComparison.CurrentCultureIgnoreCase))
         {
             // If the string matches the query text shown in the search box, add suggestion to the search box.
             e.Request.SearchSuggestionCollection.AppendQuerySuggestion(suggestion);
         }
     }
 }
 /// <summary>
 /// Called to append a list of suggestions to the SearchSuggestionCollection, if the prefix matches one in the suggestionList
 /// </summary>
 /// <param name="textToMatch">String to compare with suggestions in the suggestionList</param>
 /// <param name="e">Event when user submits query</param>
 private void AppendSuggestion(string textToMatch, SearchBoxSuggestionsRequestedEventArgs e)
 {
     foreach (string suggestion in suggestionList)
     {
         if (suggestion.StartsWith(textToMatch, StringComparison.CurrentCultureIgnoreCase))
         {
             // If the string matches the query text shown in the search box, add suggestion to the search box.
             e.Request.SearchSuggestionCollection.AppendQuerySuggestion(suggestion);
         }
     }
 }
Beispiel #19
0
        private void SearchBox_OnSuggestionsRequested(SearchBox sender, SearchBoxSuggestionsRequestedEventArgs args)
        {
            //clear search history, and add new suggestions to the search history list
            searchManager.ClearHistory();
            IEnumerable <Company> results = App.MainViewModel.GetSearchResults(args.QueryText);

            foreach (Company company in results)
            {
                searchManager.AddToHistory(company.CompanyName);
            }
        }
        private void OnSearchSuggestionsRequested(
            SearchBox sender, SearchBoxSuggestionsRequestedEventArgs 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);
                }
            }
        }
Beispiel #21
0
        private void TextEnum_SuggestionsRequested(SearchBox sender, SearchBoxSuggestionsRequestedEventArgs args)
        {
            if (!string.IsNullOrEmpty(args.QueryText))
            {
                var suggestions = ViewModel.Characters
                                  .Select(c => c.ToSymbolEnum())
                                  .Where(v => v.HasValue)
                                  .Select(v => v.Value.ToString())
                                  .Where(s => s.StartsWith(args.QueryText, StringComparison.CurrentCultureIgnoreCase));

                args.Request.SearchSuggestionCollection.AppendQuerySuggestions(suggestions);
            }
        }
        private void GroupSearchBox_OnSuggestionsRequested(SearchBox sender, SearchBoxSuggestionsRequestedEventArgs args)
        {
            var imageUri = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appdata:/Assets/ModernKeePass-SmallLogo.scale-80.png"));
            var groups   = Model.Groups.Where(g => g.Title.IndexOf(args.QueryText, StringComparison.OrdinalIgnoreCase) >= 0).Take(5);

            foreach (var group in groups)
            {
                args.Request.SearchSuggestionCollection.AppendResultSuggestion(
                    group.Title,
                    group.ParentGroupName ?? string.Empty,
                    group.Id,
                    imageUri,
                    string.Empty);
            }
        }
        private void OnSuggestionRequested(SearchBox sender, SearchBoxSuggestionsRequestedEventArgs args)
        {
            if (string.IsNullOrEmpty(args.QueryText))
            {
                return;
            }

            var    deferral    = args.Request.GetDeferral();
            string query       = args.QueryText;
            var    suggestions = this.Keys.Where(k => k.StartsWith(query)).ToList();

            args.Request.SearchSuggestionCollection.AppendQuerySuggestions(suggestions);

            deferral.Complete();
        }
Beispiel #24
0
        async private void filterBox_SuggestionsRequested(SearchBox sender, SearchBoxSuggestionsRequestedEventArgs args)
        {
            try
            {
                if (this.mainGrid.ItemsSource != null)
                {
                    var deferral = args.Request.GetDeferral();
                    if (!string.IsNullOrEmpty(args.QueryText))
                    {
                        if (!isCached)
                        {
                            await Util.WriteToDiskAsync(JsonConvert.SerializeObject(this.mainGrid.ItemsSource), "CDTaskFile.json");

                            isCached = true;
                        }

                        var searchSuggestionList = new List <string>();
                        foreach (var task in await Util.ReadFromDiskAsync <CollectDeliveryTask>("CDTaskFile.json"))
                        {
                            foreach (var propInfo in task.GetType().GetRuntimeProperties())
                            {
                                if (propInfo.PropertyType.Name.Equals(typeof(System.Boolean).Name) ||
                                    propInfo.PropertyType.Name.Equals(typeof(BindableValidator).Name))
                                {
                                    continue;
                                }

                                var propVal = Convert.ToString(propInfo.GetValue(task));
                                if (propVal.ToLowerInvariant().Contains(args.QueryText.ToLowerInvariant()))
                                {
                                    if (!searchSuggestionList.Contains(propVal))
                                    {
                                        searchSuggestionList.Add(propVal);
                                    }
                                }
                            }
                        }
                        args.Request.SearchSuggestionCollection.AppendQuerySuggestions(searchSuggestionList);
                    }
                    deferral.Complete();
                }
            }
            catch (Exception ex)
            {
                AppSettings.Instance.ErrorMessage = ex.Message;
            }
        }
Beispiel #25
0
        private void championSearchBox_SuggestionsRequested(SearchBox sender, SearchBoxSuggestionsRequestedEventArgs args)
        {
            string search = args.QueryText;

            if (search != "")
            {
                SearchSuggestionCollection suggestionCollegion = args.Request.SearchSuggestionCollection;
                championsCollection.Clear();
                foreach (KeyValuePair <string, ChampionStatic> champion in sortedChampions)
                {
                    if (champion.Value.name.ToLower().Contains(search.ToLower()))
                    {
                        if (selectedRole == "All")
                        {
                            suggestionCollegion.AppendQuerySuggestion(champion.Value.name);
                            if (screenHeight >= 1440)
                            {
                                championsCollection.Add(new ChampionsGridViewBinding(new Uri(AppConstants.championLoadingUrl + champion.Key + "_0.jpg"), 308, 560, champion.Key, champion.Value));
                            }
                            else
                            {
                                championsCollection.Add(new ChampionsGridViewBinding(new Uri(AppConstants.ChampionIconUrl() + champion.Key + ".png"), 120, 120, champion.Key, champion.Value));
                            }
                        }
                        else
                        {
                            if (champion.Value.tags[0] == selectedRole)
                            {
                                suggestionCollegion.AppendQuerySuggestion(champion.Value.name);
                                if (screenHeight >= 1440)
                                {
                                    championsCollection.Add(new ChampionsGridViewBinding(new Uri(AppConstants.championLoadingUrl + champion.Key + "_0.jpg"), 308, 560, champion.Key, champion.Value));
                                }
                                else
                                {
                                    championsCollection.Add(new ChampionsGridViewBinding(new Uri(AppConstants.ChampionIconUrl() + champion.Key + ".png"), 120, 120, champion.Key, champion.Value));
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                RefreshChampionsCollection();
            }
        }
        private async void SearchBox_OnSuggestionsRequested(SearchBox sender, SearchBoxSuggestionsRequestedEventArgs e)
        {
            //Request deferral must be recieved to allow async search suggestion population
            var deferal = e.Request.GetDeferral();

            // Add suggestions to Search Pane
            var destinations = await LocationsDataFetcher.Instance.FetchLocationsAsync(e.QueryText, false);

            var suggestions =
                destinations
                .OrderBy(location => location.City)
                .Take(5)
                .Select(location => location.City);

            e.Request.SearchSuggestionCollection.AppendQuerySuggestions(suggestions);
            deferal.Complete();
        }
        async private void filterBox_SuggestionsRequested(SearchBox sender, SearchBoxSuggestionsRequestedEventArgs args)
        {
            try
            {
                if (!String.IsNullOrWhiteSpace(args.QueryText))
                {
                    var searchSuggestionList = new List <string>();
                    var deferral             = args.Request.GetDeferral();
                    if (!string.IsNullOrEmpty(args.QueryText))
                    {
                        foreach (var task in ((MainPageViewModel)this.DataContext).PoolofTasks)
                        {
                            foreach (var propInfo in task.GetType().GetRuntimeProperties())
                            {
                                if (this.suggestLookup.Contains(propInfo.Name))
                                {
                                    var propVal = Convert.ToString(propInfo.GetValue(task));
                                    if (propVal.ToLowerInvariant().Contains(args.QueryText.ToLowerInvariant()))
                                    {
                                        if (!searchSuggestionList.Contains(propVal))
                                        {
                                            searchSuggestionList.Add(propVal);
                                        }
                                    }
                                }
                            }
                        }
                        args.Request.SearchSuggestionCollection.AppendQuerySuggestions(searchSuggestionList);
                    }
                    else
                    {
                        this.mainGrid.ItemsSource = ((MainPageViewModel)this.DataContext).PoolofTasks;
                    }
                    deferral.Complete();
                }

                else
                {
                    this.mainGrid.ItemsSource = ((MainPageViewModel)this.DataContext).PoolofTasks;
                }
            }
            catch (Exception ex)
            {
                AppSettings.Instance.ErrorMessage = ex.Message;
            }
        }
Beispiel #28
0
        private async Task PopulateResults(SearchBoxSuggestionsRequestedEventArgs arg)
        {
            var suggestionCollection = arg.Request.SearchSuggestionCollection;

            var suggestedMedia = await _searchContentDataService.FilterMediaLinkByQuery(_mediaLinks, arg.QueryText);

            _firstSuggestionID = suggestedMedia.Select(m => m.ID).FirstOrDefault();
            foreach (var mediaLink in suggestedMedia)
            {
                var imageFile = TypeIconResolver.GetIconStreamReference(mediaLink.Type);
                suggestionCollection.AppendResultSuggestion(mediaLink.Name, mediaLink.Description ?? string.Empty, mediaLink.ID, imageFile, string.Empty);
            }

            if (!suggestedMedia.Any())
            {
                suggestionCollection.AppendQuerySuggestion("No results");
            }
        }
Beispiel #29
0
        async private void filterBox_SuggestionsRequested(SearchBox sender, SearchBoxSuggestionsRequestedEventArgs args)
        {
            try
            {
                if (this.mainGrid.ItemsSource != null)
                {
                    var checkLookup = new List <string>();
                    var deferral    = args.Request.GetDeferral();
                    var query       = args.QueryText != null?args.QueryText.Trim() : String.Empty;

                    if (!string.IsNullOrEmpty(args.QueryText))
                    {
                        foreach (var task in PersistentData.Instance.PoolOfTask)
                        {
                            foreach (var propInfo in task.GetType().GetRuntimeProperties())
                            {
                                if (this.suggestLookup.Contains(propInfo.Name))
                                {
                                    var propVal = Convert.ToString(propInfo.GetValue(task));
                                    if (propVal.ToLowerInvariant().Contains(query.ToLowerInvariant()))
                                    {
                                        if (!checkLookup.Contains(propVal))
                                        {
                                            checkLookup.Add(propVal);
                                        }
                                    }
                                }
                            }
                        }
                        args.Request.SearchSuggestionCollection.AppendQuerySuggestions(checkLookup);
                    }
                    else
                    {
                        ((MainPageViewModel)this.DataContext).PoolofTasks.Clear();
                        ((MainPageViewModel)this.DataContext).PoolofTasks.AddRange(PersistentData.Instance.PoolOfTask);
                    }
                    deferral.Complete();
                }
            }
            catch (Exception ex)
            {
                AppSettings.Instance.ErrorMessage = ex.Message;
            }
        }
        private async void SearchBox_SuggestionsRequested(SearchBox sender, SearchBoxSuggestionsRequestedEventArgs args)
        {
            gloablvalue.SearchAccountUsername = SearchBox.QueryText;
            await DatabaseManagement.SearchAccountusername(result);

            if (SearchBox.QueryText == "")
            {
                result.Text = "";
            }
            else if (result.Text == SearchBox.QueryText)
            {
                result.Text = "";
                await DatabaseManagement.LoadSpacificAccountData(MainLongListSelector);
            }
            else
            {
                await DatabaseManagement.LoadAllDoctorsData(MainLongListSelector);
            }
        }
Beispiel #31
0
		private static async void GetSuggestions(SearchSuggestionsRequestDeferral deferral, SearchBox sender, SearchBoxSuggestionsRequestedEventArgs args)
		{
			try
			{
				var provider = GetProvider(sender);
				var query = args.QueryText;
				var suggestions = await Task.Run(() => provider.GetSuggestions(CancellationToken.None, query));
				var visitor = new AppendToSearchSuggestionCollectionVisitor(args.Request.SearchSuggestionCollection);
				foreach (var searchSuggestion in suggestions)
				{
					searchSuggestion.Accept(visitor);
				}
				deferral.Complete();
			}
			catch (Exception ex)
			{
				Debug.WriteLine(ex);
			}
		}
        private async void SearchBox_SuggestionsRequested(SearchBox sender, SearchBoxSuggestionsRequestedEventArgs args)
        {
            gloablvalue.SearchStudentId = SearchBox.QueryText;
            await DatabaseManagement.SearchStudentsInLecData(result);

            if (SearchBox.QueryText == "")
            {
                result.Text = "";
            }
            else if (result.Text == SearchBox.QueryText)
            {
                result.Text = "";
                await DatabaseManagement.LoadSpacificStudentInLecData(MainLongListSelector);
            }
            else
            {
                await DatabaseManagement.LoadAllStudentsInLecData(MainLongListSelector);
            }
        }
        public void SmiliesFilterOnSuggestedQuery(SearchBox sender, SearchBoxSuggestionsRequestedEventArgs args)
        {
            if (SmileCategoryList == null)
            {
                return;
            }
            string queryText = args.QueryText;

            if (string.IsNullOrEmpty(queryText))
            {
                return;
            }
            var suggestionCollection = args.Request.SearchSuggestionCollection;

            foreach (var smile in SmileCategoryList.SelectMany(smileCategory => smileCategory.SmileList.Where(smile => smile.Title.Contains(queryText))))
            {
                suggestionCollection.AppendQuerySuggestion(smile.Title);
            }
        }
        /// <summary>
        /// SearchBoxEventsSuggestionsRequested
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        public async void SearchBoxEventsSuggestionsRequested(SearchBox sender, SearchBoxSuggestionsRequestedEventArgs args)
        {
            //DetermineSearchBoxWidth();
            var queryText = args.QueryText;
            var request   = args.Request;
            var deferral  = request.GetDeferral();

            try
            {
                var source = await FavoritesDataSyncManager.GetInstance(DocumentLocation.Roaming);

                source.GetSeachSuggestions(queryText, request.SearchSuggestionCollection);
            }
            catch (Exception)
            {
            }
            finally
            {
                deferral.Complete();
            }
        }
Beispiel #35
0
        private async void SearchBox_SuggestionsRequested(SearchBox sender, SearchBoxSuggestionsRequestedEventArgs args)
        {
            var viewModel = DataContext as MainViewModel;

            if (viewModel == null)
            {
                return;
            }

            // make sure the search string isn't null, less than 3 chars, or more than 100 chars.
            // the minimum of 3 will help with suggestion api performance. it also has a hard limit of 100 chars
            if (viewModel.SearchString == null || viewModel.SearchString.Length < 3 || viewModel.SearchString.Length > 100)
            {
                return;
            }

            var deferral = args.Request.GetDeferral();

            try
            {
                // get the suggestions
                var suggestions = await viewModel.SearchSuggest();

                // append all suggestions to the search box suggestions box
                args.Request.SearchSuggestionCollection.AppendQuerySuggestions(suggestions.Select(s => s.Text));
                args.Request.SearchSuggestionCollection.AppendSearchSeparator("Top Tweeters");

                var imageUri = new Uri("ms-appx:///Assets/Azure.png");
                var imageRef = RandomAccessStreamReference.CreateFromUri(imageUri);

                foreach (var suggestResult in suggestions)
                {
                    args.Request.SearchSuggestionCollection.AppendResultSuggestion(suggestResult.Document.ScreenName, suggestResult.Document.Followers + " followers", "", imageRef, "");
                }
            }
            finally
            {
                deferral.Complete();
            }
        }
        private async Task SearchBoxSuggestionsRequested(SearchBoxSuggestionsRequestedEventArgs args)
        {
            var queryText = args.QueryText != null ? args.QueryText.Trim() : null;
            if (string.IsNullOrEmpty(queryText))
            {
                return;
            }

            var deferral = args.Request.GetDeferral();

            try
            {
                var suggestionCollection = args.Request.SearchSuggestionCollection;

                var querySuggestions = await _productCatalogRepository.GetSearchSuggestionsAsync(queryText);
                if (querySuggestions != null && querySuggestions.Count > 0)
                {
                    var querySuggestionCount = 0;
                    foreach (string suggestion in querySuggestions)
                    {
                        querySuggestionCount++;

                        suggestionCollection.AppendQuerySuggestion(suggestion);

                        if (querySuggestionCount >= MaxNumberOfSuggestions)
                        {
                            break;
                        }
                    }
                }
            }
            catch (Exception)
            {
                // Ignore any exceptions that occur trying to find search suggestions.
            }

            deferral.Complete();
        }
        /// <summary>
        /// Populates SearchBox with Suggestions when user enters text
        /// </summary>
        /// <param name="sender">The Xaml SearchBox</param>
        /// <param name="e">Event when user changes text in SearchBox</param>
        private void SearchBoxEventsSuggestionsRequested(object sender, SearchBoxSuggestionsRequestedEventArgs e)
        {
            if (!string.IsNullOrEmpty(e.QueryText))
            {
                // If the string matches the query text shown in the search box, add suggestion to the search box.
                AppendSuggestion(e.QueryText, e);

                foreach (string alternative in e.LinguisticDetails.QueryTextAlternatives)
                {
                    // If the string matches against one of the query alternatives, add suggestion to the search box.
                    AppendSuggestion(alternative, e);
                }
            }

            if (e.Request.SearchSuggestionCollection.Size > 0)
            {
                MainPage.Current.NotifyUser("Suggestions provided for query: " + e.QueryText, NotifyType.StatusMessage);
            }
            else
            {
                MainPage.Current.NotifyUser("No suggestions provided for query: " + e.QueryText, NotifyType.StatusMessage);
            }
        }
        /// <summary>
        /// Populates SearchBox with Suggestions when user enters text
        /// </summary>
        /// <param name="sender">The Xaml SearchBox</param>
        /// <param name="e">Event when user changes text in SearchBox</param>
        private void SearchBoxEventsSuggestionsRequested(object sender, SearchBoxSuggestionsRequestedEventArgs e)
        {
            string queryText = e.QueryText;
            if (!string.IsNullOrEmpty(queryText))
            {
                Windows.ApplicationModel.Search.SearchSuggestionCollection suggestionCollection = e.Request.SearchSuggestionCollection;
                foreach (string suggestion in suggestionList)
                {
                    if (suggestion.StartsWith(queryText, StringComparison.CurrentCultureIgnoreCase))
                    {
                        suggestionCollection.AppendQuerySuggestion(suggestion);
                    }
                }
            }

            if (e.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);
            }
        }
Beispiel #39
0
        private void SearchBox_SuggestionsRequested(SearchBox sender, SearchBoxSuggestionsRequestedEventArgs args)
        {

        }
 private void OnSuggestionsRequested(SearchBox searchBox, SearchBoxSuggestionsRequestedEventArgs args)
 {
     args.Request.SearchSuggestionCollection.AppendQuerySuggestion("Foo");
     args.Request.SearchSuggestionCollection.AppendQuerySuggestion("Bar");
 }
 private void SearchBox_OnSuggestionsRequested(SearchBox sender, SearchBoxSuggestionsRequestedEventArgs args)
 {
     ((MainPageViewModel)DataContext ).OnSearchPaneSuggestionsRequested(sender, args);
 }
Beispiel #42
0
        /// <summary>
        /// Populates SearchBox with Suggestions when user enters text
        /// </summary>
        /// <param name="sender">Xaml SearchBox</param>
        /// <param name="e">Event when user changes text in SearchBox</param>
        private async void SearchBoxEventsSuggestionsRequested(Object sender, SearchBoxSuggestionsRequestedEventArgs e)
        {
            var queryText = e.QueryText;
            if (string.IsNullOrEmpty(queryText))
            {
                //MainPage.Current.NotifyUser("Use the search control to submit a query", NotifyType.StatusMessage);
            }
            else
            {
                Random random = new Random();
                int r = random.Next();
                string key = System.Net.WebUtility.UrlEncode(queryText);
                string requestUrl = "http://replatform.cloudapp.net:8000/getsearchrec?v={0}&uuid={1}&type={2}&from={3}&to={4}&r={5}";
                requestUrl = String.Format(requestUrl, key, App.gDeviceName, App.gDeviceType, App.NavigationRoadmap.GetFrom(), App.NavigationRoadmap.GetTo(), r);

                // 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(requestUrl, request.SearchSuggestionCollection);
                    await task;

                    if (task.Status == TaskStatus.RanToCompletion)
                    {
                        if (request.SearchSuggestionCollection.Size > 0)
                        {
                            //
                        }
                        else
                        {
                            //
                        }
                    }
                }
                catch (TaskCanceledException)
                {
                    // We have canceled the task.
                }
                catch (FormatException)
                {
                    //
                }
                catch (Exception)
                {
                    //
                }
                finally
                {
                    deferral.Complete();
                }
            }
        }
        /// <summary>
        /// Populates SearchBox with Suggestions when user enters text
        /// </summary>
        /// <param name="sender">Xaml SearchBox</param>
        /// <param name="e">Event when user changes text in SearchBox</param>
        private async void SearchBoxEventsSuggestionsRequested(Object sender, SearchBoxSuggestionsRequestedEventArgs e)
        {
            var queryText = e.QueryText;
            if (string.IsNullOrEmpty(queryText))
            {
                MainPage.Current.NotifyUser("Use the search control to submit a query", NotifyType.StatusMessage);
            }
            else if (string.IsNullOrEmpty(UrlTextBox.Text))
            {
                MainPage.Current.NotifyUser("Please enter the web service URL", NotifyType.StatusMessage);
            }
            else
            {
                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(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)
                {
                    // 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();
                }
            }
        }
 void OnSuggestionsRequested(SearchBox sender, SearchBoxSuggestionsRequestedEventArgs args)
 {
     string[] terms = { "salt", "pepper", "water", "egg", "vinegar", "flour", "rice", "sugar", "oil" };
     IEnumerable<string> query = terms.Where(x => x.StartsWith(args.QueryText, StringComparison.OrdinalIgnoreCase));
     args.Request.SearchSuggestionCollection.AppendQuerySuggestions(query);
 }
        public void OnSearchPaneSuggestionsRequested(SearchBox sender, SearchBoxSuggestionsRequestedEventArgs args)
        {
            var request = args.Request;
            var matches = _citiesRepository.Get(x => x.Name.StartsWith(args.QueryText, StringComparison.OrdinalIgnoreCase))
                .Take(10)
                .ToList();
            var matchesTimeZones = _citiesRepository.GetAll().GroupBy(x => x.TimeZoneId).Where(x => x.Key.StartsWith(args.QueryText, StringComparison.OrdinalIgnoreCase))
                .Take(10)
                .ToList();
            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)
                .ToList();
            if (!resultSuggestion.Any())
                return;

            foreach (var match in resultSuggestion)
            {
                var image = RandomAccessStreamReference.CreateFromUri(new Uri(string.Format("ms-appx:///Assets/CountryflagsTile/{0}.png", match.CountryCode)));
                request.SearchSuggestionCollection.AppendResultSuggestion(match.Name,
                                                                          match.CountryName + ", " + match.State,
                                                                          match.Id.ToString(), image, match.CountryName);
            }
        }
Beispiel #46
0
		private static void searchBox_SuggestionsRequested(SearchBox sender, SearchBoxSuggestionsRequestedEventArgs args)
		{
			var deferral = args.Request.GetDeferral();
			GetSuggestions(deferral, sender, args);
		}
Beispiel #47
0
        private void SuggestionsRequested(SearchBox sender, SearchBoxSuggestionsRequestedEventArgs args)
        {
            if (args.QueryText == string.Empty)
            {
                return;
            }

            var suggestionCollection = args.Request.SearchSuggestionCollection;
            var queryText = args.QueryText.ToLower();

            foreach (TorrentViewModel torrent in (DataContext as MainPageViewModel).Torrents)
            {
                if (torrent.Name.ToLower().Contains(queryText))
                {
                    suggestionCollection.AppendQuerySuggestion(torrent.Name);
                }
            }
        }
Beispiel #48
0
 private void FilterBox_OnSuggestionsRequested(SearchBox sender, SearchBoxSuggestionsRequestedEventArgs args)
 {
     if (_vm.SmilieCategoryList == null) return;
     string queryText = args.QueryText;
     if (string.IsNullOrEmpty(queryText)) return;
     var suggestionCollection = args.Request.SearchSuggestionCollection;
     foreach (var smile in _vm.SmilieCategoryList.SelectMany(smileCategory => smileCategory.List.Where(smile => smile.Title.Contains(queryText))))
     {
         suggestionCollection.AppendQuerySuggestion(smile.Title);
     }
 }
Beispiel #49
0
        private void Search_SuggestionsRequested(SearchBox sender, SearchBoxSuggestionsRequestedEventArgs args)
        {
            string queryText = args.QueryText;
            if (!string.IsNullOrWhiteSpace(queryText))
            {
                var suggestionCollection = args.Request.SearchSuggestionCollection;
                // result suggestions
                var searchResults = SampleDataSource.Search(queryText, true);
                foreach (var result in searchResults.SelectMany(p => p.Items).Take(2))
                {
                    var imageUri = new Uri("ms-appx:///" + result.TileImagePath);
                    var imageSource = Windows.Storage.Streams.RandomAccessStreamReference.CreateFromUri(imageUri);
                    suggestionCollection.AppendResultSuggestion(result.Title, result.Description, result.UniqueId, imageSource, result.Description);
                }

                // separator
                suggestionCollection.AppendSearchSeparator("Suggestions");
                // query suggestions
                string[] suggestionList =
        {
            "三星", "苹果", "iphone", "华为", "huawei", "samsung", "小米", "联想", "中兴"
        };

                foreach (string suggestion in suggestionList)
                {
                    if (suggestion.StartsWith(queryText, StringComparison.CurrentCultureIgnoreCase))
                    {
                        suggestionCollection.AppendQuerySuggestion(suggestion);
                    }
                }
            }
        }