Exemplo n.º 1
0
 private void GetOpenWeaterDetails()
 {
     appId = ConfigurationManager.AppSettings["OpenWeather"];
     OpenWeather _weather = new OpenWeather(appId, SelectedCity.Name);
     string url = _weather.BuildUrl();
     OpenWeatherDetails weatherDetails = _weather.GetOpenWeatherDetails(url);
     _weatherDetails = weatherDetails;
     LoadOpenWeatherDates(weatherDetails);
 }
Exemplo n.º 2
0
 private void LoadOpenWeatherDates(OpenWeatherDetails wd)
 {
     Dates = new ObservableCollection<string>();
     wd.list.ForEach(x =>
     {
         string date = DateTime.Parse(x.dt_txt).ToShortDateString();
         if (!Dates.Contains(date))
             Dates.Add(date);
     });
     RaisePropertyChanged("Dates");
 }
Exemplo n.º 3
0
        private void GetOpenWeaterDetailsOffline(string city)
        {
            appId = ConfigurationManager.AppSettings["OpenWeather"];
            OpenWeather _weather = new OpenWeather(appId, SelectedCity.Name);

            string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory.Replace("bin\\Debug\\", "Offline Datas\\"), string.Format("{0}\\{1}.txt", SelectedWeatherSource, city));
            if (!File.Exists(path))
                throw new Exception(string.Format("Please download the data for {0} to work in offline mode.", city));

            OpenWeatherDetails weatherDetails = _weather.GetOpenWeatherDetailsOffline(File.ReadAllText(path));
            _weatherDetails = weatherDetails;
            LoadOpenWeatherDates(weatherDetails);
        }
Exemplo n.º 4
0
 public OpenWeatherViewModel(OpenWeatherDetails weatherinfo, string date)
 {
     _selectedDate = date;
     _weatherInfo  = weatherinfo;
 }