Example #1
0
        private void LoadOldData()
        {
            CurrentConditionsWrapper myWrapper;

            using (IsolatedStorageFile myIso = IsolatedStorageFile.GetUserStoreForApplication())
            {
                if (!myIso.FileExists("Seattle.txt"))
                {
                    throw new FileNotFoundException();
                }

                using (StreamReader myReader = new StreamReader(new IsolatedStorageFileStream("Seattle.txt", FileMode.Open, myIso)))
                {
                    myWrapper = CurrentWeatherGetter.TranslateJson <CurrentConditionsWrapper>(myReader.ReadToEnd());
                }
            }

            // remove any previous data
            if (myWrapper != null)
            {
                CurrentWeatherViewModel forecast = new CurrentWeatherViewModel(myWrapper);
                this.Forecasts.Remove(forecast);
                this.Forecasts.Add(forecast);
            }
        }
Example #2
0
        private void ParseAsCurrent(Stream jsonStream)
        {
            CurrentConditionsWrapper myWrapper = CurrentWeatherGetter.TranslateJson <CurrentConditionsWrapper>(jsonStream);

            if (myWrapper == null)
            {
                return;
            }

            CurrentWeatherViewModel myView = new CurrentWeatherViewModel(myWrapper);

            //ObservableCollection<CurrentWeatherViewModel> newDataContext = new ObservableCollection<CurrentWeatherViewModel>();
            //newDataContext.Add(new CurrentWeatherViewModel(myWrapper));
            this.control.Dispatcher.BeginInvoke(delegate { control.DataContext = myView; });
        }