Esempio n. 1
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (!App.ViewModel.IsDataLoaded)
            {
                App.ViewModel.LoadDataSecond(myProgressObj);
                App.ViewModel.LoadData();


                listNews.ItemsSource = App.ViewModel.News;
            }

            list.ItemsSource = App.ViewModel.TempMissions;

            IsolatedStorageFile fileStorage = IsolatedStorageFile.GetUserStoreForApplication();
            StreamReader        sr          = null;
            List <String>       names       = new List <string>();

            try
            {
                sr = new StreamReader(new IsolatedStorageFileStream("Favourites.txt", FileMode.OpenOrCreate, fileStorage));
                while (!sr.EndOfStream)
                {
                    String line = sr.ReadLine();
                    names.Add(line);
                }
                sr.Close();
            }
            catch
            {
                MessageBox.Show("File not created");
            }
            App.ViewModel.Favourites.Clear();
            foreach (String st in names)
            {
                //Mission m = App.ViewModel.Missions.FirstOrDefault(x=>x.Name == st);
                Space_Apps_ATMTech.TempModels.MissionFull mf = App.ViewModel.TempMissions.Where(x => x.Mission.Title == st).FirstOrDefault();
                if (mf != null)
                {
                    App.ViewModel.TempMissions.FirstOrDefault(x => x.Mission.Title == st).Mission.Following = true;
                    App.ViewModel.Favourites.Add(mf);
                }
            }
        }
Esempio n. 2
0
        private void Pivot_LoadingPivotItem(object sender, PivotItemEventArgs e)
        {
            if (e.Item == missions)
            {
                ApplicationBar.IsVisible = true;
                refreshAppBar.IconUri    = new Uri("/Assets/search.png", UriKind.Relative);
                isInFeatured             = false;
                if (ApplicationBar.MenuItems.Count == 0)
                {
                    ApplicationBar.MenuItems.Add(nasaMissions);
                    ApplicationBar.MenuItems.Add(esaMissions);
                    ApplicationBar.MenuItems.Add(jaxaMissions);
                    ApplicationBar.MenuItems.Add(allMissions);
                }

                list.ItemsSource = App.ViewModel.TempMissions;
            }
            else if (e.Item == featured)
            {
                ApplicationBar.IsVisible = true;
                refreshAppBar.IconUri    = new Uri("/Assets/refresh.png", UriKind.Relative);
                ApplicationBar.MenuItems.Clear();
                isInFeatured = true;
            }
            else
            {
                ApplicationBar.IsVisible = false;
            }

            if (e.Item == favourites)
            {
                IsolatedStorageFile fileStorage = IsolatedStorageFile.GetUserStoreForApplication();
                StreamReader        sr          = null;
                List <String>       names       = new List <string>();
                try
                {
                    sr = new StreamReader(new IsolatedStorageFileStream("Favourites.txt", FileMode.OpenOrCreate, fileStorage));
                    while (!sr.EndOfStream)
                    {
                        String line = sr.ReadLine();
                        names.Add(line);
                    }
                    sr.Close();
                }
                catch
                {
                    MessageBox.Show("File not created");
                }
                App.ViewModel.Favourites.Clear();
                foreach (String st in names)
                {
                    //Mission m = App.ViewModel.Missions.FirstOrDefault(x=>x.Name == st);
                    Space_Apps_ATMTech.TempModels.MissionFull mf = App.ViewModel.TempMissions.Where(x => x.Mission.Title == st).FirstOrDefault();
                    if (mf != null)
                    {
                        App.ViewModel.TempMissions.FirstOrDefault(x => x.Mission.Title == st).Mission.Following = true;
                        App.ViewModel.Favourites.Add(mf);
                    }
                }
            }
        }