Esempio n. 1
0
 public MainViewModel()
 {
     IsBusy       = true;
     NeedsRefresh = true;
     LocationType = LocationType.City;
     CityName     = "Amsterdam";
     CountryCode  = "NL";
     CurrentConditionsResponse = new WeatherInformation.ResponseWeather();
     CurrentConditionsCoord    = new WeatherInformation.Coord();
     //CurrentConditionsWeather = new List<WeatherInformation.Weather>();
     CurrentConditionsWeather = new WeatherInformation.Weather();
     CurrentConditionsMain    = new WeatherInformation.Main();
     CurrentConditionsWind    = new WeatherInformation.Wind();
     CurrentConditionsClouds  = new WeatherInformation.Clouds();
     CurrentConditionsSys     = new WeatherInformation.Sys();
     ChangedConditions        = new ChangedViewModel(CurrentConditionsMain);
 }
Esempio n. 2
0
        public async Task RefreshCurrentConditionsAsync()
        {
            IsBusy       = true;
            NeedsRefresh = false;

            WeatherInformation.ResponseWeather resultsResponse = null;

            switch (LocationType)
            {
            case LocationType.Location:
                if (Location == null)
                {
                    Location = await LocationHelper.GetCurrentLocationAsync();
                }
                resultsResponse = await WeatherHelper.GetCurrentConditionsAsync(Location.Latitude, Location.Longitude);

                break;

            case LocationType.City:
                resultsResponse = await WeatherHelper.GetCurrentConditionsAsync(CityName, CountryCode);

                break;
            }

            CurrentConditionsWeather.main        = resultsResponse.weather[0].main;
            CurrentConditionsWeather.description = resultsResponse.weather[0].description;
            //CurrentConditionsWeather[0].icon = resultsResponse.weather[0].icon;
            CurrentConditionsWeather.icon  = resultsResponse.weather[0].icon;
            CurrentConditionsResponse.name = resultsResponse.name;
            //CurrentConditionsResponse.weather.Contains() = resultsWeather;
            CurrentConditionsResponse.id   = resultsResponse.id;
            CurrentConditionsMain.temp_max = resultsResponse.main.temp_max;
            CurrentConditionsMain.temp_min = resultsResponse.main.temp_min;
            CurrentConditionsMain.temp     = resultsResponse.main.temp;
            //CurrentConditions.Humidity = results.Humidity;
            CurrentConditionsResponse.dt = resultsResponse.dt;

            ChangedConditions.temp_max = Convert.ToInt32(CurrentConditionsMain.temp_max - 273.15);
            ChangedConditions.temp_min = Convert.ToInt32(CurrentConditionsMain.temp_min - 273.15);
            ChangedConditions.temp     = Convert.ToInt32(CurrentConditionsMain.temp - 273.15);
            ChangedConditions.grades   = "C";

            IsBusy = false;
        }