// Esc/Dismiss void Update() { if (!inSearchMode && (Input.GetKey(KeyCode.LeftCommand) || Input.GetKey(KeyCode.RightCommand)) && Input.GetKey(KeyCode.F)) { StartSearching(); } if (!inSearchMode) { return; } if (Input.GetKey(KeyCode.Escape)) { StopSearching(); } else if (Input.GetKeyDown(KeyCode.DownArrow)) { SearchSuggestion.DownArrow(suggestion); } else if (Input.GetKeyDown(KeyCode.UpArrow)) { SearchSuggestion.UpArrow(suggestion); } else if (Input.GetKeyDown(KeyCode.Return)) { SearchSuggestion.selected.ClickOnPlace(); } }
private void OnSuggestionSelected(object sender, SearchSuggestion suggestion) { if (Element.BindingContext is SearchViewModel viewModel) { viewModel.SelectSuggestion(suggestion); } }
public static void ResetSelection() { if (selected != null) { currentlySelected = null; selected.Deselect(); selected = null; } }
public async Task SelectSuggestionAsync(SearchSuggestion suggestion) { // TODO FAZER A BUSCA BASEADO NO ITEM SELECIONADO System.Diagnostics.Debug.WriteLine($"Item selecionado na viewmodel: {suggestion.Description}"); Suggestions.Clear(); var resultsApi = await _api.GetSearchResults(); var resultsApp = resultsApi.ToSearchResultListApp(); }
// Typing suggestions public void TypingSuggestions(string text) { SearchSuggestion.ResetSelection(); if (text == "") { searchSuggestionsGroup.SetActive(false); return; } else { searchSuggestionsGroup.SetActive(true); RecalcualteSuggestions(text); } }
private async Task AcceptSuggestion(SearchSuggestion suggestion) { if (SearchViewModel == null || _acceptingSuggestionFlag) { return; } _acceptingSuggestionFlag = true; try { await SearchViewModel.AcceptSuggestion(suggestion); } finally { _acceptingSuggestionFlag = false; } }
/// <summary> /// /// </summary> /// <param name="query"></param> /// <returns></returns> private Object GetSource(String query) { try { if (String.IsNullOrEmpty(query)) { return(null); } Wikipedia wiki = new Wikipedia(new WikiQueryEngine()); SearchSuggestion suggestion = wiki.SearchArticles(query, 10); WikiControl omukControl = new WikiControl(); return(suggestion); } catch { } return(null); }
public static void UpArrow(SearchSuggestion[] suggestions) { if (!suggestions[0].isEnabled) { return; } if (currentlySelected == 0) { ResetSelection(); } else { currentlySelected--; selected.Deselect(); selected = suggestions[currentlySelected.Value]; selected.Select(); } }
public static void DownArrow(SearchSuggestion[] suggestions) { if (!suggestions[0].isEnabled) { return; } if (currentlySelected == null) { currentlySelected = 0; } else if (currentlySelected < 4 && suggestions[currentlySelected.Value + 1].isEnabled) { currentlySelected++; } if (selected != suggestions[currentlySelected.Value]) { if (selected != null) { selected.Deselect(); } selected = suggestions[currentlySelected.Value]; selected.Select(); } }
public String GetHtmlContent(string searchText, String data, String sense, Object source, Dictionary <String, String> uniqueLinks) { if (source == null) { source = this.GetSource(searchText); } if (source == null) { throw new ArgumentNullException("Source is NULL"); } this.suggestion = source as SearchSuggestion; if (source == null) { throw new InvalidCastException("Source is not of correct type"); } if (this.suggestion.Section == null) { throw new ArgumentException("No Data found"); } if (this.suggestion.Section.Length == 0) { throw new ArgumentException("No Data found"); } bool hasData = false; String html = String.Empty; html += "<tr>"; html += " <td id=\"tdWikipedia\" style=\"width: 100%;vertical-align: top\">"; html += " <table style=\"width: 100%\" cellpadding=\"0\" cellspacing=\"0\">"; html += " <tr>"; html += " <td style=\"border-bottom: solid 1px Silver; width: 100%; color: Black; font-family: Calibri;font-size: 16px;\">"; html += " <b>R</b>elated article(s) "; html += " <a href=\"http://wikipedia.org\" style=\"font-size:small;color:green;text-decoration:none;font-family:Calibri\">"; html += " source: wikipedia.org"; html += " </a>"; html += " </td>"; html += " </tr>"; for (int index = 0; index < this.suggestion.Section.Length && index < 5; index++) { SearchSuggestionItem sugItem = this.suggestion.Section[index]; if (uniqueLinks.ContainsKey(HttpUtility.UrlDecode(sugItem.Url.ToLower())) || uniqueLinks.ContainsKey(HttpUtility.UrlEncode(sugItem.Url.ToLower()))) { continue; } else { uniqueLinks.Add(HttpUtility.UrlDecode(sugItem.Url.ToLower()), String.Empty); } html += " <tr>"; html += " <td style=\"padding-bottom: 3px;\">"; html += " <a target=\"_blank\" href=\"" + sugItem.Url + "\" style=\"color:Blue;font-family: Calibri; font-size: medium\">"; html += sugItem.Text; html += " </a><br />"; html += " <span style=\"font-family: Calibri; font-size: small\">"; html += sugItem.Description; html += " </span>"; html += " </td>"; html += " </tr>"; hasData = true; } html += " </table>"; html += " </td>"; html += "</tr>"; html += "<tr><td style=\"height: 5px\"> </td></tr>"; return(hasData ? html : String.Empty); }
public void Update(SearchSuggestion searchSuggestion) { Name.Text = searchSuggestion.Description; }
/// <summary> /// Converts response data from Google Places API to SearchSuggestion, /// which is enhanced by Google Geocoding data. /// </summary> /// <param name="suggestions">List of suggestions (Google Places text search response)</param> /// <returns>List of generated Objects based on Places & Geocoding data</returns> public List <SearchSuggestion> ConvertToSearchSuggestion(PlacesAutocompleteResponseSuggestion[] suggestions) { return(suggestions .Where(v => v != null) .Select((suggestion) => { // Init new SearchSuggestion for each item in list var searchSuggestion = new SearchSuggestion { Name = suggestion.name, PlaceId = suggestion.place_id, Types = suggestion.types }; // Set information from google-places-api // Request Google-Geocode-API (get geocode information by Place-ID) var geocodeResponse = _googleGeocodingApiService.DoRequest(placeId: suggestion.place_id); // Check if response contains information about Place-ID if (geocodeResponse.results.Any(geocode => geocode.place_id == suggestion.place_id)) { // Get first matching result var geocodeFound = geocodeResponse.results.First(geocode => geocode.place_id == suggestion.place_id); /* * Set properties * * Information found? * -> true (set property) * -> false (set property to empty string) */ searchSuggestion.FormattedAddress = geocodeFound.formatted_address; searchSuggestion.StreetName = geocodeFound.address_components.Any(address => address.types.Contains("route")) ? geocodeFound.address_components.First(address => address.types.Contains("route")).long_name : ""; searchSuggestion.HouseNumber = geocodeFound.address_components.Any(address => address.types.Contains("street_number")) ? geocodeFound.address_components.First(address => address.types.Contains("street_number")).long_name : ""; searchSuggestion.City = geocodeFound.address_components.Any(address => address.types.Contains("locality")) ? geocodeFound.address_components.First(address => address.types.Contains("locality")).long_name : ""; searchSuggestion.PostalCode = geocodeFound.address_components.Any(address => address.types.Contains("postal_code")) ? geocodeFound.address_components.First(address => address.types.Contains("postal_code")).long_name : ""; searchSuggestion.Country = geocodeFound.address_components.Any(address => address.types.Contains("country")) ? geocodeFound.address_components.First(address => address.types.Contains("country")).long_name : ""; } else { // If no further information about place exists properties set to empty string searchSuggestion.FormattedAddress = ""; searchSuggestion.StreetName = ""; searchSuggestion.HouseNumber = ""; searchSuggestion.City = ""; searchSuggestion.PostalCode = ""; searchSuggestion.Country = ""; } return searchSuggestion; }) .ToList()); }
public void SelectSuggestion(SearchSuggestion suggestion) { // TODO FAZER A BUSCA BASEADO NO ITEM SELECIONADO System.Diagnostics.Debug.WriteLine($"Item selecionado na viewmodel: {suggestion.Description}"); Suggestions.Clear(); }