Example #1
0
        private void queryButton_Click(object sender, RoutedEventArgs e)
        {
            string           query  = textBoxQuery.Text;
            ConditionsResult result = WeatherService.GetWeatherFor(query);

            if (result == null)
            {
                MessageBox.Show(WeatherService.message);
            }
            else
            {
                labelLocation.Content   = result.current_observation.display_location.full;
                labelTempF.Content      = "Temperature: " + result.current_observation.temperature_string;
                labelTempC.Content      = "Feels Like: " + result.current_observation.feelslike_string;
                labelElev.Content       = "Elevation: " + result.current_observation.display_location.elevation;
                labelLatLong.Content    = "Latitude / Longitude: " + result.current_observation.display_location.latitude + "/" + result.current_observation.display_location.longitude;
                labelWindDir.Content    = "Wind Direction: " + result.current_observation.wind_dir;
                labelConditions.Content = result.current_observation.weather;
                labelUpdate.Content     = result.current_observation.observation_time;
                labelHumid.Content      = "Humidity: " + result.current_observation.relative_humidity;
                labelVis.Content        = "Visibility: " + result.current_observation.visibility_mi + " miles";
                labelUV.Content         = "UV: " + result.current_observation.UV;
                labelPrec.Content       = "Precipitation: " + result.current_observation.precip_today_string;
                labelWind.Content       = "Wind: " + result.current_observation.wind_mph;
                weatherImage.Source     = (ImageSource) new ImageSourceConverter().ConvertFromString(result.current_observation.icon + ".gif");
            }
        }
Example #2
0
        public async void BtnGetWeather_ClickAsync(object sender, System.EventArgs e)
        {
            cityName = etCity.Text.ToString();
            if (etCity.Text.ToString().Length > 0)
            {
                progressBar.Visibility = ViewStates.Visible;
                WeatherService weatherService = new WeatherService();
                var            result         = await weatherService.GetWeather(etCity.Text.ToString());

                //WeatherInfo.RootObject weatherInfo = new WeatherInfo.RootObject();
                //weatherInfo = result;
                if (result == null)
                {
                    progressBar.Visibility = ViewStates.Invisible;
                    Toast.MakeText(Application, "Cannot load data", ToastLength.Short).Show();
                }
                else
                {
                    progressBar.Visibility = ViewStates.Invisible;
                    Intent weather_details = new Intent(this, typeof(WeatherDetailsActivity));
                    weather_details.PutExtra("DATA", JsonConvert.SerializeObject(result));
                    StartActivity(weather_details);
                }
            }
            else
            {
                Toast.MakeText(Application, "Please type a city name", ToastLength.Short).Show();
            }
        }
Example #3
0
        private static Current getWeatherXML()
        {
            Current current = new Current();
            WeatherService <Current> weatherService = new WeatherService <Current>();

            current = weatherService.GetWeather(true);
            return(current);
        }
Example #4
0
        private static RootObject getWeatherJSON()
        {
            RootObject rootObject = new RootObject();
            WeatherService <RootObject> weatherService = new WeatherService <RootObject>();

            rootObject = weatherService.GetWeather(false);
            return(rootObject);
        }
        static void Main(string[] args)
        {
            Console.WriteLine("Once the server starts, hit any key to call the weather service");
            Console.ReadLine();

            var client = new WeatherService(new Uri("http://localhost:5000"));

            client.GetWeatherForecast().ToList().ForEach(x => Console.WriteLine($"{x.Summary} at {x.TemperatureF}"));

            var zipCode = "98052";

            client.GetWeatherForecastByZipCode(zipCode).ToList().ForEach(x => Console.WriteLine($"The weather in {zipCode} is a {x.Summary} {x.TemperatureF}"));

            Console.WriteLine($"{Environment.NewLine}Called the weather service");
            Console.ReadLine();
        }
        private void searchButton_Click(object sender, RoutedEventArgs e)
        {
            if (textBoxSearch.Text.Length == 0)
            {
                return;
            }
            if (textBoxSearch.Text == PlaceholderSearch)
            {
                return;
            }
            WeatherResult wr = WeatherService.GetWeather(textBoxSearch.Text);

            if (wr != null)
            {
                labelCityNameZip.Content = wr.cityState + " " + wr.zipCode;

                labelCityLatLong.Content = "Latitude/Longitude: "
                                           + wr.latitude + "/" + wr.longitude;

                labelWeatherCondition.Content = wr.weather;

                labelElevation.Content = "Elevation: " + wr.elevation;

                labelLastUpdated.Content = wr.lastUpdated;

                labelTemperature.Content = "Temperature: " + wr.temperature;

                labelFeelsLike.Content = "Feels Like: " + wr.feelsLike;

                labelWind.Content = "Wind: " + wr.wind;

                labelWindDirection.Content = "Wind Direction: " + wr.windDirection;

                labelHumidity.Content = "Humidity: " + wr.humidity;

                labelVisibility.Content = "Visibility: " + wr.visibility;

                labelUV.Content = "UV: " + wr.uv;

                labelPrecipitation.Content = "Precipitation: " + wr.precipitation;

                setWeatherImage(wr.iconURL, wr.icon);
            }
        }
        private void GetWeather_Clicked(object sender, RoutedEventArgs e)
        {
            var weatherService = new WeatherService();
            var selectedValue  = (City)comboboxCities.SelectedItem;

            InnerCanvas.Visibility = Visibility.Visible;

            var weatherResponse = weatherService.GetWeatherResponse(selectedValue.Name).Result;

            icon.Source = weatherResponse.ImageDownloaded;

            WeatherDescriptionLabel.Content = weatherResponse.Weather.First().Description;
            TemperatureLabel.Content        = weatherResponse.Main.Temp + "°";
            FeelsLikeLabel.Content          = weatherResponse.Main.Feels_Like + "°";
            HumidityLabel.Content           = weatherResponse.Main.Humidity + "%";
            WindSpeedLabel.Content          = weatherResponse.Wind.Speed + " meter/sec";
            SunriseLabel.Content            = weatherResponse.Sys.Sunrise.FromMsToTime() + " in UTC";
            SunsetLabel.Content             = weatherResponse.Sys.Sunset.FromMsToTime() + " in UTC";
            CountryLabel.Content            = weatherResponse.Sys.Country;
        }