Пример #1
0
        public void Run(string city)
        {
            WeatherManager mgr;

            try
            {
                mgr = new WeatherManager(city);
            }
            catch (System.Net.WebException)
            {
                label2.Text       = "Nie znalaziono takiego miasta.";
                pictureBox1.Image = null;
                return;
            }
            WeatherInfo weatherInfo = mgr.weatherInfo;

            label2.Text = $"Temperatura w {weatherInfo.Name} wynosi teraz {weatherInfo.Main.Temp - 273} st. Celcjusza. Prędkość wiatru wynosi {weatherInfo.Wind.Speed} m/s, a ciśnienie {weatherInfo.Main.Pressure} hPa.";
            string    IconUrl    = "http://openweathermap.org/img/w/" + weatherInfo.Weather[0].Icon + ".png";
            string    IconPath   = weatherInfo.Weather[0].Icon + ".png";
            var       hs         = new HtmlSample(IconUrl);
            WebClient IconClient = new WebClient();

            IconClient.DownloadFile(IconUrl, IconPath);
            pictureBox1.ImageLocation = IconPath;
        }
Пример #2
0
 public void Create(string _url, string _word, string _mail, string _type, string _name, string _city, string _typeTemp, decimal _temp, string _conditionType)
 {
     Url      = _url;
     Word     = _word;
     Mail     = _mail;
     TaskType = _type;
     TaskName = _name;
     if (_city != "")
     {
         City           = _city;
         Wmgr           = new WeatherManager(City);
         TypeTempHeight = _typeTemp;
         TempHeight     = _temp;
     }
     ConditionType = _conditionType;
 }
Пример #3
0
        public void ExecuteQuest()
        {
            if (ConditionType == "Slowo")
            {
                UpdateImagePath();
                if (JpgPath != "")
                {
                    if (TaskType == "Wyślij e-mailem")
                    {
                        SendMail("Obrazek na dziś!", "Obrazek na dziś!");
                    }
                    else if (TaskType == "Wyświetl obraz")
                    {
                        ShowImage();
                    }
                }
            }
            else if (ConditionType == "Pogoda")
            {
                if (TaskType == "Wyślij e-mailem")
                {
                    Wmgr = new WeatherManager(City);
                    if (TypeTempHeight == "wyższa niż" && Wmgr.weatherInfo.Main.Temp > Convert.ToDouble(TempHeight) || TypeTempHeight == "niższa niż" && Wmgr.weatherInfo.Main.Temp < Convert.ToDouble(TempHeight))
                    {
                        string weather = $"Temperatura wynosi dzisiaj {Wmgr.weatherInfo.Main.Temp - 273} st. Celcjusza. Ciśnienie {Wmgr.weatherInfo.Main.Pressure} hPa.";

                        SendMail("Pogoda na dziś!", weather);
                        Console.WriteLine(City);
                    }
                }
                else if (TaskType == "Wyświetl obraz")
                {
                    Form_Weather form = new Form_Weather(City);
                    form.ShowDialog();
                }
            }
        }