public async Task LoadSightAsync(Guid sightId) { CurrentSight = await _dataModelService.LoadSightAsync(sightId); CurrentSightFiles = new ObservableCollection <SightFile>(); SightImage = CurrentSight.ImageUri; foreach (var sightFile in CurrentSight.SightFiles) { // Only add Image files to the CurrentSightFiles list, not inking if (sightFile.FileType == SightFileType.ImageGallery) { CurrentSightFiles.Add(sightFile); } } SelectedSightFile = CurrentSightFiles.FirstOrDefault(); EatsControlViewModel = new EatsControlViewModel { CenterLocation = CurrentSight.Location, Sight = CurrentSight, IsDisplayingSightEats = true }; try { EatsControlViewModel.IsLoadingEats = true; EatsControlViewModel.Eats = new ObservableCollection <Restaurant>( await RestaurantDataService.Current.GetRestaurantsForSightAsync(CurrentSight)); } finally { EatsControlViewModel.IsLoadingEats = false; } }
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 }