Beispiel #1
0
        void getWeather()

        {
            using (WebClient web = new WebClient())
            {
                string url = string.Format("http://api.openweathermap.org/data/2.5/weather?q=Tallinn&appid=cc34b74e92ab9aed1fb3daaa9ae68977&units=metric&cnt=6");

                var json = web.DownloadString(url);

                var result = JsonConvert.DeserializeObject <weatherInfo.root>(json);

                weatherInfo.root outPut = result;

                peaLinn.Text = string.Format("{0}", outPut.name);
                riik.Text    = string.Format("{0}", outPut.sys.country);
                temper.Text  = string.Format("{0} \u00B0 C", outPut.main.temp);

                var ikoon = outPut.id;
                if (ikoon >= 200 && ikoon <= 299)
                {
                    pilt.Image = Properties.Resources._200;
                }
                if (ikoon >= 300 && ikoon <= 499)
                {
                    pilt.Image = Properties.Resources._300;
                }
                if (ikoon >= 500 && ikoon <= 599)
                {
                    pilt.Image = Properties.Resources._500;
                }
                if (ikoon >= 600 && ikoon <= 699)
                {
                    pilt.Image = Properties.Resources._600;
                }
                if (ikoon >= 700 && ikoon <= 799)
                {
                    pilt.Image = Properties.Resources._700;
                }
                if (ikoon == 800)
                {
                    pilt.Image = Properties.Resources._800;
                }
                if (ikoon >= 801 && ikoon <= 804)
                {
                    pilt.Image = Properties.Resources._801;
                }
                else
                {
                    pilt.Image = Properties.Resources._800;
                }
            }
        }
Beispiel #2
0
        void getWeather()

        {
            using (WebClient web = new WebClient())
            {
                string url = string.Format("http://api.openweathermap.org/data/2.5/weather?q=Tallinn&appid=cc34b74e92ab9aed1fb3daaa9ae68977&units=metric&cnt=6");

                var json = web.DownloadString(url);

                var result = JsonConvert.DeserializeObject <weatherInfo.root>(json);

                weatherInfo.root outPut = result;

                peaLinn.Text = string.Format("{0}", outPut.name);
                riik.Text    = string.Format("{0}", outPut.sys.country);
                temper.Text  = string.Format("{0} \u00B0 C", outPut.main.temp);
            }
        }