private void searchButton_Click(object sender, RoutedEventArgs e) { OpenWeatherServices openWeatherServices = new OpenWeatherServices(); WeatherInfo info = openWeatherServices.GetWeatherFor(searchTextBox.Text); temperatureLabel.Content = info.Main.temp + " °C"; mainWindow.Icon = new BitmapImage(new Uri($"http://openweathermap.org/img/wn/{info.weather[0].icon}@2x.png")); }
public static async Task <string> GetTextAsync() { string response = ""; try { response = await OpenWeatherServices.GetCurrentWeatherAsync(); WeatherResponse weatherResponse = JsonConvert.DeserializeObject <WeatherResponse>(response); response = $"Temperatura in {weatherResponse.Name} este {weatherResponse.Main.Temp} ℃"; } catch (Exception e) { MessageBox.Show(e.Message); response = "Error on calling WebApi"; } return(response); }