Beispiel #1
0
        private void AutoSuggestBoxTo_SuggestionChosen(AutoSuggestBox sender, AutoSuggestBoxSuggestionChosenEventArgs args)
        {
            // Set sender.Text. You can use args.SelectedItem to build your text string.
            var selectedText = args.SelectedItem as string;

            _to         = _placesService.GetMatrackPlaces().FirstOrDefault(x => x.Name == selectedText);
            Suggestions = new ObservableCollection <string>(_placesService.GetMatrackPlaces().Select(p => p.Name));
        }
Beispiel #2
0
        private async void BtnSearch_Click(object sender, RoutedEventArgs e)
        {
            MatrackPlace _from        = null;
            MatrackPlace _to          = null;
            var          locationFrom = new LocationDto();
            var          locationTo   = new LocationDto();

            try
            {
                if (_from == null)
                {
                    var request  = new GeolocationRequest(GeolocationAccuracy.High);
                    var location = await Geolocation.GetLocationAsync(request);

                    if (location != null)
                    {
                        var gpsLocation = new LocationDto
                        {
                            Altitude  = location.Altitude.ToString(),
                            Latitude  = location.Latitude.ToString(),
                            Longitude = location.Longitude.ToString()
                        };
                        locationFrom = gpsLocation;
                    }
                    if (_to == null)
                    {
                        _to = new MatrackPlace
                        {
                            Name        = "Nairobi CBD",
                            LocationDto = new LocationDto
                            {
                                Latitude  = "-1.292066",
                                Longitude = "36.821945"
                            }
                        };
                    }
                }
                else
                {
                    locationFrom = _from.LocationDto;
                }
                if (GlobalHelpers.HubConnection.State == HubConnectionState.Disconnected)
                {
                    await GlobalHelpers.HubConnection.StartAsync();
                }
                await GlobalHelpers.HubConnection.InvokeAsync("GetLocation",
                                                              _from, _to);
            }
            catch (Exception ex)
            {
                MessageDialog messageDialog = new MessageDialog(ex.Message);
                await messageDialog.ShowAsync();
            }
        }