From 3ce62f84469ff0e24bc8ee9b0496b6a83c67bfa9 Mon Sep 17 00:00:00 2001 From: Valeriy Mironov Date: Mon, 20 Nov 2017 09:11:33 +0200 Subject: [PATCH] Implemented reading structure of watch face and reading images --- AmazfitWFReader.sln | 64 +++++++++++++-- AmazfitWFReader/Form1.Designer.cs | 39 --------- AmazfitWFReader/Form1.cs | 20 ----- AmazfitWFReader/Program.cs | 22 ----- AmazfitWFReader/Properties/Settings.settings | 7 -- Cmd/App.config | 26 ++++++ Cmd/Cmd.csproj | 82 +++++++++++++++++++ Cmd/Program.cs | 52 ++++++++++++ .../Properties/AssemblyInfo.cs | 6 +- Cmd/packages.config | 56 +++++++++++++ {AmazfitWFReader => UI}/App.config | 0 UI/App.xaml | 9 ++ UI/App.xaml.cs | 17 ++++ UI/MainWindow.xaml | 24 ++++++ UI/MainWindow.xaml.cs | 28 +++++++ UI/Properties/AssemblyInfo.cs | 55 +++++++++++++ .../Properties/Resources.Designer.cs | 4 +- .../Properties/Resources.resx | 0 .../Properties/Settings.Designer.cs | 2 +- UI/Properties/Settings.settings | 7 ++ .../AmazfitWFReader.csproj => UI/UI.csproj | 74 +++++++++++------ WatchFace/Elements/Activity.cs | 16 ++++ WatchFace/Elements/Background.cs | 12 +++ WatchFace/Elements/Digit.cs | 18 ++++ WatchFace/Elements/Image.cs | 16 ++++ WatchFace/Elements/Number.cs | 27 ++++++ WatchFace/Elements/Switch.cs | 18 ++++ WatchFace/Elements/Time.cs | 18 ++++ WatchFace/Elements/TwoDigits.cs | 14 ++++ WatchFace/Models/Header.cs | 30 +++++++ WatchFace/Models/Image.cs | 78 ++++++++++++++++++ WatchFace/Models/Parameter.cs | 73 +++++++++++++++++ WatchFace/Models/ParameterFlags.cs | 12 +++ WatchFace/Models/Resource.cs | 16 ++++ WatchFace/Reader.cs | 77 +++++++++++++++++ WatchFace/Utils/BitReader.cs | 78 ++++++++++++++++++ WatchFace/WatchFace.csproj | 17 ++++ 37 files changed, 990 insertions(+), 124 deletions(-) delete mode 100644 AmazfitWFReader/Form1.Designer.cs delete mode 100644 AmazfitWFReader/Form1.cs delete mode 100644 AmazfitWFReader/Program.cs delete mode 100644 AmazfitWFReader/Properties/Settings.settings create mode 100644 Cmd/App.config create mode 100644 Cmd/Cmd.csproj create mode 100644 Cmd/Program.cs rename {AmazfitWFReader => Cmd}/Properties/AssemblyInfo.cs (89%) create mode 100644 Cmd/packages.config rename {AmazfitWFReader => UI}/App.config (100%) create mode 100644 UI/App.xaml create mode 100644 UI/App.xaml.cs create mode 100644 UI/MainWindow.xaml create mode 100644 UI/MainWindow.xaml.cs create mode 100644 UI/Properties/AssemblyInfo.cs rename {AmazfitWFReader => UI}/Properties/Resources.Designer.cs (94%) rename {AmazfitWFReader => UI}/Properties/Resources.resx (100%) rename {AmazfitWFReader => UI}/Properties/Settings.Designer.cs (96%) create mode 100644 UI/Properties/Settings.settings rename AmazfitWFReader/AmazfitWFReader.csproj => UI/UI.csproj (66%) create mode 100644 WatchFace/Elements/Activity.cs create mode 100644 WatchFace/Elements/Background.cs create mode 100644 WatchFace/Elements/Digit.cs create mode 100644 WatchFace/Elements/Image.cs create mode 100644 WatchFace/Elements/Number.cs create mode 100644 WatchFace/Elements/Switch.cs create mode 100644 WatchFace/Elements/Time.cs create mode 100644 WatchFace/Elements/TwoDigits.cs create mode 100644 WatchFace/Models/Header.cs create mode 100644 WatchFace/Models/Image.cs create mode 100644 WatchFace/Models/Parameter.cs create mode 100644 WatchFace/Models/ParameterFlags.cs create mode 100644 WatchFace/Models/Resource.cs create mode 100644 WatchFace/Reader.cs create mode 100644 WatchFace/Utils/BitReader.cs create mode 100644 WatchFace/WatchFace.csproj diff --git a/AmazfitWFReader.sln b/AmazfitWFReader.sln index 23176dc..bfce891 100644 --- a/AmazfitWFReader.sln +++ b/AmazfitWFReader.sln @@ -3,18 +3,72 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.27004.2009 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AmazfitWFReader", "AmazfitWFReader\AmazfitWFReader.csproj", "{20EDCAB3-CCDD-4170-80E0-73E30DD9FC85}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UI", "UI\UI.csproj", "{B05BAE0A-2C09-4910-924D-CA3DA0FA1CFD}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WatchFace", "WatchFace\WatchFace.csproj", "{8D2E0224-DE7F-4EC9-AD23-9904B9D7B409}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cmd", "Cmd\Cmd.csproj", "{A599B50E-754E-4C8F-A078-867B26E3DD09}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU + Debug|ARM = Debug|ARM + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 Release|Any CPU = Release|Any CPU + Release|ARM = Release|ARM + Release|x64 = Release|x64 + Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {20EDCAB3-CCDD-4170-80E0-73E30DD9FC85}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {20EDCAB3-CCDD-4170-80E0-73E30DD9FC85}.Debug|Any CPU.Build.0 = Debug|Any CPU - {20EDCAB3-CCDD-4170-80E0-73E30DD9FC85}.Release|Any CPU.ActiveCfg = Release|Any CPU - {20EDCAB3-CCDD-4170-80E0-73E30DD9FC85}.Release|Any CPU.Build.0 = Release|Any CPU + {B05BAE0A-2C09-4910-924D-CA3DA0FA1CFD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B05BAE0A-2C09-4910-924D-CA3DA0FA1CFD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B05BAE0A-2C09-4910-924D-CA3DA0FA1CFD}.Debug|ARM.ActiveCfg = Debug|Any CPU + {B05BAE0A-2C09-4910-924D-CA3DA0FA1CFD}.Debug|ARM.Build.0 = Debug|Any CPU + {B05BAE0A-2C09-4910-924D-CA3DA0FA1CFD}.Debug|x64.ActiveCfg = Debug|Any CPU + {B05BAE0A-2C09-4910-924D-CA3DA0FA1CFD}.Debug|x64.Build.0 = Debug|Any CPU + {B05BAE0A-2C09-4910-924D-CA3DA0FA1CFD}.Debug|x86.ActiveCfg = Debug|Any CPU + {B05BAE0A-2C09-4910-924D-CA3DA0FA1CFD}.Debug|x86.Build.0 = Debug|Any CPU + {B05BAE0A-2C09-4910-924D-CA3DA0FA1CFD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B05BAE0A-2C09-4910-924D-CA3DA0FA1CFD}.Release|Any CPU.Build.0 = Release|Any CPU + {B05BAE0A-2C09-4910-924D-CA3DA0FA1CFD}.Release|ARM.ActiveCfg = Release|Any CPU + {B05BAE0A-2C09-4910-924D-CA3DA0FA1CFD}.Release|ARM.Build.0 = Release|Any CPU + {B05BAE0A-2C09-4910-924D-CA3DA0FA1CFD}.Release|x64.ActiveCfg = Release|Any CPU + {B05BAE0A-2C09-4910-924D-CA3DA0FA1CFD}.Release|x64.Build.0 = Release|Any CPU + {B05BAE0A-2C09-4910-924D-CA3DA0FA1CFD}.Release|x86.ActiveCfg = Release|Any CPU + {B05BAE0A-2C09-4910-924D-CA3DA0FA1CFD}.Release|x86.Build.0 = Release|Any CPU + {8D2E0224-DE7F-4EC9-AD23-9904B9D7B409}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8D2E0224-DE7F-4EC9-AD23-9904B9D7B409}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8D2E0224-DE7F-4EC9-AD23-9904B9D7B409}.Debug|ARM.ActiveCfg = Debug|Any CPU + {8D2E0224-DE7F-4EC9-AD23-9904B9D7B409}.Debug|ARM.Build.0 = Debug|Any CPU + {8D2E0224-DE7F-4EC9-AD23-9904B9D7B409}.Debug|x64.ActiveCfg = Debug|Any CPU + {8D2E0224-DE7F-4EC9-AD23-9904B9D7B409}.Debug|x64.Build.0 = Debug|Any CPU + {8D2E0224-DE7F-4EC9-AD23-9904B9D7B409}.Debug|x86.ActiveCfg = Debug|Any CPU + {8D2E0224-DE7F-4EC9-AD23-9904B9D7B409}.Debug|x86.Build.0 = Debug|Any CPU + {8D2E0224-DE7F-4EC9-AD23-9904B9D7B409}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8D2E0224-DE7F-4EC9-AD23-9904B9D7B409}.Release|Any CPU.Build.0 = Release|Any CPU + {8D2E0224-DE7F-4EC9-AD23-9904B9D7B409}.Release|ARM.ActiveCfg = Release|Any CPU + {8D2E0224-DE7F-4EC9-AD23-9904B9D7B409}.Release|ARM.Build.0 = Release|Any CPU + {8D2E0224-DE7F-4EC9-AD23-9904B9D7B409}.Release|x64.ActiveCfg = Release|Any CPU + {8D2E0224-DE7F-4EC9-AD23-9904B9D7B409}.Release|x64.Build.0 = Release|Any CPU + {8D2E0224-DE7F-4EC9-AD23-9904B9D7B409}.Release|x86.ActiveCfg = Release|Any CPU + {8D2E0224-DE7F-4EC9-AD23-9904B9D7B409}.Release|x86.Build.0 = Release|Any CPU + {A599B50E-754E-4C8F-A078-867B26E3DD09}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A599B50E-754E-4C8F-A078-867B26E3DD09}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A599B50E-754E-4C8F-A078-867B26E3DD09}.Debug|ARM.ActiveCfg = Debug|Any CPU + {A599B50E-754E-4C8F-A078-867B26E3DD09}.Debug|ARM.Build.0 = Debug|Any CPU + {A599B50E-754E-4C8F-A078-867B26E3DD09}.Debug|x64.ActiveCfg = Debug|Any CPU + {A599B50E-754E-4C8F-A078-867B26E3DD09}.Debug|x64.Build.0 = Debug|Any CPU + {A599B50E-754E-4C8F-A078-867B26E3DD09}.Debug|x86.ActiveCfg = Debug|Any CPU + {A599B50E-754E-4C8F-A078-867B26E3DD09}.Debug|x86.Build.0 = Debug|Any CPU + {A599B50E-754E-4C8F-A078-867B26E3DD09}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A599B50E-754E-4C8F-A078-867B26E3DD09}.Release|Any CPU.Build.0 = Release|Any CPU + {A599B50E-754E-4C8F-A078-867B26E3DD09}.Release|ARM.ActiveCfg = Release|Any CPU + {A599B50E-754E-4C8F-A078-867B26E3DD09}.Release|ARM.Build.0 = Release|Any CPU + {A599B50E-754E-4C8F-A078-867B26E3DD09}.Release|x64.ActiveCfg = Release|Any CPU + {A599B50E-754E-4C8F-A078-867B26E3DD09}.Release|x64.Build.0 = Release|Any CPU + {A599B50E-754E-4C8F-A078-867B26E3DD09}.Release|x86.ActiveCfg = Release|Any CPU + {A599B50E-754E-4C8F-A078-867B26E3DD09}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/AmazfitWFReader/Form1.Designer.cs b/AmazfitWFReader/Form1.Designer.cs deleted file mode 100644 index aa7737e..0000000 --- a/AmazfitWFReader/Form1.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace AmazfitWFReader -{ - partial class Form1 - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Text = "Form1"; - } - - #endregion - } -} - diff --git a/AmazfitWFReader/Form1.cs b/AmazfitWFReader/Form1.cs deleted file mode 100644 index d5079dd..0000000 --- a/AmazfitWFReader/Form1.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; - -namespace AmazfitWFReader -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - } -} diff --git a/AmazfitWFReader/Program.cs b/AmazfitWFReader/Program.cs deleted file mode 100644 index e16b569..0000000 --- a/AmazfitWFReader/Program.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using System.Windows.Forms; - -namespace AmazfitWFReader -{ - static class Program - { - /// - /// The main entry point for the application. - /// - [STAThread] - static void Main() - { - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new Form1()); - } - } -} diff --git a/AmazfitWFReader/Properties/Settings.settings b/AmazfitWFReader/Properties/Settings.settings deleted file mode 100644 index 3964565..0000000 --- a/AmazfitWFReader/Properties/Settings.settings +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/Cmd/App.config b/Cmd/App.config new file mode 100644 index 0000000..e15b3f8 --- /dev/null +++ b/Cmd/App.config @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Cmd/Cmd.csproj b/Cmd/Cmd.csproj new file mode 100644 index 0000000..60a25d1 --- /dev/null +++ b/Cmd/Cmd.csproj @@ -0,0 +1,82 @@ + + + + + Debug + AnyCPU + {A599B50E-754E-4C8F-A078-867B26E3DD09} + Exe + Cmd + Cmd + v4.6.1 + 512 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\SixLabors.Core.1.0.0-beta0004\lib\netstandard1.1\SixLabors.Core.dll + + + ..\packages\SixLabors.ImageSharp.1.0.0-beta0002\lib\netstandard2.0\SixLabors.ImageSharp.dll + + + + ..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll + + + + + ..\packages\System.Diagnostics.DiagnosticSource.4.3.0\lib\net46\System.Diagnostics.DiagnosticSource.dll + + + + ..\packages\System.Memory.4.4.0-preview2-25405-01\lib\netstandard2.0\System.Memory.dll + + + + ..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll + + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.4.0\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll + + + + + + + + + + + + + + + + + + {8d2e0224-de7f-4ec9-ad23-9904b9d7b409} + WatchFace + + + + \ No newline at end of file diff --git a/Cmd/Program.cs b/Cmd/Program.cs new file mode 100644 index 0000000..cd78380 --- /dev/null +++ b/Cmd/Program.cs @@ -0,0 +1,52 @@ +using System; +using System.IO; +using System.Linq; +using WatchFace; +using WatchFace.Models; + +namespace Cmd +{ + class Program + { + static void Main(string[] args) + { + var fileName = args[0]; + Reader reader; + Console.WriteLine("Opening watch face: {0}", fileName); + using (var fileStream = File.OpenRead(fileName)) + { + reader = new Reader(fileStream); + reader.Parse(); + } + foreach (var resource in reader.Resources) + { + Console.WriteLine("{0:D}: ", resource.Id); + foreach (var descriptor in resource.Descriptor) + { + WriteParameter(4, descriptor); + } + } + + Console.ReadKey(); + } + + private static void WriteParameter(int offset, Parameter parameter) + { + for (var i = 0; i < offset; i++) + Console.Write(' '); + Console.Write("{0:D}: ", parameter.Id); + if (parameter.IsList) + { + Console.WriteLine(); + foreach (var parameter1 in parameter.List) + { + WriteParameter(offset + 4, parameter1); + } + } + else + { + Console.WriteLine("{0:D} (0x{0:x})", parameter.Value); + } + } + } +} diff --git a/AmazfitWFReader/Properties/AssemblyInfo.cs b/Cmd/Properties/AssemblyInfo.cs similarity index 89% rename from AmazfitWFReader/Properties/AssemblyInfo.cs rename to Cmd/Properties/AssemblyInfo.cs index 976618d..109f299 100644 --- a/AmazfitWFReader/Properties/AssemblyInfo.cs +++ b/Cmd/Properties/AssemblyInfo.cs @@ -5,11 +5,11 @@ using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. -[assembly: AssemblyTitle("AmazfitWFReader")] +[assembly: AssemblyTitle("Cmd")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("AmazfitWFReader")] +[assembly: AssemblyProduct("Cmd")] [assembly: AssemblyCopyright("Copyright © 2017")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -20,7 +20,7 @@ using System.Runtime.InteropServices; [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("20edcab3-ccdd-4170-80e0-73e30dd9fc85")] +[assembly: Guid("a599b50e-754e-4c8f-a078-867b26e3dd09")] // Version information for an assembly consists of the following four values: // diff --git a/Cmd/packages.config b/Cmd/packages.config new file mode 100644 index 0000000..0caaa5b --- /dev/null +++ b/Cmd/packages.config @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/AmazfitWFReader/App.config b/UI/App.config similarity index 100% rename from AmazfitWFReader/App.config rename to UI/App.config diff --git a/UI/App.xaml b/UI/App.xaml new file mode 100644 index 0000000..db385e4 --- /dev/null +++ b/UI/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/UI/App.xaml.cs b/UI/App.xaml.cs new file mode 100644 index 0000000..61f8a46 --- /dev/null +++ b/UI/App.xaml.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; + +namespace UI +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + } +} diff --git a/UI/MainWindow.xaml b/UI/MainWindow.xaml new file mode 100644 index 0000000..9d794c3 --- /dev/null +++ b/UI/MainWindow.xaml @@ -0,0 +1,24 @@ + + + + + + + + + + + + +