Example #1
0
        private void button_checkWeather_Click(object sender, EventArgs e)
        {
            string        json          = APICaller.GetWeatherFromOpenWeather(textBox_inputCity.Text);
            WeatherObject weatherObject = JsonConvert.DeserializeObject <WeatherObject>(json);

            UpdateWeather(weatherObject);
        }
Example #2
0
 private void UpdateWeather(WeatherObject weatherObject)
 {
     label_cityNameValue.Text     = weatherObject.Name;
     label_temperatureValue.Text  = Math.Round(weatherObject.Main.TempMax - 273).ToString() + " °C";
     label_skyConditionValue.Text = weatherObject.Weather[0].Description;
     label_pressureValue.Text     = weatherObject.Main.Pressure.ToString() + " hPa";
 }
Example #3
0
        private void StartSaveEventHandler()
        {
            WeatherObject weatherObject = CheckWeatherEventHandler();
            string        fileName      = weatherObject.Name + ".txt";

            FileWriter.WriteToFile(fileName, weatherObject);
        }
Example #4
0
        private WeatherObject CheckWeatherEventHandler()
        {
            string        json          = APICaller.GetWeatherFromOpenWeather(textBox_inputCity.Text);
            WeatherObject weatherObject = JsonConvert.DeserializeObject <WeatherObject>(json);

            UpdateWeather(weatherObject);
            return(weatherObject);
        }
Example #5
0
 static public void WriteToFile(string filePath, WeatherObject weatherObject)
 {
     using (System.IO.StreamWriter file = new System.IO.StreamWriter(filePath, true))
     {
         string singleLine = DateTime.Now.ToString() + " Temp: " + Math.Round(weatherObject.Main.Temp - 273) + " °C"
                             + " Sky Condition: " + weatherObject.Weather[0].Description
                             + " Pressure: " + weatherObject.Main.Pressure + " hPa";
         file.WriteLine(singleLine);
     }
 }