private async void LoadFavorites() { var favs = await Helpers.Favorites.LoadAsync(); try { var airportsDB = this.SourceManager.DataSources[DataSourceContentType.Airports] as IAirportDirectory; if (favs.Count() > 0) { this.Favorites = new ObservableCollection <AirportViewModel>(); var airports = favs.Select(f => airportsDB.GetAirportData(f)); foreach (var airport in airports) { var vm = new AirportViewModel(this.SourceManager); this.HasNetwork = SystemHelper.HasNetwork; await vm.LoadAirportDataAsync(airport.ICAO); this.Favorites.Add(vm); } } } catch (Exception ex) { Debug.WriteLine(ex.Message); } }
public async void AddWaypoint(string ICAO) { var avm = new AirportViewModel(this.SourceManager); await avm.LoadAirportDataAsync(ICAO); this.FlightPlan.AddWaypoint(avm.Airport); await this.LoadWaypoints(); }
private async void LoadAroundMe() { var airportsDB = this.SourceManager.DataSources[DataSourceContentType.Airports] as IAirportDirectory; var myPosition = await Helpers.Location.GetPosition(); var airportsNearMe = await airportsDB.GetAirportsAroundAsync(myPosition, this.AroundMeRadius); this.Nearest = new ObservableCollection <AirportViewModel>(); foreach (var airport in airportsNearMe) { var vm = new AirportViewModel(this.SourceManager); this.HasNetwork = SystemHelper.HasNetwork; await vm.LoadAirportDataAsync(airport.ICAO); this.Nearest.Add(vm); } }
private async Task LoadWaypoints() { if (this.Waypoints == null) { this.Waypoints = new ObservableCollection<AirportViewModel>(); } else { this.Waypoints.Clear(); } foreach (var wp in flightPlan.Waypoints) { var avm = new AirportViewModel(App.DataSourceManager); await avm.LoadAirportDataAsync(wp.ICAO); this.Waypoints.Add(avm); } this.Name = this.Waypoints.First().Airport.ICAO + " -> " + this.Waypoints.Last().Airport.ICAO; }
private async Task LoadWaypoints() { if (this.Waypoints == null) { this.Waypoints = new ObservableCollection <AirportViewModel>(); } else { this.Waypoints.Clear(); } foreach (var wp in flightPlan.Waypoints) { var avm = new AirportViewModel(App.DataSourceManager); await avm.LoadAirportDataAsync(wp.ICAO); this.Waypoints.Add(avm); } this.Name = this.Waypoints.First().Airport.ICAO + " -> " + this.Waypoints.Last().Airport.ICAO; }
private async Task StartSearch() { // Display error message instead? if (string.IsNullOrWhiteSpace(this.SearchQuery)) { this.ShowError = true; } else { var codes = this.SearchQuery.Split(' '); this.Results = new ObservableCollection <AirportViewModel>(); foreach (var airportCode in codes) { var r = new AirportViewModel(this.SourceManager); await r.LoadAirportDataAsync(airportCode); this.Results.Add(r); } } }
private async void LoadFavorites() { var favs = await Helpers.Favorites.LoadAsync(); try { var airportsDB = this.SourceManager.DataSources[DataSourceContentType.Airports] as IAirportDirectory; if (favs.Count() > 0) { this.Favorites = new ObservableCollection<AirportViewModel>(); var airports = favs.Select(f => airportsDB.GetAirportData(f)); foreach (var airport in airports) { var vm = new AirportViewModel(this.SourceManager); this.HasNetwork = SystemHelper.HasNetwork; await vm.LoadAirportDataAsync(airport.ICAO); this.Favorites.Add(vm); } } } catch (Exception ex) { Debug.WriteLine(ex.Message); } }
private async void LoadAroundMe() { var airportsDB = this.SourceManager.DataSources[DataSourceContentType.Airports] as IAirportDirectory; var myPosition = await Helpers.Location.GetPosition(); var airportsNearMe = await airportsDB.GetAirportsAroundAsync(myPosition, this.AroundMeRadius); this.Nearest = new ObservableCollection<AirportViewModel>(); foreach (var airport in airportsNearMe) { var vm = new AirportViewModel(this.SourceManager); this.HasNetwork = SystemHelper.HasNetwork; await vm.LoadAirportDataAsync(airport.ICAO); this.Nearest.Add(vm); } }
private async Task StartSearch() { // Display error message instead? if (string.IsNullOrWhiteSpace(this.SearchQuery)) { this.ShowError = true; } else { var codes = this.SearchQuery.Split(' '); this.Results = new ObservableCollection<AirportViewModel>(); foreach (var airportCode in codes) { var r = new AirportViewModel(this.SourceManager); await r.LoadAirportDataAsync(airportCode); this.Results.Add(r); } } }