public MainPage() { //ApplicationData.Current.LocalSettings.Values.Clear(); this.InitializeComponent(); this.NavigationCacheMode = Windows.UI.Xaml.Navigation.NavigationCacheMode.Enabled; SettingsPane.GetForCurrentView().CommandsRequested += SettingCharmManagerCommandsRequested; object countFav = ApplicationData.Current.RoamingSettings.Values["favStopsCount"]; if (countFav != null && (int)countFav != 0) { for (int i = 1; i <= (int)countFav; i++) { RoamingModel test = new RoamingModel() { Uri = ApplicationData.Current.RoamingSettings.Values["Uri" + i.ToString()].ToString(), Name = ApplicationData.Current.RoamingSettings.Values["Name" + i.ToString()].ToString(), Direction = ApplicationData.Current.RoamingSettings.Values["Direction" + i.ToString()].ToString() }; favStops.Add(test); } FavoritesListBox.ItemsSource = favStops; } else { ApplicationData.Current.RoamingSettings.Values["favStopsCount"] = 0; } object countLast = ApplicationData.Current.LocalSettings.Values["lastStopsCount"]; if (countLast != null && (int)countLast != 0) { for (int i = 1; i <= (int)countLast; i++) { RoamingModel test = new RoamingModel() { Uri = ApplicationData.Current.LocalSettings.Values["lastUri" + i.ToString()].ToString(), Name = ApplicationData.Current.LocalSettings.Values["lastName" + i.ToString()].ToString(), Direction = ApplicationData.Current.LocalSettings.Values["lastDirection" + i.ToString()].ToString() }; lastStops.Add(test); } LastSearchesListBox.ItemsSource = lastStops.Reverse(); } else { ApplicationData.Current.LocalSettings.Values["lastStopsCount"] = 0; } }
private void SaveFavouritesButtonClick(object sender, RoutedEventArgs e) { if (stop != null) { string s = stop.s; string lid = bus.lid; string rid = direction.rid; string vt = type.ID.ToString(); RoamingModel newStop = new RoamingModel() { Uri = "vehicle-vt?s=" + s + "&lid=" + lid + "&vt=" + vt + "&rid=" + rid, Name = stop.Name, Direction = direction.Name }; int currCount = (int)ApplicationData.Current.RoamingSettings.Values["favStopsCount"]; currCount++; ApplicationData.Current.RoamingSettings.Values["favStopsCount"] = currCount; favStops.Add(newStop); FavoritesListBox.ItemsSource = favStops; ApplicationData.Current.RoamingSettings.Values["Uri" + currCount.ToString()] = newStop.Uri; ApplicationData.Current.RoamingSettings.Values["Name" + currCount.ToString()] = newStop.Name; ApplicationData.Current.RoamingSettings.Values["Direction" + currCount.ToString()] = newStop.Direction; } else { } }
private void AddToLastSearched() { if (stop != null) { string s = stop.s; string lid = bus.lid; string rid = direction.rid; string vt = type.ID.ToString(); lastStop = new RoamingModel() { Uri = "vehicle-vt?s=" + s + "&lid=" + lid + "&vt=" + vt + "&rid=" + rid, Name = stop.Name, Direction = direction.Name }; int currCount = (int)ApplicationData.Current.LocalSettings.Values["lastStopsCount"]; currCount++; ApplicationData.Current.LocalSettings.Values["lastStopsCount"] = currCount; lastStops.Add(lastStop); LastSearchesListBox.ItemsSource = lastStops.Reverse(); ApplicationData.Current.LocalSettings.Values["lastUri" + currCount.ToString()] = lastStop.Uri; ApplicationData.Current.LocalSettings.Values["lastName" + currCount.ToString()] = lastStop.Name; ApplicationData.Current.LocalSettings.Values["lastDirection" + currCount.ToString()] = lastStop.Direction; } }