Exemplo n.º 1
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            var position = await LocationManager.GetPosition();

            RootObject myWeather = await OpenWeatherMapProxy.GetWeather(
                position.Coordinate.Latitude,
                position.Coordinate.Longitude);

            //ResultTextBlock.Text = $"{myWeather.name} - {myWeather.main.temp} K - {myWeather.weather[0].description}";
            //string icon = $"http://openweathermap.org/img/w/{myWeather.weather[0].icon}.png";
            //ResultImage.Source = new BitmapImage(new Uri(icon, UriKind.Absolute));
            //ResultImage.Source = new BitmapImage(new Uri($"http://openweathermap.org/img/w/{myWeather.weather[0].icon}.png", UriKind.Absolute));
            ResultImage.Source        = new BitmapImage(new Uri($"ms-appx:///Assets/Weather/{myWeather.weather[0].icon}.png", UriKind.Absolute));
            WeatherTextBlock.Text     = myWeather.weather[0].description;
            MapAsset.Text             = ((char)0xE707).ToString();
            Place.Text                = $"{myWeather.name},";
            TemperatureTextBlock.Text = $"{(myWeather.main.temp - 273).ToString()} {(char)0x00B0}C";

            GetWeatherButton.Visibility = Visibility.Collapsed;
        }
Exemplo n.º 2
0
        //private async void Button_Click(object sender, RoutedEventArgs e)
        //{
        //    var position = await LocationManager.GetPosition();

        //    var lattitude= 58.3698;// position.Coordinate.Latitude;
        //    var longitude = 26.7612;// position.Coordinate.Longitude;

        //    //RootObject myWeather = await OpenWeatherMapProxy.GetWeather(20.0, 30.0);
        //    RootObject myWeather =
        //        await OpenWeatherMapProxy.GetWeather(
        //            lattitude,
        //            longitude);

        //    //schedule update

        //    var uri = "http://uwplivetile.axtest.net/test01.xml";

        //    var tileContent = new Uri(uri);

        //    var requestedInterval = PeriodicUpdateRecurrence.HalfHour;

        //    var updater = TileUpdateManager.CreateTileUpdaterForApplication();
        //    updater.StartPeriodicUpdate(tileContent, requestedInterval);


        //    //string icon = String.Format("http://openweathermap.org/img/w/{0}.png", myWeather.weather[0].icon);
        //    string icon = String.Format("ms-appx:///Assets/Weather/{0}.png", myWeather.weather[0].icon);

        //    ResultTextBlock.Text = myWeather.name + ", " + ((int)myWeather.main.temp).ToString() + ", " + myWeather.weather[0].description;
        //    ResultImage.Source = new BitmapImage(new Uri(icon, UriKind.Absolute));
        //}

        private async void Page_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                var position = await LocationManager.GetPosition();

                var lattitude = 58.3698; // position.Coordinate.Latitude;
                var longitude = 26.7612; // position.Coordinate.Longitude;

                //RootObject myWeather = await OpenWeatherMapProxy.GetWeather(20.0, 30.0);
                RootObject myWeather =
                    await OpenWeatherMapProxy.GetWeather(
                        lattitude,
                        longitude);

                //schedule update

                var uri = "http://uwplivetile.axtest.net/test01.xml";

                var tileContent = new Uri(uri);

                var requestedInterval = PeriodicUpdateRecurrence.HalfHour;

                var updater = TileUpdateManager.CreateTileUpdaterForApplication();
                updater.StartPeriodicUpdate(tileContent, requestedInterval);


                //string icon = String.Format("http://openweathermap.org/img/w/{0}.png", myWeather.weather[0].icon);
                string icon = String.Format("ms-appx:///Assets/Weather/{0}.png", myWeather.weather[0].icon);

                TempResultTextBlock.Text        = ((int)myWeather.main.temp).ToString();
                DescriptionResultTextBlock.Text = myWeather.weather[0].description;
                LocationResultTextBlock.Text    = myWeather.name;
                ResultImage.Source = new BitmapImage(new Uri(icon, UriKind.Absolute));
            }

            catch
            {
                LocationResultTextBlock.Text = "No API connection!";
            }
        }
Exemplo n.º 3
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            var position = await LocationManager.GetPosition();

            Root myWeather = await OpenWeatherMapProxy.GetWeather(position.Coordinate.Latitude, position.Coordinate.Longitude);

            //Root myWeather = await OpenWeatherMapProxy.GetWeather(43.7315, -79.7624);

            CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture;
            TextInfo    textInfo    = cultureInfo.TextInfo;

            locationText.Text    = myWeather.name + ", " + myWeather.sys.country;
            temperatureText.Text = "Temperature ";
            degrees.Text         = (Math.Round(myWeather.main.temp)).ToString() + " C";
            skyStatus.Text       = textInfo.ToTitleCase(myWeather.weather[0].description);
            //string iconUrl = String.Format("http://openweathermap.org/img/wn/{0}@2x.png", myWeather.weather[0].icon);

            string iconUrl = String.Format("ms-appx:///Assets/Weather/{0}.png", myWeather.weather[0].icon);


            ResultImage.Source = new BitmapImage(new Uri(iconUrl, UriKind.Absolute));
        }