protected override async void OnNavigatedTo(NavigationEventArgs e)
 {
     base.OnNavigatedTo(e);
     if (e.Parameter is string[])
     {
         var stop = await Data.GetBusStop(((string[])e.Parameter)[1], CancellationTokenSource.Token);
         var route = await Data.GetRoute(((string[])e.Parameter)[0], CancellationTokenSource.Token);
         string destination = ((string[])e.Parameter)[2];
         DescriptionBlock.Text = route.Value.Name + " to " + destination + " at " + stop.Value.Name;
         Windows.Devices.Geolocation.Geolocator locator = new Windows.Devices.Geolocation.Geolocator();
         TitleBox.Text = destination;
         string city = null;
         try
         {
             var finder = await MapLocationFinder.FindLocationsAtAsync(new Windows.Devices.Geolocation.Geopoint(stop.Value.Position));
             if (finder.Locations.Count > 0)
             {
                 city = finder.Locations[0].Address.Town;
                 CityContextBox.IsEnabled = true;
                 CityContextBox.Content = "In " + city;
             }
             else
             {
                 CityContextBox.Content = "(Could not get city)";
             }
         }
         catch (Exception)
         {
             CityContextBox.Content = "(Could not get city)";
         }
         location = new ContextLocation() { Latitude = stop.Value.Position.Latitude, Longitude = stop.Value.Position.Longitude, City = city };
         favorite = new FavoriteArrival() { Contexts = new LocationContext[0], Route = route.Value.ID, Stop = stop.Value.ID, Destination = destination };
     }
 }
Пример #2
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            if (!(obj is FavoriteArrival))
            {
                return(false);
            }
            FavoriteArrival typedObj = (FavoriteArrival)obj;

            return(typedObj.Route == Route && typedObj.Stop == Stop && typedObj.Destination == Destination);
        }
Пример #3
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            if (e.Parameter is string[])
            {
                var stop = await Data.GetBusStop(((string[])e.Parameter)[1], CancellationTokenSource.Token);

                var route = await Data.GetRoute(((string[])e.Parameter)[0], CancellationTokenSource.Token);

                string destination = ((string[])e.Parameter)[2];
                DescriptionBlock.Text = route.Value.Name + " to " + destination + " at " + stop.Value.Name;
                Windows.Devices.Geolocation.Geolocator locator = new Windows.Devices.Geolocation.Geolocator();
                TitleBox.Text = destination;
                string city = null;
                try
                {
                    var finder = await MapLocationFinder.FindLocationsAtAsync(new Windows.Devices.Geolocation.Geopoint(stop.Value.Position));

                    if (finder.Locations.Count > 0)
                    {
                        city = finder.Locations[0].Address.Town;
                        CityContextBox.IsEnabled = true;
                        CityContextBox.Content   = "In " + city;
                    }
                    else
                    {
                        CityContextBox.Content = "(Could not get city)";
                    }
                }
                catch (Exception)
                {
                    CityContextBox.Content = "(Could not get city)";
                }
                location = new ContextLocation()
                {
                    Latitude = stop.Value.Position.Latitude, Longitude = stop.Value.Position.Longitude, City = city
                };
                favorite = new FavoriteArrival()
                {
                    Contexts = new LocationContext[0], Route = route.Value.ID, Stop = stop.Value.ID, Destination = destination
                };
            }
        }