Ejemplo n.º 1
0
        // funtion for button action to send request
        async void OnGetWeatherButtonClicked(object sender, EventArgs e)
        {
            if (!string.IsNullOrWhiteSpace(_cityEntry.Text))
            {
                WeatherData weatherData = await _restService.GetWeatherData(GenerateRequestUri(Constants.OpenWeatherMapEndpoint));

                BindingContext = weatherData;
            }
        }
Ejemplo n.º 2
0
        async void OnGetWeatherButtonClicked(object sender, EventArgs e)
        {
            try
            {
                var location = await Geolocation.GetLastKnownLocationAsync();

                if (location != null)
                {
                    Console.WriteLine($"Latitude: {location.Latitude}, Longitude: {location.Longitude}, Altitude: {location.Altitude}");
                }
                else
                {
                    var request = new GeolocationRequest(GeolocationAccuracy.Default);
                    location = await Geolocation.GetLocationAsync(request);
                }

                WeatherData weatherData = await _restService.GetWeatherData(GenerateRequestUri(Constants.OpenWeatherMapEndpoint, location.Latitude, location.Longitude));

                BindingContext = weatherData;
            }
            catch (Exception ex)
            {
                Debug.WriteLine($"Boop beep: {ex}");
            }
        }
        async void OnGetWeatherButtonClicked(object sender, EventArgs e)
        {
            if (!string.IsNullOrWhiteSpace(_cityEntry.Text))
            {
                loadingData.IsVisible = true;
                EntitiyData entitiyData = await restService.GetWeatherData(GenerateRequestUri(Constants.Endpoint, "/weather"));

                data = entitiyData;

                BindingContext = data;

                listForecast.ItemsSource = await restService.GetForecastData(GenerateRequestUri(Constants.Endpoint, "/forecast"));

                loadingData.IsVisible = false;
                Console.WriteLine("DEBUG - Button Clicked!");
            }
        }
Ejemplo n.º 4
0
        async void OnGetWeatherButtonClicked(object sender, EventArgs e)
        {
            var weatherData = await _restService.GetWeatherData(GenerateRequestUri(Constants.OpenWeatherMapEndpoint + "GetWeather", ((Button)sender).Text));

            BindingContext  = new { weatherData };
            _cityEntry.Text = null;
            _cityEntry.Unfocus();
            ListViewCities.IsVisible   = false;
            ScrollViewResult.IsVisible = true;
        }
Ejemplo n.º 5
0
        protected override async void OnAppearing()
        {
            base.OnAppearing();

            if (_hasAppeared)
            {
                return;
            }

            _hasAppeared = true;
            var location = await Geolocation.GetLastKnownLocationAsync();

            if (location is null)
            {
                return;
            }

            var weatherData = await _restService.GetWeatherData(GenerateLocationRequestUri(Constants.OpenWeatherMapEndpoint, location));

            BindingContext = weatherData;
            RefreshFigure(weatherData);
        }
Ejemplo n.º 6
0
        async void getDayWeather(string cityName)
        {
            WeatherData weatherData = await restService.GetWeatherData(GenerateRequestUri(Constants.OpenWeatherMapEndpoint, cityName));

            PageWeather.WeatherData = weatherData;
            MainPageWeather newWether = new MainPageWeather()
            {
                ForecastData = PageWeather.ForecastData,
                WeatherData  = PageWeather.WeatherData
            };

            BindingContext = PageWeather;
        }
Ejemplo n.º 7
0
        async void OnGetWeatherButtonClicked(object sender, EventArgs e)
        {
            try
            {
                if (!string.IsNullOrWhiteSpace(_cityEntry.Text))
                {
                    WeatherDataCurrent weatherData = await _restService.GetWeatherData(GenerateRequestUri(Constants.EndpointCurrent));

                    // BindingContext = cm;
                    this.temperatura.Text = weatherData.data[0].temp.ToString();
                    this.humedad.Text     = weatherData.data[0].rh.ToString();
                    this.rayos.Text       = weatherData.data[0].uv.ToString();
                    this.descripcion.Text = weatherData.data[0].weather.description;
                }
            }
            catch (Exception ex)
            {
                string v = ex.Message;
            }
        }
        async void GetAPIData(string cityName)
        {
            if (!string.IsNullOrWhiteSpace(cityName))
            {
                WeatherData weatherData = await _restService.GetWeatherData(GenerateRequestUri(Constants.OpenWeatherMapEndpoint, cityName));

                if (weatherData == null)
                {
                    this.DisplayAlert("", "No internet connection", "OK");
                }
                else
                {
                    weatherImage.Source          = "http://openweathermap.org/img/w/" + weatherData.Weather[0].Icon + ".png";
                    weatherData.Main.Temperature = weatherData.Main.Temperature + "°C ";
                    weatherData.Main.Humidity    = weatherData.Main.Humidity + "%";
                    weatherData.Main.Pressure    = weatherData.Main.Pressure + "hPa";
                    BindingContext = weatherData;
                }
            }
        }
        async void FilterItem(string filter)
        {
            listOfCities.BeginRefresh();
            if (!string.IsNullOrWhiteSpace(filter))
            {
                WeatherData weatherData = await _restService.GetWeatherData(GenerateRequestUri(Constants.OpenWeatherMapEndpoint, filter));

                Cities = new List <WeatherData>();
                if (weatherData != null)
                {
                    Cities.Add(new WeatherData {
                        Title = weatherData.Title
                    });
                    listOfCities.ItemsSource = Cities;
                    listOfCities.ItemTapped += CityTapped;
                    BindingContext           = weatherData;
                }
            }
            listOfCities.EndRefresh();
        }
Ejemplo n.º 10
0
        async void OnGetWeatherButtonClicked(object sender, EventArgs e)
        {
            WeatherData weatherData = await _restService.GetWeatherData(GenerateRequestUri(Constants.OpenWeatherMapEndpoint));

            BindingContext = weatherData;
        }
Ejemplo n.º 11
0
        protected override async void OnAppearing()
        {
            string[,] alldate = new string[32, 4]
            {
                { "", "", "", "" },
                { "", "", "", "" },
                { "", "", "", "" },
                { "", "", "", "" },
                { "", "", "", "" },
                { "", "", "", "" },
                { "", "", "", "" },
                { "", "", "", "" },
                { "", "", "", "" },
                { "", "", "", "" },
                { "", "", "", "" },
                { "", "", "", "" },
                { "", "", "", "" },
                { "", "", "", "" },
                { "", "", "", "" },
                { "", "", "", "" },
                { "", "", "", "" },
                { "", "", "", "" },
                { "", "", "", "" },
                { "", "", "", "" },
                { "", "", "", "" },
                { "", "", "", "" },
                { "", "", "", "" },
                { "", "", "", "" },
                { "", "", "", "" },
                { "", "", "", "" },
                { "", "", "", "" },
                { "", "", "", "" },
                { "", "", "", "" },
                { "", "", "", "" },
                { "", "", "", "" },
                { "", "", "", "" },
            };            //6日のデータ格納する型(0行目は並び替え用)
            var result = await VEvent.GetStringAsync(uri);

            int x = 1;                                                  //ループカウント

            foreach (VEvent evset in result)
            {               //6日のデータを格納
                WeatherData weatherData = await _restService.GetWeatherData(GenerateRequestUri(Constants.OpenWeatherMapEndpoint, evset.CODE));

                BindingContext = weatherData;
                alldate[x, 0]  = evset.DTSTART;
                alldate[x, 1]  = evset.SUMMARY;
                alldate[x, 2]  = evset.ADDRESS;
                alldate[x, 3]  = weatherData.Weather[0].Description;
                x++;
            }
            for (int i = 1; i <= 31; i++)     //日付の昇順に並び替え
            {
                if (alldate[i, 0] == "")
                {
                    break;
                }
                for (int j = i + 1; j <= 31; j++)
                {
                    if (alldate[j, 0] == "")
                    {
                        break;
                    }
                    if (int.Parse(alldate[i, 0]) > int.Parse(alldate[j, 0]))
                    {
                        alldate[0, 0] = alldate[i, 0];
                        alldate[0, 1] = alldate[i, 1];
                        alldate[0, 2] = alldate[i, 2];
                        alldate[0, 3] = alldate[i, 3];
                        alldate[i, 0] = alldate[j, 0];
                        alldate[i, 1] = alldate[j, 1];
                        alldate[i, 2] = alldate[j, 2];
                        alldate[i, 3] = alldate[j, 3];
                        alldate[j, 0] = alldate[0, 0];
                        alldate[j, 1] = alldate[0, 1];
                        alldate[j, 2] = alldate[0, 2];
                        alldate[j, 3] = alldate[0, 3];
                    }
                }
            }
            int    y = 1;    //年月日を日付に変更
            string month;
            string day;

            while (alldate[y, 0] != "")
            {
                if (alldate[y, 0].Substring(4, 1) == "0")
                {
                    month = alldate[y, 0].Substring(5, 1) + "月";
                }
                else
                {
                    month = alldate[y, 0].Substring(4, 2) + "月";
                }
                day           = alldate[y, 0].Substring(6, 2) + "日";
                alldate[y, 0] = month + day;
                y++;
            }

            int cnt = 1;                                //ループカウント

            foreach (VEvent ev in result)               //ラベルに表示
            {
                if (cnt == 1)
                {
                    day1.Text         = alldate[cnt, 0];
                    today.Text        = alldate[cnt, 0];
                    summary1.Text     = alldate[cnt, 1];
                    summarytoday.Text = alldate[cnt, 1];
                    venue1.Text       = alldate[cnt, 2];
                    venuetoday.Text   = alldate[cnt, 2];
                    weather1.Text     = alldate[cnt, 3];
                    weathertoday.Text = alldate[cnt, 3];
                }
                if (cnt == 2)
                {
                    day2.Text     = alldate[cnt, 0];
                    summary2.Text = alldate[cnt, 1];
                    venue2.Text   = alldate[cnt, 2];
                    weather2.Text = alldate[cnt, 3];
                }
                if (cnt == 3)
                {
                    day3.Text     = alldate[cnt, 0];
                    summary3.Text = alldate[cnt, 1];
                    venue3.Text   = alldate[cnt, 2];
                    weather3.Text = alldate[cnt, 3];
                }
                if (cnt == 4)
                {
                    day4.Text     = alldate[cnt, 0];
                    summary4.Text = alldate[cnt, 1];
                    venue4.Text   = alldate[cnt, 2];
                    weather4.Text = alldate[cnt, 3];
                }
                if (cnt == 5)
                {
                    day5.Text     = alldate[cnt, 0];
                    summary5.Text = alldate[cnt, 1];
                    venue5.Text   = alldate[cnt, 2];
                    weather5.Text = alldate[cnt, 3];
                }
                if (cnt == 6)
                {
                    day6.Text     = alldate[cnt, 0];
                    summary6.Text = alldate[cnt, 1];
                    venue6.Text   = alldate[cnt, 2];
                    weather6.Text = alldate[cnt, 3];
                }
                cnt++;
            }
        }