From 948fd521cc0de8100ef01e90f24ef8b0cbc00734 Mon Sep 17 00:00:00 2001 From: Valeriy Mironov Date: Sat, 2 Feb 2019 23:22:00 +0200 Subject: [PATCH] WIP on new elemens --- Amazfit.sln.DotSettings | 1 + .../ActivityElements/FormattedNumber.cs | 3 ++ .../Elements/BasicElements/UnknownType.cs | 29 +++++++++++++++++++ .../Elements/BasicElements/UnknownType14d6.cs | 19 ++++++++++++ WatchFace.Parser/Elements/Battery.cs | 6 ++++ WatchFace.Parser/Elements/Date.cs | 6 ++++ .../Elements/DateElements/DateUnknown3.cs | 11 +++++++ WatchFace.Parser/Elements/Time.cs | 3 ++ WatchFace.Parser/Elements/UnknownType14.cs | 26 +++++++++++++++++ WatchFace.Parser/Utils/ParametersConverter.cs | 12 +++++--- WatchFace.Parser/WatchFace.Parser.csproj | 4 +++ WatchFace.Parser/WatchFace.cs | 3 ++ 12 files changed, 119 insertions(+), 4 deletions(-) create mode 100644 WatchFace.Parser/Elements/BasicElements/UnknownType.cs create mode 100644 WatchFace.Parser/Elements/BasicElements/UnknownType14d6.cs create mode 100644 WatchFace.Parser/Elements/DateElements/DateUnknown3.cs create mode 100644 WatchFace.Parser/Elements/UnknownType14.cs diff --git a/Amazfit.sln.DotSettings b/Amazfit.sln.DotSettings index ec62546..ef673c7 100644 --- a/Amazfit.sln.DotSettings +++ b/Amazfit.sln.DotSettings @@ -4,6 +4,7 @@ NEVER C:\Users\valeronm\AppData\Local\JetBrains\Transient\ReSharperPlatformVs15\v11_048a238b\SolutionCaches True + True True True True diff --git a/WatchFace.Parser/Elements/ActivityElements/FormattedNumber.cs b/WatchFace.Parser/Elements/ActivityElements/FormattedNumber.cs index 9207003..a0bc838 100644 --- a/WatchFace.Parser/Elements/ActivityElements/FormattedNumber.cs +++ b/WatchFace.Parser/Elements/ActivityElements/FormattedNumber.cs @@ -15,5 +15,8 @@ namespace WatchFace.Parser.Elements.ActivityElements [ParameterId(3)] [ParameterImageIndex] public long? DecimalPointImageIndex { get; set; } + + [ParameterId(4)] + public long? SuffixMilesImageIndex { get; set; } } } \ No newline at end of file diff --git a/WatchFace.Parser/Elements/BasicElements/UnknownType.cs b/WatchFace.Parser/Elements/BasicElements/UnknownType.cs new file mode 100644 index 0000000..9299792 --- /dev/null +++ b/WatchFace.Parser/Elements/BasicElements/UnknownType.cs @@ -0,0 +1,29 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using WatchFace.Parser.Attributes; +using WatchFace.Parser.Models; + +namespace WatchFace.Parser.Elements.BasicElements +{ + public class UnknownType + { + [ParameterId(1)] + public long TopLeftX { get; set; } + + [ParameterId(2)] + public long TopLeftY { get; set; } + + [ParameterId(3)] + public long BottomRightX { get; set; } + + [ParameterId(4)] + public long BottomRightY { get; set; } + + [ParameterId(5)] + [JsonConverter(typeof(StringEnumConverter))] + public TextAlignment Alignment { get; set; } + + [ParameterId(6)] + public long Spacing { get; set; } + } +} \ No newline at end of file diff --git a/WatchFace.Parser/Elements/BasicElements/UnknownType14d6.cs b/WatchFace.Parser/Elements/BasicElements/UnknownType14d6.cs new file mode 100644 index 0000000..365b912 --- /dev/null +++ b/WatchFace.Parser/Elements/BasicElements/UnknownType14d6.cs @@ -0,0 +1,19 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using WatchFace.Parser.Attributes; +using WatchFace.Parser.Models; + +namespace WatchFace.Parser.Elements.BasicElements +{ + public class UnknownType14d6 + { + [ParameterId(1)] + public Coordinates Unknown1 { get; set; } + + [ParameterId(2)] + public Coordinates Unknown2 { get; set; } + + [ParameterId(3)] + public long? Unknown3 { get; set; } + } +} \ No newline at end of file diff --git a/WatchFace.Parser/Elements/Battery.cs b/WatchFace.Parser/Elements/Battery.cs index 6d9879d..23e2049 100644 --- a/WatchFace.Parser/Elements/Battery.cs +++ b/WatchFace.Parser/Elements/Battery.cs @@ -13,5 +13,11 @@ namespace WatchFace.Parser.Elements [ParameterId(3)] public Scale Scale { get; set; } + + [ParameterId(5)] + public long? Unknown5 { get; set; } + + [ParameterId(6)] + public long? Unknown6 { get; set; } } } \ No newline at end of file diff --git a/WatchFace.Parser/Elements/Date.cs b/WatchFace.Parser/Elements/Date.cs index fe37c9b..42afd1c 100644 --- a/WatchFace.Parser/Elements/Date.cs +++ b/WatchFace.Parser/Elements/Date.cs @@ -11,5 +11,11 @@ namespace WatchFace.Parser.Elements [ParameterId(2)] public ImageSet WeekDay { get; set; } + + [ParameterId(3)] + public DateUnknown3 Unknown3 { get; set; } + + [ParameterId(4)] + public Coordinates Unknown4 { get; set; } } } \ No newline at end of file diff --git a/WatchFace.Parser/Elements/DateElements/DateUnknown3.cs b/WatchFace.Parser/Elements/DateElements/DateUnknown3.cs new file mode 100644 index 0000000..a01c2a5 --- /dev/null +++ b/WatchFace.Parser/Elements/DateElements/DateUnknown3.cs @@ -0,0 +1,11 @@ +using WatchFace.Parser.Attributes; +using WatchFace.Parser.Elements.BasicElements; + +namespace WatchFace.Parser.Elements.DateElements +{ + public class DateUnknown3 + { + [ParameterId(2)] + public UnknownType Unknown2 { get; set; } + } +} \ No newline at end of file diff --git a/WatchFace.Parser/Elements/Time.cs b/WatchFace.Parser/Elements/Time.cs index 0dd5ffd..6c7e94f 100644 --- a/WatchFace.Parser/Elements/Time.cs +++ b/WatchFace.Parser/Elements/Time.cs @@ -22,5 +22,8 @@ namespace WatchFace.Parser.Elements [JsonConverter(typeof(DrawingOrderJsonConverter))] [ParameterId(5)] public long? DrawingOrder { get; set; } + + [ParameterId(9)] + public long? Unknown9 { get; set; } } } \ No newline at end of file diff --git a/WatchFace.Parser/Elements/UnknownType14.cs b/WatchFace.Parser/Elements/UnknownType14.cs new file mode 100644 index 0000000..da9096b --- /dev/null +++ b/WatchFace.Parser/Elements/UnknownType14.cs @@ -0,0 +1,26 @@ +using Newtonsoft.Json; +using WatchFace.Parser.Attributes; +using WatchFace.Parser.Elements.BasicElements; +using WatchFace.Parser.Elements.TimeElements; +using WatchFace.Parser.JsonConverters; + +namespace WatchFace.Parser.Elements +{ + public class UnknownType14 + { + [ParameterId(1)] + public TwoDigits Unknown1 { get; set; } + + [ParameterId(2)] + public TwoDigits Unknown2 { get; set; } + + [ParameterId(6)] + public UnknownType14d6 Unknown6 { get; set; } + + [ParameterId(7)] + public UnknownType14d6 Unknown7 { get; set; } + + [ParameterId(8)] + public UnknownType14d6 Unknown8 { get; set; } + } +} \ No newline at end of file diff --git a/WatchFace.Parser/Utils/ParametersConverter.cs b/WatchFace.Parser/Utils/ParametersConverter.cs index c09a607..ebf9cd0 100644 --- a/WatchFace.Parser/Utils/ParametersConverter.cs +++ b/WatchFace.Parser/Utils/ParametersConverter.cs @@ -15,8 +15,6 @@ namespace WatchFace.Parser.Utils var result = new List(); var currentType = typeof(T); - if (!string.IsNullOrEmpty(path)) - Logger.Trace("{0} '{1}'", path, currentType.Name); foreach (var kv in ElementsHelper.SortedProperties()) { var id = kv.Key; @@ -52,13 +50,19 @@ namespace WatchFace.Parser.Utils else if (propertyType.IsGenericType && propertyType.GetGenericTypeDefinition() == typeof(List<>)) { foreach (var item in propertyValue) + { + Logger.Trace("{0} '{1}'", currentPath, propertyInfo.Name); result.Add(new Parameter(id, Build(item, currentPath))); + } } else { var innerParameters = Build(propertyValue, currentPath); if (innerParameters.Count > 0) + { + Logger.Trace("{0} '{1}'", currentPath, propertyInfo.Name); result.Add(new Parameter(id, innerParameters)); + } else Logger.Trace("{0} '{1}': Skipped because of empty", currentPath, propertyInfo.Name); } @@ -75,8 +79,6 @@ namespace WatchFace.Parser.Utils var thisMethod = typeof(ParametersConverter).GetMethod(nameof(Parse)); - if (!string.IsNullOrEmpty(path)) - Logger.Trace("{0} '{1}'", path, currentType.Name); foreach (var parameter in descriptor) { var currentPath = string.IsNullOrEmpty(path) @@ -111,6 +113,7 @@ namespace WatchFace.Parser.Utils } else if (propertyType.IsGenericType && propertyType.GetGenericTypeDefinition() == typeof(List<>)) { + Logger.Trace("{0} '{1}'", currentPath, propertyInfo.Name); dynamic propertyValue = propertyInfo.GetValue(result, null); if (propertyValue == null) { @@ -132,6 +135,7 @@ namespace WatchFace.Parser.Utils } else { + Logger.Trace("{0} '{1}'", currentPath, propertyInfo.Name); dynamic propertyValue = propertyInfo.GetValue(result, null); if (propertyValue != null) throw new ArgumentException($"Parameter {parameter.Id} is already set for {currentType.Name}"); diff --git a/WatchFace.Parser/WatchFace.Parser.csproj b/WatchFace.Parser/WatchFace.Parser.csproj index 14008da..06a799c 100644 --- a/WatchFace.Parser/WatchFace.Parser.csproj +++ b/WatchFace.Parser/WatchFace.Parser.csproj @@ -59,16 +59,20 @@ + + + + diff --git a/WatchFace.Parser/WatchFace.cs b/WatchFace.Parser/WatchFace.cs index 6eda388..e013b56 100644 --- a/WatchFace.Parser/WatchFace.cs +++ b/WatchFace.Parser/WatchFace.cs @@ -31,5 +31,8 @@ namespace WatchFace.Parser [ParameterId(10)] public AnalogDialFace AnalogDialFace { get; set; } + + [ParameterId(14)] + public UnknownType14 Unknown14 { get; set; } } } \ No newline at end of file