예제 #1
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;
        }
예제 #2
0
        public async void RefreshCurrentConditionsAsync()
        {
            IsBusy       = true;
            NeedsRefresh = false;

            var results = await WeatherHelper.GetCurrentConditionsAsync(CityName, CountryCode);

            CurrentConditions.Conditions     = results.Conditions;
            CurrentConditions.Description    = results.Description;
            CurrentConditions.DisplayName    = results.DisplayName;
            CurrentConditions.Icon           = results.Icon;
            CurrentConditions.Id             = results.Id;
            CurrentConditions.MaxTemperature = results.MaxTemperature;
            CurrentConditions.MinTemperature = results.MinTemperature;
            CurrentConditions.Temperature    = results.Temperature;
            CurrentConditions.Humidity       = results.Humidity;
            CurrentConditions.TimeStamp      = results.TimeStamp.ToLocalTime();

            IsBusy = false;
        }