private void AnimateWindDirectionIcons(CurrentDataPoint currentWeather) { WindDirectionIcon.Rotate(currentWeather.WindBearing + 180, 15, 15).Start(); var baseAngle = 0; var visual = ElementCompositionPreview.GetElementVisual(WindDirectionIcon); var animationRotate = UI.CreateScalarAnimation(_compositor, baseAngle, baseAngle + 20); visual.RotationAxis = new Vector3(0, 0, 1); visual.CenterPoint = new Vector3(15, 15, 0); visual.StartAnimation("RotationAngleInDegrees", animationRotate); }
private void PopulateForecastView(DayDataPoint todayWeather, CurrentDataPoint currentWeather) { Status.Text = currentWeather.Summary; //FeelsLike.Text = string.Format("{0} {1}°{2}", App.ResourceLoader.GetString("FeelsLike"), // currentWeather.ApparentTemperature, Settings.GetTemperatureUnit()); PrecipProbaValue.Text = $"{todayWeather.PrecipitationProbability * 100}%"; HumidityValue.Text = $"{currentWeather.Humidity * 100}%"; UVIndexValue.Text = $"{currentWeather.UVIndex}"; VisibilityValue.Text = $"{currentWeather.Visibility}"; SunriseTime.Text = todayWeather.SunriseTime.ToLocalTime().ToString("HH:mm"); SunsetTime.Text = todayWeather.SunsetTime.ToLocalTime().ToString("HH:mm"); MoonriseTime.Text = todayWeather.SunsetTime.ToLocalTime().ToString("HH:mm"); MoonsetTime.Text = todayWeather.SunriseTime.ToLocalTime().ToString("HH:mm"); WindSpeed.Text = $"{currentWeather.WindSpeed}{GetWindSpeedUnits()}"; WindDirection.Text = $"{currentWeather.WindBearing}°"; CloudCover.Text = $"{currentWeather.CloudCover * 100}%"; SetPressureValue(currentWeather, true); if (_pageDataSource.Forecast.Daily.Days == null || _pageDataSource.Forecast.Daily.Days.Count == 0) { return; } var currentDay = _pageDataSource.Forecast.Daily.Days[0]; MaxTempValue.Text = $"{(int)currentDay.MaxTemperature}°"; MinTempValue.Text = $"{(int)currentDay.MinTemperature}°"; // TODO: Make a pull request to avoid UNIX time conversion (https://github.com/jcheng31/DarkSkyApi) DateTimeOffset baseUnixTime = new DateTimeOffset(1970, 1, 1, 0, 0, 0, new TimeSpan()); var converted = baseUnixTime.AddSeconds(currentDay.UVIndexTime); UVIndexTimeValue.Text = $"{converted.ToLocalTime().ToString("HH:mm")}"; }
public static Grid CreateNew(Forecast forecast, bool isPremiumUser, bool deactivateBackgroundColorAnimation = false) { CurrentDataPoint currentForecast = forecast.Currently; DayDataPoint todayForecast = forecast.Daily.Days[0]; InitializeVariables(todayForecast); var scene = new Grid(); scene = Backgrounds.PaintBackground(scene, currentForecast, todayForecast); if (!deactivateBackgroundColorAnimation) { scene = Backgrounds.AnimateBackgroundColor(scene, currentForecast.Icon, _screenSize); } scene = AddAnimations(scene, currentForecast.Icon); scene = Icons.AddWeatherIconCondition(scene, forecast, _IsDay, isPremiumUser); //scene = isPremiumUser ? AddSpecialEvents(scene, forecast) : scene; return(scene); }
private void SetPressureValue(CurrentDataPoint currentWeather, bool skipAnimation = false) { var unit = Settings.GetPressureUnit(); var pressure = currentWeather.Pressure; if (unit == null) { unit = GetPressureUnits(); } else { pressure *= 0.75006168f; } if (skipAnimation) { Pressure.Text = string.Format("{0}{1}", pressure, unit); return; } UI.AnimateNumericValue(pressure, Pressure, _UIDispatcher, unit, 100); }
public static Grid AddWeatherIconCondition(Grid scene, Forecast forecast, bool isDay = true, bool isPremiumUser = false) { _isPremiumUser = isPremiumUser; CurrentDataPoint currentForecast = forecast.Currently; DayDataPoint todayForecast = forecast.Daily.Days[0]; var topScene = new Grid() { Name = "PrimaryConditionScene", VerticalAlignment = VerticalAlignment.Top, HorizontalAlignment = HorizontalAlignment.Center, Margin = new Thickness(0, 200, 0, 0) }; var condition = currentForecast.Icon; Canvas weatherCondition = null; switch (condition) { case "clear-day": weatherCondition = CreateClearDayIcon(); break; case "clear-night": weatherCondition = CreateClearNightIcon(todayForecast); break; case "partly-cloudy-day": weatherCondition = CreatePartlyCloudyDayIcon(); break; case "partly-cloudy-night": weatherCondition = CreatePartlyCloudyNightIcon(todayForecast); break; case "cloudy": weatherCondition = isDay == true? CreateCloudyDayIcon() : CreateCloudyNightIcon(todayForecast); break; case "rain": weatherCondition = CreateRainIcon(); break; case "sleet": // neige fondu weatherCondition = CreateSnowIcon(); break; case "snow": weatherCondition = CreateSnowIcon(); break; case "wind": weatherCondition = CreateWindIcon(); break; case "fog": weatherCondition = CreateFogIcon(); break; default: break; } //weatherCondition = GetWeatherIcon(); // test prupose topScene.Children.Add(weatherCondition); scene.Children.Add(topScene); return(scene); }
public static Grid PaintBackground(Grid scene, CurrentDataPoint current, DayDataPoint day) { var condition = current.Icon; var gradient = new LinearGradientBrush(); var firstStop = new GradientStop() { Offset = 0.0 }; var lastStop = new GradientStop() { Offset = 0.5 }; switch (condition) { case "clear-day": firstStop.Color = Color.FromArgb(255, 249, 191, 59); lastStop.Color = Color.FromArgb(255, 249, 105, 14); break; case "clear-night": firstStop.Color = Color.FromArgb(255, 51, 110, 123); lastStop.Color = Color.FromArgb(255, 31, 58, 147); break; case "partly-cloudy-day": firstStop.Color = Color.FromArgb(255, 58, 83, 155); lastStop.Color = Color.FromArgb(255, 34, 49, 63); break; case "partly-cloudy-night": firstStop.Color = Color.FromArgb(255, 58, 83, 155); lastStop.Color = Color.FromArgb(255, 34, 49, 63); break; case "cloudy": firstStop.Color = Color.FromArgb(255, 34, 49, 63); lastStop.Color = Color.FromArgb(255, 103, 128, 159); break; case "rain": firstStop.Color = Color.FromArgb(255, 31, 58, 147); lastStop.Color = Color.FromArgb(255, 75, 119, 190); break; case "sleet": // neige fondu firstStop.Color = Color.FromArgb(255, 236, 240, 241); lastStop.Color = Color.FromArgb(255, 191, 191, 191); break; case "snow": firstStop.Color = Color.FromArgb(255, 236, 236, 236); lastStop.Color = Color.FromArgb(255, 255, 255, 255); break; case "wind": firstStop.Color = Color.FromArgb(255, 236, 236, 236); lastStop.Color = Color.FromArgb(255, 137, 196, 244); break; case "fog": firstStop.Color = Color.FromArgb(255, 107, 185, 240); lastStop.Color = Color.FromArgb(255, 174, 168, 211); break; default: firstStop.Color = Color.FromArgb(255, 249, 191, 59); lastStop.Color = Color.FromArgb(255, 211, 84, 0); break; } gradient.GradientStops.Add(firstStop); gradient.GradientStops.Add(lastStop); scene.Background = gradient; return(scene); }