Esempio n. 1
0
        private async void ToTextField_EditingChanged(object sender, EventArgs e)
        {
            try
            {
                var searchText = _toTextField.Text;
                if (!string.IsNullOrEmpty(searchText))
                {
                    var suggestions = await GeocodeHelper.SuggestAsync(searchText);

                    var suggestionTableSource = new TableSource <string>(suggestions, (s) => s);
                    suggestionTableSource.TableRowSelected += ToSuggestionTableSource_TableRowSelected;
                    _toAutoCompleteTableView.Source         = suggestionTableSource;
                    _toAutoCompleteTableView.ReloadData();
                    var oldFrame = _toAutoCompleteTableView.Frame;
                    _toAutoCompleteTableView.Frame  = new CGRect(oldFrame.Left, oldFrame.Top, oldFrame.Width, suggestions.Count() * 30f);
                    _toAutoCompleteTableView.Hidden = false;
                }
                else
                {
                    _toAutoCompleteTableView.Hidden = true;
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine($"{ex.Message}\n{ex.StackTrace}");
            }
        }
Esempio n. 2
0
        private async void search_QuerySubmitted(object s, AutoSuggestBoxQuerySubmittedEventArgs args)
        {
            string         query  = null;
            AutoSuggestBox sender = (AutoSuggestBox)s;

            if (args.ChosenSuggestion == null)
            {
                query       = (await GeocodeHelper.SuggestAsync(args.QueryText))?.FirstOrDefault();
                sender.Text = query;
            }
            else
            {
                query = args.ChosenSuggestion as string;
            }
            if (query != null)
            {
                if (sender == searchFrom)
                {
                    VM.GeocodeFromLocation(query);
                }
                else
                {
                    VM.GeocodeToLocation(query);
                }
            }
        }
        public async Task SuggestM3NW0_MultipleResults()
        {
            await ProvisioningTests.EnsureData();

            var result = await GeocodeHelper.SuggestAsync("M3NW0");

            Assert.AreEqual(8, result.Count());
            Assert.IsTrue(result.All(r => r.StartsWith("M3nw0")));
        }
        public async Task SuggestM3NW040_SingleResult()
        {
            await ProvisioningTests.EnsureData();

            var result = await GeocodeHelper.SuggestAsync("M3NW040");

            Assert.AreEqual(1, result.Count());
            Assert.AreEqual("M3nw040", result.First());
        }
        private async void Search_TextChanged(object sender, TextChangedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(e.NewTextValue))
            {
                (sender as AutoCompleteView).Suggestions = null;
            }
            else
            {
                var suggestions = await GeocodeHelper.SuggestAsync(e.NewTextValue);

                (sender as AutoCompleteView).Suggestions = suggestions.ToList();
            }
        }
Esempio n. 6
0
        private async void search_SuggestionsRequested(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args)
        {
            if (args.Reason == AutoSuggestionBoxTextChangeReason.UserInput)
            {
                if (string.IsNullOrWhiteSpace(sender.Text))
                {
                    sender.ItemsSource = null;
                }
                else
                {
                    var suggestions = await GeocodeHelper.SuggestAsync(sender.Text);

                    sender.ItemsSource = suggestions.ToList();
                }
            }
        }
Esempio n. 7
0
        private async void search_TextChanged(object s, AutoSuggestBoxTextChangedEventArgs args)
        {
            AutoSuggestBox sender = (AutoSuggestBox)s;

            // Only get results when it was a user typing,
            // otherwise assume the value got filled in by TextMemberPath
            // or the handler for SuggestionChosen.
            if (args.Reason == AutoSuggestionBoxTextChangeReason.UserInput)
            {
                if (string.IsNullOrWhiteSpace(sender.Text))
                {
                    sender.ItemsSource = null;
                }
                else
                {
                    var suggestions = await GeocodeHelper.SuggestAsync(sender.Text);

                    sender.ItemsSource = suggestions.ToList();
                }
            }
        }
Esempio n. 8
0
        private async void FromTextField_EditingChanged(object sender, EventArgs e)
        {
            var searchText = _fromTextField.Text;

            if (!string.IsNullOrEmpty(searchText))
            {
                var suggestions = await GeocodeHelper.SuggestAsync(searchText);

                var suggestionTableSource = new TableSource <string>(suggestions, (s) => s);
                suggestionTableSource.TableRowSelected += FromSuggestionTableSource_TableRowSelected;
                _fromAutoCompleteTableView.Source       = suggestionTableSource;
                _fromAutoCompleteTableView.ReloadData();
                var oldFrame = _fromAutoCompleteTableView.Frame;
                _fromAutoCompleteTableView.Frame  = new CGRect(oldFrame.Left, oldFrame.Top, oldFrame.Width, suggestions.Count() * 30f);
                _fromAutoCompleteTableView.Hidden = false;
            }
            else
            {
                _fromAutoCompleteTableView.Hidden = true;
            }
        }