diff --git a/WatchFace.Parser/Elements/WeatherElements/AirPollution.cs b/WatchFace.Parser/Elements/WeatherElements/AirPollution.cs index fdb1690..ada8936 100644 --- a/WatchFace.Parser/Elements/WeatherElements/AirPollution.cs +++ b/WatchFace.Parser/Elements/WeatherElements/AirPollution.cs @@ -5,7 +5,8 @@ namespace WatchFace.Parser.Elements.WeatherElements { public class AirPollution { - // TODO: Looks like here should be Id 1 also + [ParameterId(1)] + public Number Index { get; set; } [ParameterId(2)] public ImageSet Icon { get; set; } diff --git a/WatchFace.Parser/Models/Elements/Weather/AirPollution/AirQualityIndexNumberElement.cs b/WatchFace.Parser/Models/Elements/Weather/AirPollution/AirQualityIndexNumberElement.cs new file mode 100644 index 0000000..4dacfe0 --- /dev/null +++ b/WatchFace.Parser/Models/Elements/Weather/AirPollution/AirQualityIndexNumberElement.cs @@ -0,0 +1,17 @@ +using System.Drawing; +using WatchFace.Parser.Interfaces; + +namespace WatchFace.Parser.Models.Elements +{ + public class AirQualityIndexNumberElement : NumberElement, IDrawable + { + public AirQualityIndexNumberElement(Parameter parameter, Element parent = null, string name = null) : + base(parameter, parent, name) { } + + public void Draw(Graphics drawer, Bitmap[] resources, WatchState state) + { + if (state.AirQualityIndex != null) + Draw(drawer, resources, state.AirQualityIndex.Value); + } + } +} \ No newline at end of file diff --git a/WatchFace.Parser/Models/Elements/Weather/AirPollutionElement.cs b/WatchFace.Parser/Models/Elements/Weather/AirPollutionElement.cs index a6e48ee..2985b66 100644 --- a/WatchFace.Parser/Models/Elements/Weather/AirPollutionElement.cs +++ b/WatchFace.Parser/Models/Elements/Weather/AirPollutionElement.cs @@ -5,12 +5,16 @@ public AirPollutionElement(Parameter parameter, Element parent = null, string name = null) : base(parameter, parent, name) { } + public AirQualityIndexNumberElement Index { get; set; } public AirPollutionImageElement Current { get; set; } protected override Element CreateChildForParameter(Parameter parameter) { switch (parameter.Id) { + case 1: + Index = new AirQualityIndexNumberElement(parameter, this); + return Index; case 2: Current = new AirPollutionImageElement(parameter, this); return Current; diff --git a/WatchFace.Parser/Models/WatchState.cs b/WatchFace.Parser/Models/WatchState.cs index d3fd13c..53e13c2 100644 --- a/WatchFace.Parser/Models/WatchState.cs +++ b/WatchFace.Parser/Models/WatchState.cs @@ -18,7 +18,10 @@ namespace WatchFace.Parser.Models public int? TomorrowDayTemperature { get; set; } public int? TomorrowNightTemperature { get; set; } public WeatherCondition CurrentWeather { get; set; } = WeatherCondition.Cloudy; + + // https://en.wikipedia.org/wiki/Air_quality_index#Mainland_China public AirCondition Air { get; set; } = AirCondition.Excellent; + public int? AirQualityIndex { get; set; } = 15; public int BatteryLevel { get; set; } = 67; public bool Bluetooth { get; set; } = true; diff --git a/WatchFace.Parser/PreviewGenerator.cs b/WatchFace.Parser/PreviewGenerator.cs index 59249a7..d25bc9b 100644 --- a/WatchFace.Parser/PreviewGenerator.cs +++ b/WatchFace.Parser/PreviewGenerator.cs @@ -21,7 +21,7 @@ namespace WatchFace.Parser for (var i = 0; i < 10; i++) { var num = i + 1; - watchState.BatteryLevel = num * 10; + watchState.BatteryLevel = 100 - (num * 10); watchState.Pulse = 60 + num * 2; watchState.Steps = num * 1000; @@ -36,6 +36,17 @@ namespace WatchFace.Parser watchState.DayTemperature += 2; watchState.NightTemperature += 4; + if (num < 3) + { + watchState.Air = AirCondition.Unknown; + watchState.AirQualityIndex = null; + } + else + { + watchState.Air = (AirCondition) (num - 3); + watchState.AirQualityIndex = (num - 2) * 50 - 25; + } + if (num < 3) watchState.CurrentTemperature = null; else if (num == 3) diff --git a/WatchFace.Parser/WatchFace.Parser.csproj b/WatchFace.Parser/WatchFace.Parser.csproj index 91ff268..fc360f4 100644 --- a/WatchFace.Parser/WatchFace.Parser.csproj +++ b/WatchFace.Parser/WatchFace.Parser.csproj @@ -120,6 +120,7 @@ +