コード例 #1
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 };
     }
 }
コード例 #2
0
 public bool IsInContext(ContextLocation location)
 {
     if (Contexts == null && Contexts.Length == 0)
         return false;
     else
         return Contexts.Any(ctxt => ctxt.IsInContext(location));
 }
コード例 #3
0
 public bool IsInContext(ContextLocation location)
 {
     if (Contexts == null && Contexts.Length == 0)
     {
         return(false);
     }
     else
     {
         return(Contexts.Any(ctxt => ctxt.IsInContext(location)));
     }
 }
コード例 #4
0
 public override bool IsInContext(ContextLocation location)
 {
     switch (Direction)
     {
         case CardinalDirection.North:
             return location.Latitude >= RelativeLocation.Latitude;
         case CardinalDirection.South:
             return location.Latitude <= RelativeLocation.Latitude;
         case CardinalDirection.East:
             return location.Longitude >= RelativeLocation.Longitude;
         case CardinalDirection.West:
             return location.Longitude <= RelativeLocation.Longitude;
     }
     return false;
 }
コード例 #5
0
        public override bool IsInContext(ContextLocation location)
        {
            switch (Direction)
            {
            case CardinalDirection.North:
                return(location.Latitude >= RelativeLocation.Latitude);

            case CardinalDirection.South:
                return(location.Latitude <= RelativeLocation.Latitude);

            case CardinalDirection.East:
                return(location.Longitude >= RelativeLocation.Longitude);

            case CardinalDirection.West:
                return(location.Longitude <= RelativeLocation.Longitude);
            }
            return(false);
        }
コード例 #6
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
                };
            }
        }
コード例 #7
0
 public static double Distance(ContextLocation start, ContextLocation end)
 {
     return(HelperFunctions.GetDistanceBetweenPoints(start.Latitude, start.Longitude, end.Latitude, end.Longitude));
 }
コード例 #8
0
 public override bool IsInContext(ContextLocation location)
 {
     return ContextLocation.Distance(RelativeLocation, location) <= Distance;
 }
コード例 #9
0
 public override bool IsInContext(ContextLocation location)
 {
     return location.City == RelativeLocation.City;
 }
コード例 #10
0
 public abstract bool IsInContext(ContextLocation location);
コード例 #11
0
 public override bool IsInContext(ContextLocation location)
 {
     return(ContextLocation.Distance(RelativeLocation, location) <= Distance);
 }
コード例 #12
0
 public override bool IsInContext(ContextLocation location)
 {
     return(location.City == RelativeLocation.City);
 }
コード例 #13
0
 public abstract bool IsInContext(ContextLocation location);
コード例 #14
0
 public static double Distance(ContextLocation start, ContextLocation end)
 {
     return HelperFunctions.GetDistanceBetweenPoints(start.Latitude, start.Longitude, end.Latitude, end.Longitude);
 }