private void button_checkWeather_Click(object sender, EventArgs e) { string json = APICaller.GetWeatherFromOpenWeather(textBox_inputCity.Text); WeatherObject weatherObject = JsonConvert.DeserializeObject <WeatherObject>(json); UpdateWeather(weatherObject); }
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"; }
private void StartSaveEventHandler() { WeatherObject weatherObject = CheckWeatherEventHandler(); string fileName = weatherObject.Name + ".txt"; FileWriter.WriteToFile(fileName, weatherObject); }
private WeatherObject CheckWeatherEventHandler() { string json = APICaller.GetWeatherFromOpenWeather(textBox_inputCity.Text); WeatherObject weatherObject = JsonConvert.DeserializeObject <WeatherObject>(json); UpdateWeather(weatherObject); return(weatherObject); }
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); } }