From 0bfc829604fad12fb346de94b818ef5b378ece27 Mon Sep 17 00:00:00 2001 From: Invvard <7305493+Invvard@users.noreply.github.com> Date: Tue, 7 May 2019 22:14:14 -0400 Subject: [PATCH 01/56] Add the ErgoDox tag model --- .../Model/ErgodoxTag.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/InvvardDev.EZLayoutDisplay.Desktop/Model/ErgodoxTag.cs diff --git a/src/InvvardDev.EZLayoutDisplay.Desktop/Model/ErgodoxTag.cs b/src/InvvardDev.EZLayoutDisplay.Desktop/Model/ErgodoxTag.cs new file mode 100644 index 00000000..50521dcd --- /dev/null +++ b/src/InvvardDev.EZLayoutDisplay.Desktop/Model/ErgodoxTag.cs @@ -0,0 +1,14 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Serialization; + +namespace InvvardDev.EZLayoutDisplay.Desktop.Model +{ + public class ErgodoxTag + { + /// + /// Gets or sets the tag name. + /// + [JsonProperty("name")] + public string Name { get; set; } + } +} \ No newline at end of file From 6a2cd842e1d22d624b3d05ff34bd4008c7b153cb Mon Sep 17 00:00:00 2001 From: Invvard <7305493+Invvard@users.noreply.github.com> Date: Tue, 7 May 2019 22:14:45 -0400 Subject: [PATCH 02/56] Add the geometry and tag list properties --- .../Model/ErgodoxLayout.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/InvvardDev.EZLayoutDisplay.Desktop/Model/ErgodoxLayout.cs b/src/InvvardDev.EZLayoutDisplay.Desktop/Model/ErgodoxLayout.cs index e9c633f5..b565dec3 100644 --- a/src/InvvardDev.EZLayoutDisplay.Desktop/Model/ErgodoxLayout.cs +++ b/src/InvvardDev.EZLayoutDisplay.Desktop/Model/ErgodoxLayout.cs @@ -11,12 +11,24 @@ public class ErgodoxLayout [JsonProperty("hashId")] public string HashId { get; set; } + /// + /// Gets or sets the keyboard geometry. + /// + [JsonProperty("geometry")] + public string Geometry { get; set; } + /// /// Gets or sets the layout title. /// [JsonProperty("title")] public string Title { get; set; } + /// + /// Gets or sets the keyboard tags. + /// + [JsonProperty("tags", NullValueHandling = NullValueHandling.Ignore)] + public List Tags { get; set; } + /// /// Gets or sets the list of . /// From 013dd0cad7209bd1a5bc6021e8aef958ffb418bd Mon Sep 17 00:00:00 2001 From: Invvard <7305493+Invvard@users.noreply.github.com> Date: Tue, 7 May 2019 22:15:15 -0400 Subject: [PATCH 03/56] Add ZIP and HEX file URL properties --- .../Model/Revision.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/InvvardDev.EZLayoutDisplay.Desktop/Model/Revision.cs b/src/InvvardDev.EZLayoutDisplay.Desktop/Model/Revision.cs index 3b72cfb1..22a61d80 100644 --- a/src/InvvardDev.EZLayoutDisplay.Desktop/Model/Revision.cs +++ b/src/InvvardDev.EZLayoutDisplay.Desktop/Model/Revision.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using Newtonsoft.Json; namespace InvvardDev.EZLayoutDisplay.Desktop.Model @@ -11,6 +12,18 @@ public class Revision [JsonProperty("hashId")] public string HashId { get; set; } + /// + /// Gets or sets the keyboard layout HEX file URL. + /// + [JsonProperty("hexUrl")] + public Uri HexUrl { get; set; } + + /// + /// Gets or sets the keyboard layout source zip URL. + /// + [JsonProperty("zipUrl")] + public Uri SourceUrl { get; set; } + /// /// Gets or sets the keyboard model. /// From 115218bf5384b8a0aa61942f2c53bdc91ff3f691 Mon Sep 17 00:00:00 2001 From: Invvard <7305493+Invvard@users.noreply.github.com> Date: Tue, 7 May 2019 22:35:52 -0400 Subject: [PATCH 04/56] Add the GetLayoutInfo method signature --- .../Service/Interface/ILayoutService.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/InvvardDev.EZLayoutDisplay.Desktop/Service/Interface/ILayoutService.cs b/src/InvvardDev.EZLayoutDisplay.Desktop/Service/Interface/ILayoutService.cs index 3e413026..da07a72f 100644 --- a/src/InvvardDev.EZLayoutDisplay.Desktop/Service/Interface/ILayoutService.cs +++ b/src/InvvardDev.EZLayoutDisplay.Desktop/Service/Interface/ILayoutService.cs @@ -6,6 +6,13 @@ namespace InvvardDev.EZLayoutDisplay.Desktop.Service.Interface { public interface ILayoutService { + /// + /// Gets the basic info. + /// + /// The layout hash ID to get. + /// The . + Task GetLayoutInfo(string layoutHashId); + /// /// Gets the . /// From e1b2ce0ee61e73a94f66adc600022c36dee65221 Mon Sep 17 00:00:00 2001 From: Invvard <7305493+Invvard@users.noreply.github.com> Date: Tue, 7 May 2019 22:36:12 -0400 Subject: [PATCH 05/56] Implement GetLayoutInfo method --- .../Service/Design/LayoutService.cs | 7 ++ .../Service/Implementation/LayoutService.cs | 78 ++++++++++++++----- 2 files changed, 66 insertions(+), 19 deletions(-) diff --git a/src/InvvardDev.EZLayoutDisplay.Desktop/Service/Design/LayoutService.cs b/src/InvvardDev.EZLayoutDisplay.Desktop/Service/Design/LayoutService.cs index 0e33a8db..9109a53a 100644 --- a/src/InvvardDev.EZLayoutDisplay.Desktop/Service/Design/LayoutService.cs +++ b/src/InvvardDev.EZLayoutDisplay.Desktop/Service/Design/LayoutService.cs @@ -8,6 +8,13 @@ namespace InvvardDev.EZLayoutDisplay.Desktop.Service.Design { public class LayoutService : ILayoutService { + public async Task GetLayoutInfo(string layoutHashId) + { + Debug.WriteLine("Layout retrieved."); + + return await new Task(() => new ErgodoxLayout()); + } + /// public async Task GetErgodoxLayout(string layoutHashId) { diff --git a/src/InvvardDev.EZLayoutDisplay.Desktop/Service/Implementation/LayoutService.cs b/src/InvvardDev.EZLayoutDisplay.Desktop/Service/Implementation/LayoutService.cs index aac4a309..f3c64df1 100644 --- a/src/InvvardDev.EZLayoutDisplay.Desktop/Service/Implementation/LayoutService.cs +++ b/src/InvvardDev.EZLayoutDisplay.Desktop/Service/Implementation/LayoutService.cs @@ -15,34 +15,69 @@ namespace InvvardDev.EZLayoutDisplay.Desktop.Service.Implementation public class LayoutService : ILayoutService { private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); + private readonly string GetLayoutBody = "{{\"operationName\":\"getLayout\",\"variables\":{{\"hashId\":\"{0}\"}},\"query\":\"query getLayout($hashId: String!) {{\\n Layout(hashId: $hashId) {{\\n ...LayoutData\\n }}\\n}}\\n\\nfragment LayoutData on Layout {{\\n hashId\\n title\\n revisions {{\\n hashId\\n model\\n layers {{\\n hashId\\n keys\\n position\\n title\\n color\\n }}\\n}}\\n}}\\n\"}}"; - private const string GetLayoutRequestUri = "https://oryx.ergodox-ez.com/graphql"; + private readonly string GetLayoutInfoRequestBody = "{0}"; + private const string GetLayoutRequestUri = "https://oryx.ergodox-ez.com/graphql"; + #region ILayoutService implementation + /// + public async Task GetLayoutInfo(string layoutHashId) + { + Logger.TraceMethod(); + Logger.DebugInputParam(nameof(layoutHashId), layoutHashId); + + ValidateLayoutHashId(layoutHashId); + + var requestBody = string.Format(GetLayoutInfoRequestBody, layoutHashId); + + var layout = await HttpClientCall(requestBody); + + if (layout?.LayoutRoot?.Layout == null) + { + Logger.Error("Layout {0} does not exist", layoutHashId); + + throw new ArgumentException(layoutHashId, $"Hash ID \"{layoutHashId}\" does not exist"); + } + + return layout.LayoutRoot.Layout; + } + /// public async Task GetErgodoxLayout(string layoutHashId) { Logger.TraceMethod(); Logger.DebugInputParam(nameof(layoutHashId), layoutHashId); - if (string.IsNullOrWhiteSpace(layoutHashId)) + ValidateLayoutHashId(layoutHashId); + + var requestBody = string.Format(GetLayoutBody, layoutHashId); + + var layout = await HttpClientCall(requestBody); + + if (layout?.LayoutRoot?.Layout == null) { - Logger.Error("Layout {0} was not found", layoutHashId); - // ReSharper disable once LocalizableElement - throw new ArgumentNullException(nameof(layoutHashId), $"Layout hash ID '{layoutHashId}' was not found."); + Logger.Error("Layout {0} does not exist", layoutHashId); + + throw new ArgumentException(layoutHashId, $"Hash ID \"{layoutHashId}\" does not exist"); } + return layout.LayoutRoot.Layout; + } + + private async Task HttpClientCall(string requestBody) + { DataRoot layout; using (HttpClient client = new HttpClient()) { - var body = string.Format(GetLayoutBody, layoutHashId); - Logger.Debug("Request body : {@body}", body); + Logger.Debug("Request body : {@body}", requestBody); - var response = await client.PostAsync(GetLayoutRequestUri, new StringContent(body, Encoding.UTF8, "application/json")); + var response = await client.PostAsync(GetLayoutRequestUri, new StringContent(requestBody, Encoding.UTF8, "application/json")); Logger.Debug("Response : {@response}", response); var result = await response.Content.ReadAsStringAsync(); @@ -50,15 +85,19 @@ public async Task GetErgodoxLayout(string layoutHashId) layout = JsonConvert.DeserializeObject(result); Logger.Debug("Deserialized layout : {@layout}", layout); - - if (layout?.LayoutRoot?.Layout == null) - { - Logger.Error("Layout {0} does not exist", layoutHashId); - throw new ArgumentException(layoutHashId, $"Hash ID \"{layoutHashId}\" does not exist"); - } } - return layout.LayoutRoot.Layout; + return layout; + } + + private static void ValidateLayoutHashId(string layoutHashId) + { + if (!string.IsNullOrWhiteSpace(layoutHashId)) return; + + Logger.Error("Layout {0} was not found", layoutHashId); + + // ReSharper disable once LocalizableElement + throw new ArgumentNullException(nameof(layoutHashId), $"Layout hash ID '{layoutHashId}' was not found."); } /// @@ -93,16 +132,17 @@ private async Task> ReadLayoutDefinition() if (Resources.layoutDefinition.Length <= 0) { Logger.Warn("Layout definition is empty"); + return new List(); } var layoutTemplate = await Task.Run(() => { - var json = Encoding.Default.GetString(Resources.layoutDefinition); + var json = Encoding.Default.GetString(Resources.layoutDefinition); - var layoutDefinition = JsonConvert.DeserializeObject>(json); + var layoutDefinition = JsonConvert.DeserializeObject>(json); - return layoutDefinition; - }); + return layoutDefinition; + }); Logger.DebugOutputParam(nameof(layoutTemplate), layoutTemplate); From 5a9f8158e0f7cfefc71d2637e818058aa73119b5 Mon Sep 17 00:00:00 2001 From: Invvard <7305493+Invvard@users.noreply.github.com> Date: Thu, 9 May 2019 21:03:47 -0400 Subject: [PATCH 06/56] Update the project --- .../InvvardDev.EZLayoutDisplay.Desktop.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/src/InvvardDev.EZLayoutDisplay.Desktop/InvvardDev.EZLayoutDisplay.Desktop.csproj b/src/InvvardDev.EZLayoutDisplay.Desktop/InvvardDev.EZLayoutDisplay.Desktop.csproj index d5f60982..c0e9bb01 100644 --- a/src/InvvardDev.EZLayoutDisplay.Desktop/InvvardDev.EZLayoutDisplay.Desktop.csproj +++ b/src/InvvardDev.EZLayoutDisplay.Desktop/InvvardDev.EZLayoutDisplay.Desktop.csproj @@ -110,6 +110,7 @@ + From 827c9ae95ed50e5980bd1dfae021fc3f8037b832 Mon Sep 17 00:00:00 2001 From: Invvard <7305493+Invvard@users.noreply.github.com> Date: Thu, 9 May 2019 21:04:14 -0400 Subject: [PATCH 07/56] Create the GraphQL for layout info --- .../Service/Implementation/LayoutService.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/InvvardDev.EZLayoutDisplay.Desktop/Service/Implementation/LayoutService.cs b/src/InvvardDev.EZLayoutDisplay.Desktop/Service/Implementation/LayoutService.cs index f3c64df1..4674eafc 100644 --- a/src/InvvardDev.EZLayoutDisplay.Desktop/Service/Implementation/LayoutService.cs +++ b/src/InvvardDev.EZLayoutDisplay.Desktop/Service/Implementation/LayoutService.cs @@ -19,10 +19,11 @@ public class LayoutService : ILayoutService private readonly string GetLayoutBody = "{{\"operationName\":\"getLayout\",\"variables\":{{\"hashId\":\"{0}\"}},\"query\":\"query getLayout($hashId: String!) {{\\n Layout(hashId: $hashId) {{\\n ...LayoutData\\n }}\\n}}\\n\\nfragment LayoutData on Layout {{\\n hashId\\n title\\n revisions {{\\n hashId\\n model\\n layers {{\\n hashId\\n keys\\n position\\n title\\n color\\n }}\\n}}\\n}}\\n\"}}"; - private readonly string GetLayoutInfoRequestBody = "{0}"; + private readonly string GetLayoutInfoRequestBody = + "{{\"operationName\":\"getLayout\",\"variables\":{{\"hashId\":\"{0}\"}},\"query\":\"query getLayout($hashId: String!) {{\\n Layout(hashId: $hashId) {{\\n ...LayoutData\\n __typename\\n }}\\n}}\\n\\nfragment LayoutData on Layout {{\\n geometry\\n hashId\\n title\\n tags {{\\n id\\n hashId\\n name\\n }}\\n revisions {{\\n hexUrl\\n model\\n zipUrl\\n layers {{\\n position\\n title\\n }}\\n }}\\n __typename\\n}}\\n\"}}"; + + private const string GetLayoutRequestUri = "https://oryx.ergodox-ez.com/graphql"; - private const string GetLayoutRequestUri = "https://oryx.ergodox-ez.com/graphql"; - #region ILayoutService implementation /// From e8b7095d7bd064c116891b4852e1eb85f9438f29 Mon Sep 17 00:00:00 2001 From: Invvard <7305493+Invvard@users.noreply.github.com> Date: Thu, 9 May 2019 21:11:01 -0400 Subject: [PATCH 08/56] Move duplicated code to private method --- .../Service/Implementation/LayoutService.cs | 90 +++++++++---------- 1 file changed, 43 insertions(+), 47 deletions(-) diff --git a/src/InvvardDev.EZLayoutDisplay.Desktop/Service/Implementation/LayoutService.cs b/src/InvvardDev.EZLayoutDisplay.Desktop/Service/Implementation/LayoutService.cs index 4674eafc..4fff868e 100644 --- a/src/InvvardDev.EZLayoutDisplay.Desktop/Service/Implementation/LayoutService.cs +++ b/src/InvvardDev.EZLayoutDisplay.Desktop/Service/Implementation/LayoutService.cs @@ -32,31 +32,52 @@ public async Task GetLayoutInfo(string layoutHashId) Logger.TraceMethod(); Logger.DebugInputParam(nameof(layoutHashId), layoutHashId); - ValidateLayoutHashId(layoutHashId); + var info = await QueryData(layoutHashId, GetLayoutInfoRequestBody); + + return info; + } - var requestBody = string.Format(GetLayoutInfoRequestBody, layoutHashId); + /// + public async Task GetErgodoxLayout(string layoutHashId) + { + Logger.TraceMethod(); + Logger.DebugInputParam(nameof(layoutHashId), layoutHashId); - var layout = await HttpClientCall(requestBody); + var layout = await QueryData(layoutHashId, GetLayoutBody); - if (layout?.LayoutRoot?.Layout == null) - { - Logger.Error("Layout {0} does not exist", layoutHashId); + return layout; + } - throw new ArgumentException(layoutHashId, $"Hash ID \"{layoutHashId}\" does not exist"); - } + /// + public EZLayout PrepareEZLayout(ErgodoxLayout ergodoxLayout) + { + Logger.TraceMethod(); - return layout.LayoutRoot.Layout; + var ezLayoutMaker = new EZLayoutMaker(); + EZLayout ezLayout = ezLayoutMaker.PrepareEZLayout(ergodoxLayout); + + return ezLayout; } /// - public async Task GetErgodoxLayout(string layoutHashId) + public async Task> GetLayoutTemplate() { Logger.TraceMethod(); - Logger.DebugInputParam(nameof(layoutHashId), layoutHashId); + IEnumerable layoutTemplate = await ReadLayoutDefinition(); + + return layoutTemplate; + } + + #endregion + + #region Private methods + + private async Task QueryData(string layoutHashId, string graphQlQuery) + { ValidateLayoutHashId(layoutHashId); - var requestBody = string.Format(GetLayoutBody, layoutHashId); + var requestBody = string.Format(graphQlQuery, layoutHashId); var layout = await HttpClientCall(requestBody); @@ -70,6 +91,16 @@ public async Task GetErgodoxLayout(string layoutHashId) return layout.LayoutRoot.Layout; } + private static void ValidateLayoutHashId(string layoutHashId) + { + if (!string.IsNullOrWhiteSpace(layoutHashId)) return; + + Logger.Error("Layout {0} was not found", layoutHashId); + + // ReSharper disable once LocalizableElement + throw new ArgumentNullException(nameof(layoutHashId), $"Layout hash ID '{layoutHashId}' was not found."); + } + private async Task HttpClientCall(string requestBody) { DataRoot layout; @@ -91,41 +122,6 @@ private async Task HttpClientCall(string requestBody) return layout; } - private static void ValidateLayoutHashId(string layoutHashId) - { - if (!string.IsNullOrWhiteSpace(layoutHashId)) return; - - Logger.Error("Layout {0} was not found", layoutHashId); - - // ReSharper disable once LocalizableElement - throw new ArgumentNullException(nameof(layoutHashId), $"Layout hash ID '{layoutHashId}' was not found."); - } - - /// - public EZLayout PrepareEZLayout(ErgodoxLayout ergodoxLayout) - { - Logger.TraceMethod(); - - var ezLayoutMaker = new EZLayoutMaker(); - EZLayout ezLayout = ezLayoutMaker.PrepareEZLayout(ergodoxLayout); - - return ezLayout; - } - - /// - public async Task> GetLayoutTemplate() - { - Logger.TraceMethod(); - - IEnumerable layoutTemplate = await ReadLayoutDefinition(); - - return layoutTemplate; - } - - #endregion - - #region Private methods - private async Task> ReadLayoutDefinition() { Logger.TraceMethod(); From 7196e6c080e8529637edb1ebc59ad377a0d51bf0 Mon Sep 17 00:00:00 2001 From: Invvard <7305493+Invvard@users.noreply.github.com> Date: Thu, 9 May 2019 21:31:02 -0400 Subject: [PATCH 09/56] Update the default Layout URL --- src/InvvardDev.EZLayoutDisplay.Desktop/App.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/InvvardDev.EZLayoutDisplay.Desktop/App.config b/src/InvvardDev.EZLayoutDisplay.Desktop/App.config index 91b7abd6..9b76f990 100644 --- a/src/InvvardDev.EZLayoutDisplay.Desktop/App.config +++ b/src/InvvardDev.EZLayoutDisplay.Desktop/App.config @@ -21,7 +21,7 @@ - https://configure.ergodox-ez.com/layouts/default/latest/0 + https://configure.ergodox-ez.com/ergodox-ez/layouts/default/latest/0 {"modifiers":[0,1,2,4],"keycode":32} From d8d47e0e4e0c37c9352625b92cffcf5dc3af7264 Mon Sep 17 00:00:00 2001 From: Invvard <7305493+Invvard@users.noreply.github.com> Date: Thu, 9 May 2019 21:31:29 -0400 Subject: [PATCH 10/56] Update the default Layout URL --- .../Properties/Settings.Designer.cs | 4 ++-- .../Properties/Settings.settings | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/InvvardDev.EZLayoutDisplay.Desktop/Properties/Settings.Designer.cs b/src/InvvardDev.EZLayoutDisplay.Desktop/Properties/Settings.Designer.cs index 20fee19f..d0cabd01 100644 --- a/src/InvvardDev.EZLayoutDisplay.Desktop/Properties/Settings.Designer.cs +++ b/src/InvvardDev.EZLayoutDisplay.Desktop/Properties/Settings.Designer.cs @@ -12,7 +12,7 @@ namespace InvvardDev.EZLayoutDisplay.Desktop.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.0.0.0")] public sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); @@ -25,7 +25,7 @@ public static Settings Default { [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("https://configure.ergodox-ez.com/layouts/default/latest/0")] + [global::System.Configuration.DefaultSettingValueAttribute("https://configure.ergodox-ez.com/ergodox-ez/layouts/default/latest/0")] public string ErgodoxLayoutUrl { get { return ((string)(this["ErgodoxLayoutUrl"])); diff --git a/src/InvvardDev.EZLayoutDisplay.Desktop/Properties/Settings.settings b/src/InvvardDev.EZLayoutDisplay.Desktop/Properties/Settings.settings index cea1e0ac..d45dd66c 100644 --- a/src/InvvardDev.EZLayoutDisplay.Desktop/Properties/Settings.settings +++ b/src/InvvardDev.EZLayoutDisplay.Desktop/Properties/Settings.settings @@ -3,7 +3,7 @@ - https://configure.ergodox-ez.com/layouts/default/latest/0 + https://configure.ergodox-ez.com/ergodox-ez/layouts/default/latest/0 {"modifiers":[0,1,2,4],"keycode":32} From ddaf1b98158ff567d3bab0e9ba377f99d88ed364 Mon Sep 17 00:00:00 2001 From: Invvard <7305493+Invvard@users.noreply.github.com> Date: Thu, 9 May 2019 21:48:23 -0400 Subject: [PATCH 11/56] Remove unused using --- src/InvvardDev.EZLayoutDisplay.Desktop/Model/ErgodoxTag.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/InvvardDev.EZLayoutDisplay.Desktop/Model/ErgodoxTag.cs b/src/InvvardDev.EZLayoutDisplay.Desktop/Model/ErgodoxTag.cs index 50521dcd..bda5b2b7 100644 --- a/src/InvvardDev.EZLayoutDisplay.Desktop/Model/ErgodoxTag.cs +++ b/src/InvvardDev.EZLayoutDisplay.Desktop/Model/ErgodoxTag.cs @@ -1,5 +1,4 @@ using Newtonsoft.Json; -using Newtonsoft.Json.Serialization; namespace InvvardDev.EZLayoutDisplay.Desktop.Model { From 02c8862d0c0b17819e3aac17b5cbb48335127b4b Mon Sep 17 00:00:00 2001 From: Invvard <7305493+Invvard@users.noreply.github.com> Date: Sat, 11 May 2019 14:49:52 -0400 Subject: [PATCH 12/56] Update dictionary --- src/InvvardDev.EZLayoutDisplay.sln.DotSettings | 1 + 1 file changed, 1 insertion(+) diff --git a/src/InvvardDev.EZLayoutDisplay.sln.DotSettings b/src/InvvardDev.EZLayoutDisplay.sln.DotSettings index 8d835aae..5d6ad40f 100644 --- a/src/InvvardDev.EZLayoutDisplay.sln.DotSettings +++ b/src/InvvardDev.EZLayoutDisplay.sln.DotSettings @@ -1,4 +1,5 @@  <data /> <data><IncludeFilters /><ExcludeFilters><Filter ModuleMask="InvvardDev.EZLayoutDisplay.Desktop" ModuleVersionMask="*" ClassMask="InvvardDev.EZLayoutDisplay.Desktop.ViewModel.ViewModelLocator" FunctionMask="*" IsEnabled="True" /><Filter ModuleMask="InvvardDev.EZLayoutDisplay.Desktop" ModuleVersionMask="*" ClassMask="InvvardDev.EZLayoutDisplay.Desktop.View.*" FunctionMask="*" IsEnabled="True" /><Filter ModuleMask="InvvardDev.EZLayoutDisplay.Desktop" ModuleVersionMask="*" ClassMask="InvvardDev.EZLayoutDisplay.Desktop.Model.Enum.*" FunctionMask="*" IsEnabled="True" /><Filter ModuleMask="InvvardDev.EZLayoutDisplay.Desktop" ModuleVersionMask="*" ClassMask="InvvardDev.EZLayoutDisplay.Desktop.Design.*" FunctionMask="*" IsEnabled="True" /><Filter ModuleMask="InvvardDev.EZLayoutDisplay.Desktop" ModuleVersionMask="*" ClassMask="XamlGeneratedNamespace.*" FunctionMask="*" IsEnabled="True" /><Filter ModuleMask="InvvardDev.EZLayoutDisplay.Desktop" ModuleVersionMask="*" ClassMask="InvvardDev.EZLayoutDisplay.Desktop.Properties.*" FunctionMask="*" IsEnabled="True" /><Filter ModuleMask="InvvardDev.EZLayoutDisplay.Desktop" ModuleVersionMask="*" ClassMask="InvvardDev.EZLayoutDisplay.Desktop.Model.Service.Implementation.ApplicationService" FunctionMask="*" IsEnabled="True" /><Filter ModuleMask="InvvardDev.EZLayoutDisplay.Desktop" ModuleVersionMask="*" ClassMask="InvvardDev.EZLayoutDisplay.Desktop.Model.Service.Implementation.SettingsService" FunctionMask="*" IsEnabled="True" /><Filter ModuleMask="InvvardDev.EZLayoutDisplay.Desktop" ModuleVersionMask="*" ClassMask="InvvardDev.EZLayoutDisplay.Desktop.Model.Service.Implementation.WindowService" FunctionMask="*" IsEnabled="True" /><Filter ModuleMask="InvvardDev.EZLayoutDisplay.Desktop" ModuleVersionMask="*" ClassMask="InvvardDev.EZLayoutDisplay.Desktop.Model.Dictionary.*" FunctionMask="*" IsEnabled="True" /><Filter ModuleMask="InvvardDev.EZLayoutDisplay.Desktop" ModuleVersionMask="*" ClassMask="InvvardDev.EZLayoutDisplay.Desktop.Model.Service.Implementation.KeyboardHookService" FunctionMask="*" IsEnabled="True" /><Filter ModuleMask="InvvardDev.EZLayoutDisplay.Tests" ModuleVersionMask="*" ClassMask="*" FunctionMask="*" IsEnabled="True" /><Filter ModuleMask="InvvardDev.EZLayoutDisplay.Desktop" ModuleVersionMask="*" ClassMask="InvvardDev.EZLayoutDisplay.Desktop.Service.Implementation.ApplicationService" FunctionMask="*" IsEnabled="True" /><Filter ModuleMask="InvvardDev.EZLayoutDisplay.Desktop" ModuleVersionMask="*" ClassMask="InvvardDev.EZLayoutDisplay.Desktop.Service.Implementation.SettingsService" FunctionMask="*" IsEnabled="True" /><Filter ModuleMask="InvvardDev.EZLayoutDisplay.Desktop" ModuleVersionMask="*" ClassMask="InvvardDev.EZLayoutDisplay.Desktop.Service.Implementation.WindowService" FunctionMask="*" IsEnabled="True" /><Filter ModuleMask="InvvardDev.EZLayoutDisplay.Desktop" ModuleVersionMask="*" ClassMask="InvvardDev.EZLayoutDisplay.Desktop.Service.Implementation.KeyboardHookService" FunctionMask="*" IsEnabled="True" /><Filter ModuleMask="InvvardDev.EZLayoutDisplay.Desktop" ModuleVersionMask="*" ClassMask="InvvardDev.EZLayoutDisplay.Desktop.Service.Design.*" FunctionMask="*" IsEnabled="True" /><Filter ModuleMask="InvvardDev.EZLayoutDisplay.Desktop" ModuleVersionMask="*" ClassMask="InvvardDev.EZLayoutDisplay.Desktop.App" FunctionMask="*" IsEnabled="True" /><Filter ModuleMask="InvvardDev.EZLayoutDisplay.Desktop" ModuleVersionMask="*" ClassMask="InvvardDev.EZLayoutDisplay.Desktop.ViewModel.DisplayLayoutViewModel" FunctionMask="LoadDesignTimeModel" IsEnabled="True" /><Filter ModuleMask="InvvardDev.EZLayoutDisplay.Desktop" ModuleVersionMask="*" ClassMask="InvvardDev.EZLayoutDisplay.Desktop.Model.KeyCategoryDetail" FunctionMask="*" IsEnabled="True" /><Filter ModuleMask="*" ModuleVersionMask="*" ClassMask="*" FunctionMask="*" IsEnabled="False" /><Filter ModuleMask="InvvardDev.EZLayoutDisplay.Console" ModuleVersionMask="*" ClassMask="*" FunctionMask="*" IsEnabled="True" /><Filter ModuleMask="InvvardDev.EZLayoutDisplay.Desktop" ModuleVersionMask="*" ClassMask="InvvardDev.EZLayoutDisplay.Desktop.Service.Implementation.LayoutService" FunctionMask="GetLayoutTemplate" IsEnabled="True" /><Filter ModuleMask="InvvardDev.EZLayoutDisplay.Desktop" ModuleVersionMask="*" ClassMask="InvvardDev.EZLayoutDisplay.Desktop.Service.Implementation.LayoutService" FunctionMask="ReadLayoutDefinition" IsEnabled="True" /><Filter ModuleMask="InvvardDev.EZLayoutDisplay.Desktop" ModuleVersionMask="*" ClassMask="InvvardDev.EZLayoutDisplay.Desktop.Model.Hotkey" FunctionMask="*" IsEnabled="True" /><Filter ModuleMask="InvvardDev.EZLayoutDisplay.Desktop" ModuleVersionMask="*" ClassMask="InvvardDev.EZLayoutDisplay.Desktop.Helper.KeyContentTemplateSelector" FunctionMask="*" IsEnabled="True" /><Filter ModuleMask="InvvardDev.EZLayoutDisplay.Desktop" ModuleVersionMask="*" ClassMask="InvvardDev.EZLayoutDisplay.Desktop.ViewModel.DisplayLayoutViewModel" FunctionMask="LoadCompleteLayout" IsEnabled="True" /><Filter ModuleMask="InvvardDev.EZLayoutDisplay.Desktop" ModuleVersionMask="*" ClassMask="InvvardDev.EZLayoutDisplay.Desktop.Service.Implementation.ProcessService" FunctionMask="*" IsEnabled="True" /></ExcludeFilters></data> + True True \ No newline at end of file From 22566f7482aecec112311a39f0be0263f4dff5ef Mon Sep 17 00:00:00 2001 From: Invvard <7305493+Invvard@users.noreply.github.com> Date: Sat, 11 May 2019 16:02:52 -0400 Subject: [PATCH 13/56] Get layout info on URL change --- .../ViewModel/SettingsViewModel.cs | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/InvvardDev.EZLayoutDisplay.Desktop/ViewModel/SettingsViewModel.cs b/src/InvvardDev.EZLayoutDisplay.Desktop/ViewModel/SettingsViewModel.cs index dcb1a43d..b1bc185a 100644 --- a/src/InvvardDev.EZLayoutDisplay.Desktop/ViewModel/SettingsViewModel.cs +++ b/src/InvvardDev.EZLayoutDisplay.Desktop/ViewModel/SettingsViewModel.cs @@ -1,6 +1,7 @@ using System; using System.Text.RegularExpressions; using System.Threading.Tasks; +using System.Timers; using System.Windows.Input; using GalaSoft.MvvmLight; using GalaSoft.MvvmLight.CommandWpf; @@ -19,6 +20,7 @@ public class SettingsViewModel : ViewModelBase #region Fields private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); + private Timer _updateLayoutInfoTimer; private readonly ISettingsService _settingsService; private readonly IWindowService _windowService; @@ -129,11 +131,28 @@ public string LayoutUrlContent { if (Set(ref _layoutUrlContent, value)) { - UpdateButtonCanExecute(); + UrlContentUpdated(); } } } + private void UrlContentUpdated() + { + UpdateButtonCanExecute(); + UpdateErgoDoxInfo(); + } + + private void UpdateErgoDoxInfo() + { + Logger.TraceMethod(); + + var layoutHashId = ExtractLayoutHashId(LayoutUrlContent); + + Logger.Debug("Layout Hash ID = {0}", layoutHashId); + + var layoutInfo = _layoutService.GetLayoutInfo(layoutHashId); + } + public string AltModifierLabel { get => _altModifierLabel; @@ -176,6 +195,8 @@ public SettingsViewModel(ISettingsService settingsService, IWindowService window _windowService = windowService; _layoutService = layoutService; + _updateLayoutInfoTimer = new Timer(750); + SetLabelUi(); SetSettingControls(); @@ -304,7 +325,7 @@ private string ExtractLayoutHashId(string layoutUrl) { layoutHashId = match.Groups[layoutHashIdGroupName].Value; } - + Logger.Debug("Layout URL = {0}", layoutUrl); Logger.Debug("Layout Hash ID = {0}", layoutHashId); From 763a1c1058be1b09e8728a1ba95d2605356f65b6 Mon Sep 17 00:00:00 2001 From: Invvard <7305493+Invvard@users.noreply.github.com> Date: Mon, 13 May 2019 19:31:40 -0400 Subject: [PATCH 14/56] Simplify after change layout URL --- .../ViewModel/SettingsViewModel.cs | 22 ++++--------------- 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/src/InvvardDev.EZLayoutDisplay.Desktop/ViewModel/SettingsViewModel.cs b/src/InvvardDev.EZLayoutDisplay.Desktop/ViewModel/SettingsViewModel.cs index b1bc185a..1e433e78 100644 --- a/src/InvvardDev.EZLayoutDisplay.Desktop/ViewModel/SettingsViewModel.cs +++ b/src/InvvardDev.EZLayoutDisplay.Desktop/ViewModel/SettingsViewModel.cs @@ -1,7 +1,6 @@ using System; using System.Text.RegularExpressions; using System.Threading.Tasks; -using System.Timers; using System.Windows.Input; using GalaSoft.MvvmLight; using GalaSoft.MvvmLight.CommandWpf; @@ -20,7 +19,6 @@ public class SettingsViewModel : ViewModelBase #region Fields private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - private Timer _updateLayoutInfoTimer; private readonly ISettingsService _settingsService; private readonly IWindowService _windowService; @@ -129,17 +127,11 @@ public string LayoutUrlContent get => _layoutUrlContent; set { - if (Set(ref _layoutUrlContent, value)) - { - UrlContentUpdated(); - } - } - } + if (!Set(ref _layoutUrlContent, value)) return; - private void UrlContentUpdated() - { - UpdateButtonCanExecute(); - UpdateErgoDoxInfo(); + UpdateButtonCanExecute(); + UpdateErgoDoxInfo(); + } } private void UpdateErgoDoxInfo() @@ -148,8 +140,6 @@ private void UpdateErgoDoxInfo() var layoutHashId = ExtractLayoutHashId(LayoutUrlContent); - Logger.Debug("Layout Hash ID = {0}", layoutHashId); - var layoutInfo = _layoutService.GetLayoutInfo(layoutHashId); } @@ -195,8 +185,6 @@ public SettingsViewModel(ISettingsService settingsService, IWindowService window _windowService = windowService; _layoutService = layoutService; - _updateLayoutInfoTimer = new Timer(750); - SetLabelUi(); SetSettingControls(); @@ -286,8 +274,6 @@ private async Task UpdateLayout() var layoutHashId = ExtractLayoutHashId(LayoutUrlContent); - Logger.Debug("Layout Hash ID = {0}", layoutHashId); - try { var ergodoxLayout = await _layoutService.GetErgodoxLayout(layoutHashId); From 45fb5fb22d66acfba980793b9ccbbf5e3b156a01 Mon Sep 17 00:00:00 2001 From: Invvard <7305493+Invvard@users.noreply.github.com> Date: Mon, 13 May 2019 19:32:26 -0400 Subject: [PATCH 15/56] Modify window to add space for Layout info --- .../View/SettingsWindow.xaml | 21 +++++++++++-------- .../View/SettingsWindow.xaml.cs | 4 ++-- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/InvvardDev.EZLayoutDisplay.Desktop/View/SettingsWindow.xaml b/src/InvvardDev.EZLayoutDisplay.Desktop/View/SettingsWindow.xaml index 4fd469f1..04eb9b3f 100644 --- a/src/InvvardDev.EZLayoutDisplay.Desktop/View/SettingsWindow.xaml +++ b/src/InvvardDev.EZLayoutDisplay.Desktop/View/SettingsWindow.xaml @@ -5,7 +5,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" Background="{StaticResource WindowBackgroundBrush}" Title="{Binding WindowTitle}" Icon="{StaticResource WindowIcon}" - Width="600" Height="100" MinWidth="500" MinHeight="100" + Width="630" Height="400" MinWidth="500" MinHeight="100" WindowStartupLocation="CenterScreen" ResizeMode="NoResize" DataContext="{Binding Settings, Source={StaticResource Locator}}"> @@ -15,25 +15,28 @@ - + +