private void BindData() { using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication()) { try { ObservableCollection<Route> routes = new ObservableCollection<Route>(); IsolatedStorageFileStream location = new IsolatedStorageFileStream("favoriteRoutes.dat", System.IO.FileMode.Open, storage); StreamReader sr = new StreamReader(location); string content = sr.ReadToEnd(); string[] strRoutes = content.Split(';'); foreach(string strTempRoute in strRoutes) { Route route = new Route(); string[] strRoute = strTempRoute.Split(','); if(strRoute[0] == WebService.GetCity()) { route.StartStat = strRoute[1]; route.EndStat = strRoute[2]; route.Info = strTempRoute + ";"; routes.Add(route); } } llsFavRoutes.ItemsSource = routes; location.Dispose(); } catch (Exception e1) { Debug.WriteLine(e1.Message); } } }
private void BindHistoryData() { using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication()) { try { ObservableCollection<Route> routes = new ObservableCollection<Route>(); if (storage.FileExists("HistoryRoutes.dat")) { IsolatedStorageFileStream location = new IsolatedStorageFileStream("HistoryRoutes.dat", System.IO.FileMode.Open, storage); StreamReader sr = new StreamReader(location); string content = sr.ReadToEnd(); sr.Close(); string[] strRoutes = content.Split(';'); foreach (string strTempRoute in strRoutes) { Route route = new Route(); string[] strRoute = strTempRoute.Split(','); if (strRoute[0] == WebService.GetCity()) { route.StartStat = strRoute[1]; route.EndStat = strRoute[2]; route.Info = strRoute[1] + "-" + strRoute[2]; routes.Add(route); } } llsHistory.ItemsSource = routes; tbkHistory.Visibility = Visibility.Visible; btnClearHistory.Visibility = Visibility.Visible; llsHistory.Visibility = Visibility.Visible; location.Dispose(); } else { tbkHistory.Visibility = Visibility.Collapsed; btnClearHistory.Visibility = Visibility.Collapsed; llsHistory.Visibility = Visibility.Collapsed; } } catch (Exception e1) { Debug.WriteLine(e1.Message); } } }