示例#1
0
        // Five days forecast.
        public static FiveDaysForecast.RootObject fiveDaysForecast(string id)
        {
            FiveDaysForecast.RootObject fdf = new FiveDaysForecast.RootObject();
            string         url     = forecastUrl + id + "&appid=98d8eb3d190051551f5cdbb079b6670d";
            HttpWebRequest request = WebRequest.CreateHttp(url);

            request.Method = httpverb.GET.ToString();
            var response = request.GetResponse();

            var          dataStream  = response.GetResponseStream();
            StreamReader reader      = new StreamReader(dataStream);
            object       objResponse = reader.ReadToEnd();

            fdf = JsonConvert.DeserializeObject <FiveDaysForecast.RootObject>(objResponse.ToString());
            response.Close();

            return(fdf);
        }
示例#2
0
        // Returns the five days forecast.
        public void FiveDaysForecast()
        {
            FiveDaysForecast.RootObject forecast = new FiveDaysForecast.RootObject();
            forecast = RestClient.fiveDaysForecast("id=" + txtCityID.Text);
            List <FiveDaysForecast.List> fdfl = forecast.list;

            lblCountry2.Text = forecast.city.country;
            fdfl.ForEach(delegate(FiveDaysForecast.List fff)
            {
                listBox1.Items.Add("Temperature" + fff.main.temp.ToString() +
                                   "\nTemperature Min=" + fff.main.temp_min +
                                   "\nTemperature Max=" +
                                   "\nPressure:" + fff.main.pressure +
                                   "\nSea Level:" + fff.main.sea_level +
                                   "\nGround Level:" + fff.main.grnd_level +
                                   "\nHumidity:" + fff.main.humidity +
                                   "\nTemp kf:" + fff.main.temp_kf);
            });
        }