private async void Page_Loaded(object sender, RoutedEventArgs e) { try { var position = await LocationManager.GetPosition(); var lat = position.Coordinate.Latitude; var lon = position.Coordinate.Longitude; RootObject myWeather = await OpenWeatherMapProxy.GetWeather(lat, lon); //Schedule Update var uri = String.Format("http://uwpweatherservice.azurewebsites.net/?lat={0}&lon={1}", lat, lon); var tileContent = new Uri(uri); var requestedInterval = PeriodicUpdateRecurrence.HalfHour; var updater = TileUpdateManager.CreateTileUpdaterForApplication(); updater.StartPeriodicUpdate(tileContent, requestedInterval); string icon = String.Format("ms-appx:///Assets/Weather/{0}.png", myWeather.weather[0].icon); TempTextBlock.Text = ((int)myWeather.main.temp).ToString(); DescriptionTextBlock.Text = myWeather.weather[0].description; LocationTextBlock.Text = myWeather.name; ResultImage.Source = new BitmapImage(new Uri(icon, UriKind.Absolute)); } catch { LocationTextBlock.Text = "Unable to get weather at this time"; } }
private async void Page_Loaded(object sender, RoutedEventArgs e) { try { ErrorStackPanel.Visibility = Visibility.Collapsed; var position = await LocationManager.GetPosition(); var latitude = position.Latitude; var longitude = position.Longitude; var myWeather = await OpenWeatherMapProxy.GetWeather(latitude, longitude); TempTextBlock.Text = myWeather.main.temp.ToString(); DescriptionTextBlock.Text = myWeather.weather[0].description; LocationTextBlock.Text = myWeather.name; ResultImage.Source = new BitmapImage(new Uri(String.Format("ms-appx:///Assets/Weather/{0}.png", myWeather.weather[0].icon))); var updater = TileUpdateManager.CreateTileUpdaterForApplication(); //WARNING: Test code //The application URL must be your published URL var url = String.Format("http://localhost/Weather/?lat={0}&lon={1}", latitude, longitude); var tileContent = new Uri(url); updater.StartPeriodicUpdate(tileContent, PeriodicUpdateRecurrence.HalfHour); } catch { ErrorStackPanel.Visibility = Visibility.Visible; } }
private async void Button_Click(object sender, RoutedEventArgs e) { var position = await LocationManager.GetPosition(); var lat = position.Coordinate.Latitude; var lon = position.Coordinate.Longitude; RootObject myWeather = await OpenWeatherMapProxy .GetWeather(lat, lon); //RootObject myWeather = await OpenWeatherMapProxy // .GetWeather(); //Schedule update var uri = string.Format("http://uwpweatherappservice20160623104638.azurewebsites.net/?lat={0}&lon={1}", lat, lon); var tileContent = new Uri(uri); var requestedInterval = PeriodicUpdateRecurrence.HalfHour; var updater = TileUpdateManager.CreateTileUpdaterForApplication(); updater.StartPeriodicUpdate(tileContent, requestedInterval); string icon = String.Format("ms-appx:///Assets/Weather/{0}.png", myWeather.weather[0].icon); WeatherResultIcon.Source = new BitmapImage(new Uri(icon, UriKind.Absolute)); ResultTextBlock.Text = myWeather.name + " " + ((int)myWeather.main.temp).ToString() + " " + myWeather.weather[0].description + " " + myWeather.weather[0].icon.ToString(); }
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); string icon = String.Format("http://openweathermap.org/img/w/{0}.png", myWeather.weather[0].icon); ResultImage.Source = new BitmapImage(new Uri(icon, UriKind.Absolute)); ResultTextBlock.Text = myWeather.name + " - " + ((int)myWeather.main.temp).ToString() + " - " + myWeather.weather[0].description; }
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; }
//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!"; } }
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)); }