예제 #1
0
        public async void WeeklyWeather(string CityName)
        {
            objRest = new RESThandler(@"http://api.openweathermap.org/data/2.5/forecast/daily?q=" + CityName + ",NZ&units=metric&&cnt=6&appid=4523a891deaa6f198b0a55eb53303f6d");

            var Response = await objRest.ExecuteRequestAsync();

            string[] forecastDay  = new string[5];
            string[] forecastIcon = new string[5];
            string[] forecastHigh = new string[5];
            string[] forecastLow  = new string[5];
            for (int i = 0; i < forecastDay.Length; i++)
            {
                forecastDay[i]  = UnixTimeStampToDateTime(Response.list[i + 1].dt).ToString("dddd");
                forecastIcon[i] = Response.list[i + 1].weather[0].icon.ToString();
                forecastHigh[i] = Response.list[i + 1].temp.max.ToString() + "°C";
                forecastLow[i]  = Response.list[i + 1].temp.min.ToString() + "°C";
            }

            forecast = new Forecast[forecastDay.Length];

            for (int i = 0; i < forecastDay.Length; i++)
            {
                forecast[i] = new Forecast(forecastDay[i], forecastIcon[i], forecastHigh[i], forecastLow[i]);
            }

            objAdapter = new DataAdapter(this, forecast);

            lvWeeklyForecast.Adapter = objAdapter;
        }
예제 #2
0
        public async void DailyWeather(string CityName)
        {
            objRest = new RESThandler(@"http://api.openweathermap.org/data/2.5/weather?q=" + CityName + ",NZ&units=metric&appid=4523a891deaa6f198b0a55eb53303f6d");

            var Response = await objRest.ExecuteRequestAsync();

            txtCity.Text     = Response.name;
            txtTemp.Text     = Response.main.temp.ToString() + "°C";
            txtForecast.Text = Response.weather[0].description.ToString();
            txtLow.Text      = Response.main.temp_min.ToString() + "°C";
            txtHigh.Text     = Response.main.temp_max.ToString() + "°C";

            string iconRef = Response.weather[0].icon;

            GetImage(iconRef, ivWeatherToday);
        }