Esempio n. 1
0
        public CurrentForecastDataDisplayModel(string userInput, string choosenUnits, Label cityLabel, Label tempLabel,
                                               Label pressureLabel, Label humidityLabel, Label descrLabel, Label tempMaxLabel, Image weatherIcon,
                                               CurrentWeatherDataModel.RootObject currentData, DailyWeatherDataModel.RootObject dailyData)
        {
            _dailyData = dailyData;

            if (choosenUnits == "metric")
            {
                tempLabel.Text = Math.Round(Convert.ToDecimal(currentData.main.temp)).ToString() + "°C";

                tempMaxLabel.Text = GetMaxTemp().ToString() + "°C";
            }
            else
            {
                tempLabel.Text = Math.Round(Convert.ToDecimal(currentData.main.temp)).ToString() + "°F";

                tempMaxLabel.Text = GetMaxTemp().ToString() + "°F";
            }

            cityLabel.Text = userInput + "," + currentData.sys.country;

            pressureLabel.Text = currentData.main.pressure / 1000 + "Bar";

            humidityLabel.Text = currentData.main.humidity + "%";

            descrLabel.Text = currentData.weather.First().main;

            weatherIcon.Source = "http://openweathermap.org/img/wn/" + currentData.weather.First().icon + ".png";
        }
Esempio n. 2
0
        async void GetDataBtn_Clicked(object sender, System.EventArgs e)
        {
            OpenWeatherApi api = new OpenWeatherApi(UserInput(), ChoosenUnits());

            try
            {
                _currentData = await api.GetCurrentWeather();

                _dailyData = await api.GetDailyWeather();

                FillInCurrentForecast();
                FillHourlyForecast();

                await LoadAnimations();
            }
            catch (Exception ex)
            {
                ExceptionHandling(ex);
            }
        }