protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); fromStation = NavigationContext.QueryString.ContainsKey("fromStation") ? Stations.Get(NavigationContext.QueryString["fromStation"]) : null; excludeStation = NavigationContext.QueryString.ContainsKey("excludeStation") ? NavigationContext.QueryString["excludeStation"] : null; if (fromStation == null) { if (e.NavigationMode == NavigationMode.New) { if (Stations.Country == Country.UK) { Task.Run(() => InstallVoiceCommands()); } ErrorReporting.CheckForPreviousException(true); AppMetadata.CheckForNewVersion(); if (!Settings.GetBool(Setting.LocationServicesEnabled) && !Settings.GetBool(Setting.LocationServicesPromptShown)) { Settings.Set(Setting.LocationServicesPromptShown, true); if (Extensions.ShowMessageBox("Location Services", "This application uses your current location to improve the experience. Do you wish to give it permission to use your location?", "Use location", "No thanks")) { Settings.Set(Setting.LocationServicesEnabled, true); } } } } else { pivot.Title = fromStation.Name + " calling at"; nearest.Header = "Near " + fromStation.Name; } var removeBackEntry = NavigationContext.QueryString.ContainsKey("removeBackEntry"); if (removeBackEntry) { NavigationService.RemoveBackEntry(); } LocationService.PositionChanged += LoadNearestStations; LoadNearestStations(); RefreshRecentItemsList(); if (NavigationContext.QueryString.ContainsKey("initialFilter")) { filter.Text = NavigationContext.QueryString["initialFilter"]; pivot.SelectedIndex = 2; } else if (hasRecentItemsToDisplay) { pivot.SelectedIndex = 1; } else if (fromStation == null && Settings.GetBool(Setting.LocationServicesEnabled)) { pivot.SelectedIndex = 0; } else { pivot.SelectedIndex = 2; } }
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); if (departuresAndArrivalsTable != null) { ErrorReporting.Log("departuresAndArrivalsTable is not null"); Load(); return; } var stationStr = NavigationContext.QueryString["station"]; var from = Stations.Get(stationStr); var to = NavigationContext.QueryString.ContainsKey("callingAt") ? Stations.Get(NavigationContext.QueryString["callingAt"]) : null; var removeBackEntry = NavigationContext.QueryString.ContainsKey("removeBackEntry"); departuresAndArrivalsTable = DeparturesAndArrivalsTable.Create(from, to); title.Text = departuresAndArrivalsTable.ToString(); if (title.Text.Length > 40) { title.Text = title.Text.Replace(" calling at ", "\ncalling at "); } if (e.NavigationMode == NavigationMode.New) { RecentItems.Add(departuresAndArrivalsTable); } if (removeBackEntry) { NavigationService.RemoveBackEntry(); } if (departuresAndArrivalsTable.HasDestinationFilter) { var filterOrClearFilterItem = ApplicationBar.Buttons.Cast <ApplicationBarIconButton>().Single(button => button.Text == "Filter"); filterOrClearFilterItem.Text = "Clear Filter"; filterOrClearFilterItem.IconUri = new Uri("/Assets/Icons/dark/appbar.filter.clear.png", UriKind.Relative); var filterByAnotherDestinationItem = new ApplicationBarMenuItem("Filter by another destination"); filterByAnotherDestinationItem.Click += OnFilterByAnotherDestinationClick; ApplicationBar.MenuItems.Insert(0, filterByAnotherDestinationItem); var reverseJourneyItem = new ApplicationBarIconButton(new Uri("/Assets/Icons/dark/appbar.arrow.left.right.png", UriKind.Relative)) { Text = "Reverse" }; reverseJourneyItem.Click += OnReverseJourneyClick; ApplicationBar.Buttons.Insert(2, reverseJourneyItem); } if (!NavigationService.CanGoBack) { var homeButton = new ApplicationBarIconButton { IconUri = new Uri("/Assets/Icons/dark/appbar.list.png", UriKind.Relative), Text = "All Stations", }; homeButton.Click += OnHomeClick; ApplicationBar.Buttons.Remove(GetPinToStartButton()); ApplicationBar.Buttons.Add(homeButton); } else { GetPinToStartButton().IsEnabled = !IsStationPinnedToStart(); } CreateDirectionsPivotItem(); if (!Stations.Country.SupportsArrivals) { // when supportsArrivals is false PivotSelectionChanged won't be triggered Load(); } }