private void ShowImage() { string iconUrl = WeatherIcons.GetCurrentIcon(currentData.weather[0].icon); PictureWeather.ImageLocation = iconUrl; }
public async Task <ViewModel.Weather> GetWeather(Configuration.Configuration config) { ViewModel.Weather weather = new ViewModel.Weather(); WeatherNet.ClientSettings.ApiUrl = config.WeatherAPIUrl; WeatherNet.ClientSettings.ApiKey = config.WeatherAPIKey; // get current weather info var currentWeather = await WeatherNet.Clients.CurrentWeather.GetByCityNameAsync( config.WeatherCity, config.WeatherCountry, config.WeatherLanguage, config.WeatherUnits); if (!currentWeather.Success) { return(null); } weather.BeaufortWindScale = WIWindBeaufort.Beaufort[WIWindBeaufort.KMHToBeaufort(currentWeather.Item.WindSpeed)]; var now = DateTimeFactory.Instance.Now; weather.SunState = WeatherIcons.Sunrise; weather.SunStateTime = currentWeather.Item.Sunrise.ToString("HH:mm"); if (currentWeather.Item.Sunrise < now && currentWeather.Item.Sunset > now) { weather.SunState = WeatherIcons.Sunset; weather.SunStateTime = currentWeather.Item.Sunset.ToString("HH:mm"); } weather.Temperature = string.Format("{0:0.0}°", currentWeather.Item.Temp); weather.WeatherIcon = WeatherIcons.TryGetIcon(currentWeather.Item.Icon); var forecastDaily = await WeatherNet.Clients.FiveDaysForecast.GetByCityNameDailyAsync(config.WeatherCity, config.WeatherCountry, config.WeatherLanguage, config.WeatherUnits); var forecastDetail = await WeatherNet.Clients.FiveDaysForecast.GetByCityNameAsync(config.WeatherCity, config.WeatherCountry, config.WeatherLanguage, config.WeatherUnits); if (forecastDaily.Success) { foreach (var item in forecastDaily.Items) { var forecast = new ViewModel.WeatherForecast(); forecast.Icon = WeatherIcons.TryGetIcon(item.Icon); forecast.Day = item.Date.ToString("ddd."); forecast.MaxTemp = string.Format("{0:0.0}°", item.TempMax); forecast.MinTemp = string.Format("{0:0.0}°", item.TempMin); forecast.Temp = string.Format("{0:0.0}°", item.Temp); forecast.DMaxTemp = item.TempMax; forecast.DMinTemp = item.TempMin; forecast.DateTime = item.Date.Date; weather.Forecasts.Add(forecast); if (forecastDaily.Success) { var detailForecast = new ViewModel.WeatherForecast(); detailForecast.Update(forecast); if (detailForecast.DateTime.Day == now.Day) { detailForecast.Day = "Heute"; } else { detailForecast.Day = forecast.DateTime.ToString("dddd"); } var dtBegin = detailForecast.DateTime.Date; var dtEnd = dtBegin.AddDays(1); foreach (var itemdetail in forecastDetail.Items.Where(A => A.Date >= dtBegin && A.Date < dtEnd)) { ViewModel.WeatherForecastDetail detail = new ViewModel.WeatherForecastDetail(); detail.DateTime = itemdetail.Date; detail.Time = itemdetail.Date.ToString("HH:mm"); detail.Icon = WeatherIcons.TryGetIcon(itemdetail.Icon); detail.Temp = string.Format("{0:0.0}°", itemdetail.Temp); // TODO: MORE WEATHER INFO?? detailForecast.Details.Add(detail); } weather.ForecastDetails.Add(detailForecast); } } if (weather.Forecasts.Count > 0) { weather.Forecasts.RemoveAt(0); } } return(weather); }
private void OnPainting(object sender, SKPaintSurfaceEventArgs e) { var surface = e.Surface; var canvas = surface.Canvas; canvas.Clear(SKColors.White); var fontAwesome = "I {{fa-heart-o color=ff0000}} to {{fa-code}} on {{fa-windows color=1BA1E2}}!"; var ionIcons = "{{ion-ios-cloud-download-outline color=0000ff}} the SkiaSharp source from {{ion-social-github}}."; var materialDesignIcons = "SkiaSharp works on {{mdi-apple}}, {{mdi-android color=a4c639}}, {{mdi-windows}} and {{mdi-linux}}!"; var materialIcons = "SkiaSharp supports {{brush}} and {{photo color=006400}}!"; var meteocons = "We love the {{mc-sun color=f9d71c}} and some {{mc-cloud-double-o}} s."; var simple = "We all {{icon-heart color=ff0000}} a {{icon-present}}!"; var typicons = "SkiaSharp runs on {{typcn-device-desktop}}, {{typcn-device-laptop}}, {{typcn-device-phone}} and {{typcn-device-tablet}} devices!"; var weather = "An {{wi-solar-eclipse}} is when the {{wi-day-sunny color=f9d71c}} is hidden."; using (var lookup = new SKTextRunLookup()) using (var textPaint = new SKPaint()) { // the lookup does not have to be re-created on each draw // instead, it can be created and re-used FontAwesome.AddTo(lookup); IonIcons.AddTo(lookup); MaterialDesignIcons.AddTo(lookup); MaterialIcons.AddTo(lookup); Meteocons.AddTo(lookup); SimpleLineIcons.AddTo(lookup); Typicons.AddTo(lookup); WeatherIcons.AddTo(lookup); textPaint.IsAntialias = true; textPaint.TextSize = 48; textPaint.Typeface = SKTypeface.FromFamilyName("Arial"); // the DrawIconifiedText method will re-calculate the text runs // it may be better to cache this using the: // var runs = SKTextRun.Create(text, lookup); // and then drawing it using the DrawText method. var padding = 24; var yOffset = padding + textPaint.TextSize; canvas.DrawIconifiedText(fontAwesome, padding, yOffset, lookup, textPaint); yOffset += padding + textPaint.TextSize; canvas.DrawIconifiedText(ionIcons, padding, yOffset, lookup, textPaint); yOffset += padding + textPaint.TextSize; canvas.DrawIconifiedText(materialDesignIcons, padding, yOffset, lookup, textPaint); yOffset += padding + textPaint.TextSize; canvas.DrawIconifiedText(materialIcons, padding, yOffset, lookup, textPaint); yOffset += padding + textPaint.TextSize; canvas.DrawIconifiedText(meteocons, padding, yOffset, lookup, textPaint); yOffset += padding + textPaint.TextSize; canvas.DrawIconifiedText(simple, padding, yOffset, lookup, textPaint); yOffset += padding + textPaint.TextSize; canvas.DrawIconifiedText(typicons, padding, yOffset, lookup, textPaint); yOffset += padding + textPaint.TextSize; canvas.DrawIconifiedText(weather, padding, yOffset, lookup, textPaint); yOffset += padding + textPaint.TextSize; } }