You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.1 KiB

1 year ago
namespace WeatherClient
{
public partial class MainPage : ContentPage
{
int count = 0;
public MainPage()
{
InitializeComponent();
}
private async void btnRefresh_Clicked(object sender, EventArgs e)
{
btnRefresh.IsEnabled = false;
actIsBusy.IsRunning = true;
Models.WeatherData weatherData = await Services.WeatherServer.GetWeather(txtPostalCode.Text);
lblWind.Text = weatherData.Wind.ToString();
lblHumidity.Text = weatherData.Humidity.ToString();
lblPrecipitation.Text = weatherData.Precipitation.ToString();
lblTemperature.Text = weatherData.Temperature.ToString("#");
imgCondition.Source = weatherData.Condition switch
{
Models.WeatherType.Sunny => ImageSource.FromFile("sunny.png"),
Models.WeatherType.Cloudy => ImageSource.FromFile("cloud.png"),
_ => ImageSource.FromFile("question.png")
};
btnRefresh.IsEnabled = true;
actIsBusy.IsRunning = false;
}
}
}