Exemple #1
0
        public async Task LoadTripAsync(Guid tripId, bool animateMap = true)
        {
            // As we need to have requested this permission for our background task, ask here
            await Geolocator.RequestAccessAsync();

            CurrentTrip = await _dataModelService.LoadTripAsync(tripId);

            Sights =
                new ObservableCollection <Sight>(
                    CurrentTrip.Sights.OrderBy(s => s.RankInDestination));

            BuildSightGroups();

            if (Map != null)
            {
                var boundingBox = GeoboundingBox.TryCompute(GetSightsPositions());
                if (animateMap)
                {
                    // Delay to allow the Map to finish loading - on faster machines, animation fails
                    await Task.Delay(500);

                    // We actually don't want to wait for the map to stop animating
                    // so we assign the task to a variable to remove the warning about await
                    var task = Map.TrySetViewBoundsAsync(boundingBox,
                                                         new Thickness {
                        Left = 48, Top = 48, Right = 48, Bottom = 48
                    },
                                                         MapAnimationKind.Bow);
                }
                else
                {
                    // We actually don't want to wait for the map to stop animating
                    // so we assign the task to a variable to remove the warning about await
                    var task = Map.TrySetViewBoundsAsync(boundingBox,
                                                         new Thickness {
                        Left = 48, Top = 48, Right = 48, Bottom = 48
                    },
                                                         MapAnimationKind.None);
                }
            }

            EatsControlViewModel = new EatsControlViewModel {
                CenterLocation = CurrentTrip.Location, Trip = CurrentTrip
            };
            try
            {
                EatsControlViewModel.IsLoadingEats = true;
                EatsControlViewModel.Eats          =
                    new ObservableCollection <Restaurant>(await RestaurantDataService.Current.GetRestaurantsForTripAsync(CurrentTrip));
            }
            finally
            {
                EatsControlViewModel.IsLoadingEats = false;
            }

            // Insert the M1_CreateTiles snippet here
        }