public async Task SetContent(IEnumerable <Stop> stops, bool isCurrent, DateTime startTime, GeoCoordinate sourceLocation, Stop sourceStop) { NameList.ItemsSource = stops.Select(s => s.Group).Distinct().Select(s => new HeaderModel { Stop = s.Stops.First(), IsLink = !isCurrent }).ToList(); var model = await ArrivalTrips.CalculateRoutes(stops, startTime, sourceLocation, sourceStop, MaximumDistance); var lines = new List <string>(); if (model.Count > 0) { double dist = model.First().Distance; if (sourceStop != null && stops.Contains(sourceStop)) { lines.Add(App.Common.Services.Resources.LocalizedStringOf("StopMapPosition")); } else if (dist > 10.0 && dist < MaximumDistance) { int minutes = (int)Math.Round(model.First().WalkTime.TotalMinutes); lines.Add(StringFactory.Format(App.Common.Services.Resources.LocalizedStringOf("StopMapDistance"), minutes > 1, StringFactory.LocalizeDistanceWithUnit(dist), minutes)); } if (model.First().IsFar) { IsDistanceIgnored = true; } RouteList.ItemsSource = model; lines.Add(StringFactory.Format(App.Common.Services.Resources.LocalizedStringOf("StopMapDepartures"), false, startTime.ToString("t"))); } else { RouteList.Visibility = Visibility.Collapsed; lines.Add(App.Common.Services.Resources.LocalizedStringOf("RoutePanelOutOfService")); } DetailsText.Text = String.Join("\n", lines); }
public async void ShowContent() { IsExpanded = true; FrontPanel.Visibility = Visibility.Collapsed; ContentPanel.Visibility = Visibility.Visible; if (unset) { if (!initialized) { throw new InvalidOperationException("Uninitalized pushpin showed."); } unset = false; NameList.ItemsSource = stops.Select(s => s.Group).Distinct().Select(s => new HeaderModel { Stop = s.Stops.First(), IsLink = !isCurrent }).ToList(); var model = await ArrivalTrips.CalculateRoutes(stops, startTime, sourceLocation, sourceStop, MaximumDistance); if (model.Count > 0) { double dist = model.First().Distance; DetailsText.Text = ""; if (sourceStop != null && stops.Contains(sourceStop)) { DetailsText.Text += AppResources.StopMapPosition + "\n"; } else if (dist > 10.0 && dist < MaximumDistance) { int minutes = (int)Math.Round(model.First().WalkTime.TotalMinutes); DetailsText.Text += StringFactory.Format(AppResources.StopMapDistance, minutes > 1, StringFactory.LocalizeDistanceWithUnit(dist), minutes); } if (model.First().IsFar) { IsDistanceIgnored = true; } RouteList.ItemsSource = model; DetailsText.Text += StringFactory.Format(AppResources.StopMapDepartures, false, startTime.ToString("t")); } else { RouteList.Visibility = Visibility.Collapsed; DetailsText.Text = AppResources.RoutePanelOutOfService; } } }