diff --git a/src/InvvardDev.EZLayoutDisplay.Console/App.config b/src/InvvardDev.EZLayoutDisplay.Console/App.config
deleted file mode 100644
index 4bfa0056..00000000
--- a/src/InvvardDev.EZLayoutDisplay.Console/App.config
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
diff --git a/src/InvvardDev.EZLayoutDisplay.Console/ConfiguratorKeyDefinition.cs b/src/InvvardDev.EZLayoutDisplay.Console/ConfiguratorKeyDefinition.cs
deleted file mode 100644
index 7315f8ea..00000000
--- a/src/InvvardDev.EZLayoutDisplay.Console/ConfiguratorKeyDefinition.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-namespace InvvardDev.EZLayoutDisplay.Console
-{
- public class ConfiguratorKeyDefinition
- {
- public string KeyCode { get; set; }
- public string Label { get; set; }
- public string MenuLabel { get; set; }
- public string Glyph { get; set; }
- public string Category { get; set; }
- public string Description { get; set; }
- public string Command { get; set; }
- public bool? PrecedingKey { get; set; }
- }
-}
\ No newline at end of file
diff --git a/src/InvvardDev.EZLayoutDisplay.Console/InvvardDev.EZLayoutDisplay.Console.csproj b/src/InvvardDev.EZLayoutDisplay.Console/InvvardDev.EZLayoutDisplay.Console.csproj
deleted file mode 100644
index 6e038db8..00000000
--- a/src/InvvardDev.EZLayoutDisplay.Console/InvvardDev.EZLayoutDisplay.Console.csproj
+++ /dev/null
@@ -1,63 +0,0 @@
-
-
-
-
- Debug
- AnyCPU
- {CC579192-C568-42B4-969C-445D5F0D79E1}
- Exe
- InvvardDev.EZLayoutDisplay.Console
- InvvardDev.EZLayoutDisplay.Console
- v4.8
- 512
- true
- true
-
-
-
- AnyCPU
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- AnyCPU
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
-
-
- ..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {F12B94C1-40E4-429C-8EDE-5C410BE81FAF}
- InvvardDev.EZLayoutDisplay.Desktop
-
-
-
-
\ No newline at end of file
diff --git a/src/InvvardDev.EZLayoutDisplay.Console/KeyDefinitionProcessor.cs b/src/InvvardDev.EZLayoutDisplay.Console/KeyDefinitionProcessor.cs
deleted file mode 100644
index 1d99e5c0..00000000
--- a/src/InvvardDev.EZLayoutDisplay.Console/KeyDefinitionProcessor.cs
+++ /dev/null
@@ -1,539 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using InvvardDev.EZLayoutDisplay.Desktop.Model;
-using InvvardDev.EZLayoutDisplay.Desktop.Model.Enum;
-using Newtonsoft.Json;
-
-namespace InvvardDev.EZLayoutDisplay.Console
-{
- public class KeyDefinitionProcessor
- {
- private const string KeyDefinitionInputFilename = "keyDefinitions.json";
- private const string KeyDefinitionOutputFilename = "keyDefinitions.output.json";
-
- public void RunProcess()
- {
- if (!CheckKeyDefinitionJsExists())
- {
- return;
- }
-
- var keyCodesOrigin = ReadJsonFile();
-
- if (!keyCodesOrigin.Any())
- {
- return;
- }
-
- List keyDefinitions = ToEZKeyDefinitions(keyCodesOrigin);
-
- WriteJsonFile(keyDefinitions);
- }
-
- private bool CheckKeyDefinitionJsExists()
- {
- var fileExist = File.Exists(KeyDefinitionInputFilename);
-
- return fileExist;
- }
-
- private List ReadJsonFile()
- {
- List keyCodes;
-
- using (StreamReader sr = new StreamReader(KeyDefinitionInputFilename))
- {
- var json = sr.ReadToEnd();
- keyCodes = JsonConvert.DeserializeObject>(json);
- }
-
- return keyCodes;
- }
-
- private List ToEZKeyDefinitions(List keyCodesOrigin)
- {
- List keyDefinitions = new List();
-
- foreach (var configKeyDef in keyCodesOrigin)
- {
- var (label, isGlyph) = ChooseLabel(configKeyDef);
- var keyDefinition = new KeyDefinition {
- Label = label,
- Description = configKeyDef.Description,
- IsGlyph = isGlyph,
- KeyCode = configKeyDef.KeyCode,
- KeyCategory = (KeyCategory) Enum.Parse(typeof(KeyCategory), configKeyDef.Category, true),
- SecondaryCommand = configKeyDef.Command
- };
-
- if (configKeyDef.PrecedingKey.HasValue)
- {
- keyDefinition.PrecedingKey = configKeyDef.PrecedingKey.Value;
- }
-
- keyDefinitions.Add(keyDefinition);
- }
-
- return keyDefinitions;
- }
-
- private void WriteJsonFile(List keyDefinitions)
- {
- var json = JsonConvert.SerializeObject(keyDefinitions);
- json = json.Replace(@"\\u", @"\u");
-
- File.WriteAllText(KeyDefinitionOutputFilename, json);
- }
-
- private (string, bool) ChooseLabel(ConfiguratorKeyDefinition configKeyDef)
- {
- var label = string.IsNullOrWhiteSpace(configKeyDef.Label)
- ? configKeyDef.MenuLabel
- : configKeyDef.Label;
-
- bool isGlyph;
- (label, isGlyph) = ApplySpecialLabel(configKeyDef.KeyCode, label);
-
- return (label, isGlyph);
- }
-
- private (string, bool) ApplySpecialLabel(string keyCode, string label)
- {
- var isGlyph = false;
-
- switch (keyCode)
- {
- case "KC_TRANSPARENT":
- label = "";
-
- break;
- case "TG":
- label = "\\u2750 {0}";
-
- break;
- case "MO":
- label = "\\u27F2 {0}";
-
- break;
- case "OSL":
- label = "OSL {0}";
-
- break;
- case "TO":
- label = "TO {0}";
-
- break;
- case "TT":
- label = "TT {0}";
-
- break;
- case "LT":
- label = "LT \\u2192 {0}";
-
- break;
- case "KC_AUDIO_MUTE":
- label = "\\ue913";
- isGlyph = true;
-
- break;
- case "KC_AUDIO_VOL_UP":
- label = "\\ue914";
- isGlyph = true;
-
- break;
- case "KC_AUDIO_VOL_DOWN":
- label = "\\ue912";
- isGlyph = true;
-
- break;
- case "KC_MEDIA_NEXT_TRACK":
- label = "\\ue908";
- isGlyph = true;
-
- break;
- case "KC_MEDIA_PREV_TRACK":
- label = "\\ue90a";
- isGlyph = true;
-
- break;
- case "KC_MEDIA_STOP":
- label = "\\ue919";
- isGlyph = true;
-
- break;
- case "KC_MEDIA_PLAY_PAUSE":
- label = "\\ue91a";
- isGlyph = true;
-
- break;
- case "KC_MEDIA_EJECT":
- label = "\\ue90c";
- isGlyph = true;
-
- break;
- case "KC_MEDIA_FAST_FORWARD":
- label = "\\ue906";
- isGlyph = true;
-
- break;
- case "KC_MEDIA_REWIND":
- label = "\\ue909";
- isGlyph = true;
-
- break;
- case "LSFT_T":
- case "RSFT_T":
- case "KC_LSHIFT":
- case "KC_RSHIFT":
- case "MOD_LSFT":
- case "MOD_RSFT":
- label = "\\u21e7";
-
- break;
- case "KC_LGUI":
- case "KC_RGUI":
- case "MOD_LGUI":
- case "MOD_RGUI":
- label = "\\ue904";
- isGlyph = true;
-
- break;
- case "KC_MS_UP":
- label = "\\ue91c";
- isGlyph = true;
-
- break;
- case "KC_MS_DOWN":
- label = "\\ue91d";
- isGlyph = true;
-
- break;
- case "KC_MS_LEFT":
- label = "\\ue91e";
- isGlyph = true;
-
- break;
- case "KC_MS_RIGHT":
- label = "\\ue91f";
- isGlyph = true;
-
- break;
- case "KC_MS_BTN1":
- label = "\\ue920";
- isGlyph = true;
-
- break;
- case "KC_MS_BTN2":
- label = "\\ue922";
- isGlyph = true;
-
- break;
- case "KC_MS_BTN3":
- label = "\\ue921";
- isGlyph = true;
-
- break;
- case "KC_BSPACE":
- label = "\\ue918";
- isGlyph = true;
-
- break;
- case "KC_ENTER":
- label = "\\u23ce";
-
- break;
- case "KC_SPACE":
- label = "\\u23b5";
-
- break;
- case "KC_APPLICATION":
- label = "\\ue90f";
- isGlyph = true;
-
- break;
- case "KC_LEFT":
- label = "\\u25c0";
-
- break;
- case "KC_UP":
- label = "\\u25b2";
-
- break;
- case "KC_RIGHT":
- label = "\\u25b6";
-
- break;
- case "KC_DOWN":
- label = "\\u25bc";
-
- break;
- case "RGB_MOD":
- label = "\\ue916";
- isGlyph = true;
-
- break;
- case "RGB_SLD":
- label = "\\ue90e";
- isGlyph = true;
-
- break;
- case "RGB_VAI":
- label = "\\ue911";
- isGlyph = true;
-
- break;
- case "RGB_VAD":
- label = "\\ue910";
- isGlyph = true;
-
- break;
- case "RGB_HUI":
- label = "\\ue923";
- isGlyph = true;
-
- break;
- case "RGB_HUD":
- label = "\\ue924";
- isGlyph = true;
-
- break;
- case "RGB_TOG":
- label = "\\ue90d";
- isGlyph = true;
-
- break;
- case "RGB":
- label = "\\ue915";
- isGlyph = true;
-
- break;
- case "FR_SUP2":
- label = "\\u00B2";
-
- break;
- case "DE_SQ2":
- label = "\\u00B2";
-
- break;
- case "FR_EACU":
- label = "\\u00E9";
-
- break;
- case "FR_EGRV":
- label = "\\u00E8";
-
- break;
- case "FR_CCED":
- label = "\\u00E7";
-
- break;
- case "FR_AGRV":
- label = "\\u00E0";
-
- break;
- case "FR_UGRV":
- label = "\\u00F9";
-
- break;
- case "DE_SS":
- label = "\\u00DF";
-
- break;
- case "DE_AE":
- label = "\\u00C4";
-
- break;
- case "DE_UE":
- label = "\\u00DC";
-
- break;
- case "DE_OE":
- label = "\\u00D6";
-
- break;
- case "DE_CIRC":
- label = "\\u005E\\u00B0";
-
- break;
- case "NO_HALF":
- case "ES_EURO":
- label = "\\u00BD";
-
- break;
- case "NO_AM":
- label = "\\u00E5";
-
- break;
- case "NO_AE":
- label = "\\u00F8";
-
- break;
- case "NO_OSLH":
- label = "\\u00E6";
-
- break;
- case "ES_OVRR":
- label = "\\u00BA";
-
- break;
- case "ES_IEXL":
- label = "\\u00A1";
-
- break;
- case "ES_NTIL":
- label = "\\u00F1";
-
- break;
- case "ES_ASML":
- label = "\\u00AA";
-
- break;
- case "FR_OVRR":
- label = "\\u00B0";
-
- break;
- case "DE_RING":
- label = "\\u00B0";
-
- break;
- case "FR_UMLT":
- label = "\\u00A8";
-
- break;
- case "FR_PND":
- label = "\\u00A3";
-
- break;
- case "FR_MU":
- label = "\\u03BC";
-
- break;
- case "FR_SECT":
- label = "\\u00A7";
-
- break;
- case "DE_PARA":
- label = "\\u00A7";
-
- break;
- case "DE_EURO":
- label = "\\u20AC";
-
- break;
- case "FR_EURO":
- case "NO_EURO":
- label = "\\u20AC";
-
- break;
- case "FR_BULT":
- label = "\\u00A4";
-
- break;
- case "DE_ACUT":
- label = "\\u00B4\\u0060";
-
- break;
- case "ES_ACUT":
- label = "\\u00B4";
-
- break;
- case "DE_SQ3":
- label = "\\u00B3";
-
- break;
- case "NO_LCBR":
- label = "\\u00B6";
-
- break;
- case "NO_RCBR":
- label = "\\u2260";
-
- break;
- case "ES_OVDT":
- label = "\\u00B7";
-
- break;
- case "ES_IQUE":
- label = "\\u00BF";
-
- break;
- case "ES_NOT":
- label = "\\u00AC";
-
- break;
- case "HU_UE":
- label = "\\u00FC";
-
- break;
- case "HU_OO":
- label = "\\u00F3";
-
- break;
- case "HU_OE":
- label = "\\u00F6";
-
- break;
- case "HU_OEE":
- label = "\\u0151";
-
- break;
- case "HU_UU":
- label = "\\u00FA";
-
- break;
- case "HU_EE":
- label = "\\u00E9";
-
- break;
- case "HU_BRV":
- label = "\\u02D8";
-
- break;
- case "HU_RING":
- label = "\\u00B0";
-
- break;
- case "HU_EURO":
- label = "\\u20AC";
-
- break;
- case "HU_SS":
- label = "\\u00DF";
-
- break;
- case "HU_AA":
- label = "\\u00E1";
-
- break;
- case "HU_UEE":
- label = "\\u0171";
-
- break;
- case "HU_PARA":
- label = "\\u00A7";
-
- break;
- case "HU_II":
- label = "\\u00ED";
-
- break;
- case "HU_ACUT":
- label = "\\u00B4";
-
- break;
- case "HU_DIV":
- label = "\\u00F7";
-
- break;
- case "HU_CRSS":
- label = "\\u00D7";
-
- break;
- }
-
- return (label, isGlyph);
- }
- }
-}
\ No newline at end of file
diff --git a/src/InvvardDev.EZLayoutDisplay.Console/Program.cs b/src/InvvardDev.EZLayoutDisplay.Console/Program.cs
deleted file mode 100644
index 8a0218b6..00000000
--- a/src/InvvardDev.EZLayoutDisplay.Console/Program.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-namespace InvvardDev.EZLayoutDisplay.Console
-{
- class Program
- {
- // ReSharper disable once UnusedParameter.Local
- static void Main(string[] args)
- {
- InitializeProcess();
- }
-
- private static void InitializeProcess()
- {
- var process = new KeyDefinitionProcessor();
- process.RunProcess();
- }
- }
-}
diff --git a/src/InvvardDev.EZLayoutDisplay.Console/Properties/AssemblyInfo.cs b/src/InvvardDev.EZLayoutDisplay.Console/Properties/AssemblyInfo.cs
deleted file mode 100644
index 238d2a11..00000000
--- a/src/InvvardDev.EZLayoutDisplay.Console/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-using System.Reflection;
-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("InvvardDev.EZLayoutDisplay.Console")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("InvvardDev.EZLayoutDisplay.Console")]
-[assembly: AssemblyCopyright("Copyright © 2019")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("cc579192-c568-42b4-969c-445d5f0d79e1")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/src/InvvardDev.EZLayoutDisplay.Console/packages.config b/src/InvvardDev.EZLayoutDisplay.Console/packages.config
deleted file mode 100644
index 0abde8c2..00000000
--- a/src/InvvardDev.EZLayoutDisplay.Console/packages.config
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/src/InvvardDev.EZLayoutDisplay.Console/readme.md b/src/InvvardDev.EZLayoutDisplay.Console/readme.md
deleted file mode 100644
index fe60024a..00000000
--- a/src/InvvardDev.EZLayoutDisplay.Console/readme.md
+++ /dev/null
@@ -1,25 +0,0 @@
-# How-to update key definitions
-## Javascript definition to JSON
-- Open a tab in your prefered browser and go to https://playcode.io/259701?tabs=console&script.js&output
- (or open [KeyDefinitionsJSProcessor.js](https://github.com/Invvard/EZLayoutDisplay/blob/master/resources/Scripts/KeyDefinitionsJSProcessor.js) in an environment where you can run it),
-- In an other tab, open the js file : https://configure.ergodox-ez.com/static/js/config/keyDefinitions.js (you may need to use your browser developer tool),
-- Select and copy the whole keyCodes constant object (around line 51 to 1243) with the surroundings curly braces,
-- Paste it in the KeyDefinitionJSProcessor.js script (replace the previous version),
-- Run the script : in the console, you'll find the generated JSON,
-- Copy-paste this JSON into a file,
-- Save the file under the name 'keyDefinitions.json' in the same folder where you'll run the console APP.
-
-## JSON to EZLayoutDisplay
-- Go to the Console App folder,
-- Verify the 'keyDefinitions.json' file is present,
-- Run the console app,
-- If everything went well, you'll see a file named 'keyDefinitions.output.json',
-
-## Integrate the new definitions
-- Open Visual Studio,
-- In the 'InvvardDev.EZLayoutDisplay.Desktop' project properties, open the file 'keyDefinitions.json',
-- In this file, copy-paste the content of the 'keyDefinitions.output.json' you just generated,
-- VS should automatically format the pasted JSON but we don't want this, so just CTRL+Z once and it will be inlined back again,
-- Save the file.
-
-Now, if you update your layout with the main application, you'll see the characters in their last version.
diff --git a/src/InvvardDev.EZLayoutDisplay.Desktop/App.config b/src/InvvardDev.EZLayoutDisplay.Desktop/App.config
index 68727d12..6c6107cf 100644
--- a/src/InvvardDev.EZLayoutDisplay.Desktop/App.config
+++ b/src/InvvardDev.EZLayoutDisplay.Desktop/App.config
@@ -1,18 +1,18 @@
-
+
-
+
-
+
-
-
+
+
@@ -26,7 +26,7 @@
{"modifiers":[0,1,2,4],"keycode":32}
-
+
diff --git a/src/InvvardDev.EZLayoutDisplay.Desktop/Helper/EZLayoutMaker.cs b/src/InvvardDev.EZLayoutDisplay.Desktop/Helper/EZLayoutMaker.cs
index 3331d5f9..493af00a 100644
--- a/src/InvvardDev.EZLayoutDisplay.Desktop/Helper/EZLayoutMaker.cs
+++ b/src/InvvardDev.EZLayoutDisplay.Desktop/Helper/EZLayoutMaker.cs
@@ -3,6 +3,9 @@
using InvvardDev.EZLayoutDisplay.Desktop.Model;
using InvvardDev.EZLayoutDisplay.Desktop.Model.Dictionary;
using InvvardDev.EZLayoutDisplay.Desktop.Model.Enum;
+using InvvardDev.EZLayoutDisplay.Desktop.Model.Ez;
+using InvvardDev.EZLayoutDisplay.Desktop.Model.Ez.Content;
+using InvvardDev.EZLayoutDisplay.Desktop.Model.ZsaModels;
using NLog;
namespace InvvardDev.EZLayoutDisplay.Desktop.Helper
@@ -10,10 +13,7 @@ namespace InvvardDev.EZLayoutDisplay.Desktop.Helper
public class EZLayoutMaker
{
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
-
- private const string NoCommand = "KC_NO";
private const string TransparentKey = "KC_TRANSPARENT";
- private const string KeyCodeOsm = "OSM";
private readonly KeyDefinitionDictionary _keyDefinitionDictionary;
public EZLayoutMaker()
@@ -54,9 +54,11 @@ private EZLayer PrepareEZLayer(ErgodoxLayer ergodoxLayer)
foreach (var ergodoxKey in ergodoxLayer.Keys)
{
- var key = PrepareKeyLabels(ergodoxKey, layer.Color);
+ var keyDisplayMode = SelectKeyDisplayMode(ergodoxKey);
+ var key = PrepareKeyContent(ergodoxKey, keyDisplayMode);
+ key.GlowColor = GetColor(ergodoxKey.GlowColor, layer.Color);
- layer.EZKeys.Add(key);
+ layer.Keys.Add(key);
}
Logger.DebugOutputParam(nameof(layer), layer);
@@ -64,116 +66,109 @@ private EZLayer PrepareEZLayer(ErgodoxLayer ergodoxLayer)
return layer;
}
- private EZKey PrepareKeyLabels(ErgodoxKey ergodoxKey, string layerColor)
+ private KeyDisplayMode SelectKeyDisplayMode(ErgodoxKey ergodoxKey)
{
- Logger.TraceMethod();
- Logger.DebugInputParam(nameof(ergodoxKey), ergodoxKey);
-
- var keyDefinition = GetKeyDefinition(ergodoxKey.Code);
-
- /** Every category has a label, so no need to make a special case :
- *
- * KeyCategory.Autoshift
- * KeyCategory.Digit
- * KeyCategory.Letters
- * KeyCategory.Fn
- * KeyCategory.Fw
- * KeyCategory.Lang
- * KeyCategory.Numpad
- * KeyCategory.Other
- * KeyCategory.Punct
- * KeyCategory.ShiftedPunct
- * KeyCategory.System
- *
- **/
- var key = new EZKey
- {
- KeyCategory = keyDefinition.KeyCategory,
- Label = new KeyLabel(ergodoxKey.CustomLabel != null ? ergodoxKey.CustomLabel : keyDefinition.Label, keyDefinition.IsGlyph),
- Color = GetColor(ergodoxKey.GlowColor, layerColor),
- DisplayType = KeyDisplayType.SimpleLabel
- };
-
- switch (keyDefinition.KeyCategory)
+ var features = new List {
+ ergodoxKey.Tap,
+ ergodoxKey.Hold,
+ ergodoxKey.DoubleTap,
+ ergodoxKey.TapHold
+ }.Where(f => f != null)
+ .ToList();
+
+ var featureCount = features.Count;
+ var isComplexFeature = featureCount == 1 && (ergodoxKey.DoubleTap != null || ergodoxKey.TapHold != null);
+ KeyDefinition firstKeyDefinition = null;
+ if (features.Any())
{
- case KeyCategory.DualFunction:
-
- if (AddCommandLabel(ergodoxKey, key))
- key.DisplayType = KeyDisplayType.ModifierUnder;
- else
- key.KeyCategory = KeyCategory.Modifier;
-
- break;
- case KeyCategory.Layer:
- case KeyCategory.LayerShortcuts:
- key.Label.Content = string.Format(key.Label.Content, ergodoxKey.Layer.ToString());
-
- if (AddCommandLabel(ergodoxKey, key)) key.DisplayType = KeyDisplayType.ModifierUnder;
-
- break;
-
- case KeyCategory.Modifier:
-
- if (ergodoxKey.Code == KeyCodeOsm && !IsCommandEmpty(ergodoxKey.Command))
- {
- var commandDefinition = GetKeyDefinition(ergodoxKey.Command);
- key.Modifier = new KeyLabel(commandDefinition.Label);
- key.DisplayType = KeyDisplayType.ModifierOnTop;
- }
-
- break;
- case KeyCategory.Media:
- case KeyCategory.Mouse:
- case KeyCategory.Nav:
- case KeyCategory.Spacing:
- case KeyCategory.Shine:
- key.DisplayType = KeyDisplayType.SimpleLabel;
+ firstKeyDefinition = GetKeyDefinition(features.First().Code);
+ }
- break;
+ var category = featureCount switch
+ {
+ 0 => KeyDisplayMode.Empty,
+ 1 when ergodoxKey.Tap?.Macro != null => KeyDisplayMode.Macro,
+ 1 when firstKeyDefinition.Category == KeyCategory.Shine => KeyDisplayMode.ColorControl,
+ 1 when isComplexFeature => KeyDisplayMode.ComplexFeature,
+ 1 when firstKeyDefinition.Category == KeyCategory.Modifier => KeyDisplayMode.Modifier,
+ 1 when !string.IsNullOrWhiteSpace(ergodoxKey.CustomLabel) => KeyDisplayMode.CustomLabel,
+ >= 2 => KeyDisplayMode.DualFunction,
+ _ => KeyDisplayMode.Base
+ };
+
+ return category;
+ }
- case KeyCategory.Shortcuts:
+ private Key PrepareKeyContent(ErgodoxKey ergodoxKey, KeyDisplayMode displayMode)
+ {
+ Logger.TraceMethod();
+ Logger.DebugInputParam(nameof(ergodoxKey), ergodoxKey);
+ Logger.DebugInputParam(nameof(displayMode), displayMode);
- if (!IsCommandEmpty(ergodoxKey.Command))
- {
- var commandDefinition = GetKeyDefinition(ergodoxKey.Command);
- key.Label.Content = $"{key.Label.Content} + {commandDefinition.Label}";
- }
+ var features = new List {
+ ergodoxKey.Tap,
+ ergodoxKey.Hold,
+ ergodoxKey.DoubleTap,
+ ergodoxKey.TapHold }
+ .Where(f => f != null)
+ .ToList();
- break;
- case KeyCategory.French:
- key.InternationalHint = "fr";
+ var key = new Key() { DisplayMode = displayMode };
+ switch (displayMode)
+ {
+ case KeyDisplayMode.CustomLabel:
+ key.Primary = new BaseContent { Label = ergodoxKey.CustomLabel };
break;
- case KeyCategory.German:
- key.InternationalHint = "de";
-
+ case KeyDisplayMode.Macro:
+ key.Primary = new BaseContent { Label = "Macro" };
break;
- case KeyCategory.Hungarian:
- key.InternationalHint = "hu";
-
+ case KeyDisplayMode.Base:
+ case KeyDisplayMode.ComplexFeature:
+ case KeyDisplayMode.Modifier:
+ case KeyDisplayMode.ColorControl:
+ key.Primary = GetDisplayedFeature(features[0]);
break;
- case KeyCategory.Spanish:
- key.InternationalHint = "es";
+ case KeyDisplayMode.DualFunction:
+ key.Primary = GetDisplayedFeature(features[0]);
+ key.Secondary = GetDisplayedFeature(features[1]);
+ if (key.Primary.Label.Length > 1) key.Primary.Tag = "";
+ if (key.Secondary.Label.Length > 1) key.Secondary.Tag = "";
break;
- case KeyCategory.Nordic:
- key.InternationalHint = "no";
-
+ default:
+ key.Primary = new BaseContent { Label = string.Empty };
break;
}
- ProcessModifiers(ergodoxKey, key);
-
Logger.DebugOutputParam(nameof(key), key);
return key;
}
- private static string GetColor(string keyColor, string defaultColor = "#777")
+ private BaseContent GetDisplayedFeature(ErgodoxKeyFeature feature)
{
- var fontColor = string.IsNullOrWhiteSpace(keyColor) ? defaultColor : keyColor;
+ var mods = ProcessModifiers(feature.Modifiers);
+ var keyDefinition = GetKeyDefinition(feature.Code);
- return fontColor;
+ var keyFeature = keyDefinition switch
+ {
+ // ColorControl Key - Color picker
+ { KeyCode: "RGB" } => new ColorPicker { Label = keyDefinition.Label, ColorCode = feature.Color },
+ // Layer toggle key
+ { Category: KeyCategory.Layer } => new Layer { Label = keyDefinition.Label, Id = feature.Layer.Value, Tag = keyDefinition.Tag },
+ { IsGlyph: true } => new Glyph { Label = keyDefinition.Label, Modifier = mods },
+ // Modded label
+ _ when !string.IsNullOrWhiteSpace(mods) => new BaseContent { Label = $"{mods}+{keyDefinition.Label}", Tag = keyDefinition.Tag },
+ _ => new BaseContent { Label = keyDefinition.Label, Tag = keyDefinition.Tag }
+ };
+
+ return keyFeature;
+ }
+
+ private static string GetColor(string keyColor, string defaultColor = "#777")
+ {
+ return string.IsNullOrWhiteSpace(keyColor) ? defaultColor : keyColor;
}
private KeyDefinition GetKeyDefinition(string ergodoxKeyCode)
@@ -189,33 +184,13 @@ private KeyDefinition GetKeyDefinition(string ergodoxKeyCode)
return keyDefinition;
}
- ///
- /// Apply the command label.
- ///
- /// The containing the command to be applied.
- /// The to apply the command to.
- /// True if command has been applied.
- private bool AddCommandLabel(ErgodoxKey ergodoxKey, EZKey key)
+ private string ProcessModifiers(ErgodoxModifiers modifiers)
{
- if (IsCommandEmpty(ergodoxKey.Command)) return false;
+ if (modifiers == null) return "";
- var commandDefinition = GetKeyDefinition(ergodoxKey.Command);
- key.Modifier = key.Label;
- key.Label = new KeyLabel(commandDefinition.Label, commandDefinition.IsGlyph);
+ var mods = GetModifiersApplied(modifiers);
- return true;
- }
-
- private void ProcessModifiers(ErgodoxKey ergodoxKey, EZKey key)
- {
- if (ergodoxKey.Modifiers == null) return;
-
- var mods = GetModifiersApplied(ergodoxKey.Modifiers);
-
- if (!mods.Any()) return;
-
- key.Modifier = new KeyLabel(AggregateModifierLabels(mods));
- key.DisplayType = KeyDisplayType.ModifierOnTop;
+ return AggregateModifierLabels(mods);
}
private List GetModifiersApplied(ErgodoxModifiers ergodoxModifiers)
@@ -223,53 +198,27 @@ private List GetModifiersApplied(ErgodoxModifiers ergodoxModifiers)
var keyModifiers = new KeyModifierDictionary();
var mods = new List();
- if (ergodoxModifiers.LeftAlt) mods.Add(keyModifiers.EZModifiers.First(m => m.KeyModifier == KeyModifier.LeftAlt));
-
- if (ergodoxModifiers.LeftCtrl) mods.Add(keyModifiers.EZModifiers.First(m => m.KeyModifier == KeyModifier.LeftCtrl));
-
- if (ergodoxModifiers.LeftShift) mods.Add(keyModifiers.EZModifiers.First(m => m.KeyModifier == KeyModifier.LeftShift));
-
- if (ergodoxModifiers.LeftWin) mods.Add(keyModifiers.EZModifiers.First(m => m.KeyModifier == KeyModifier.LeftWin));
-
- if (ergodoxModifiers.RightAlt) mods.Add(keyModifiers.EZModifiers.First(m => m.KeyModifier == KeyModifier.RightAlt));
-
- if (ergodoxModifiers.RightCtrl) mods.Add(keyModifiers.EZModifiers.First(m => m.KeyModifier == KeyModifier.RightCtrl));
-
- if (ergodoxModifiers.RightShift) mods.Add(keyModifiers.EZModifiers.First(m => m.KeyModifier == KeyModifier.RightShift));
-
- if (ergodoxModifiers.RightWin) mods.Add(keyModifiers.EZModifiers.First(m => m.KeyModifier == KeyModifier.RightWin));
+ if (ergodoxModifiers.LeftAlt) mods.Add(keyModifiers.EZModifiers[KeyModifier.LeftAlt]);
+ if (ergodoxModifiers.LeftCtrl) mods.Add(keyModifiers.EZModifiers[KeyModifier.LeftCtrl]);
+ if (ergodoxModifiers.LeftShift) mods.Add(keyModifiers.EZModifiers[KeyModifier.LeftShift]);
+ if (ergodoxModifiers.LeftWin) mods.Add(keyModifiers.EZModifiers[KeyModifier.LeftWin]);
+ if (ergodoxModifiers.RightAlt) mods.Add(keyModifiers.EZModifiers[KeyModifier.RightAlt]);
+ if (ergodoxModifiers.RightCtrl) mods.Add(keyModifiers.EZModifiers[KeyModifier.RightCtrl]);
+ if (ergodoxModifiers.RightShift) mods.Add(keyModifiers.EZModifiers[KeyModifier.RightShift]);
+ if (ergodoxModifiers.RightWin) mods.Add(keyModifiers.EZModifiers[KeyModifier.RightWin]);
return mods.OrderBy(m => m.Index).ToList();
}
private string AggregateModifierLabels(List mods)
{
- string subLabel;
-
- switch (mods.Count)
+ return mods.Count switch
{
- case 1:
- subLabel = mods.First().Labels[EZModifier.LabelSize.Large];
-
- break;
- case 2:
- subLabel = mods.Select(m => m.Labels[EZModifier.LabelSize.Medium]).Aggregate((seed, inc) => $"{seed}+{inc}");
-
- break;
- default:
- subLabel = mods.Select(m => m.Labels[EZModifier.LabelSize.Small]).Aggregate((seed, inc) => $"{seed}+{inc}");
-
- break;
- }
-
- return subLabel;
- }
-
- private bool IsCommandEmpty(string command)
- {
- var isEmpty = string.IsNullOrWhiteSpace(command) || command == NoCommand || command == KeyCodeOsm;
-
- return isEmpty;
+ 1 => mods.First().Labels[EZModifier.LabelSize.Large],
+ 2 => mods.Select(m => m.Labels[EZModifier.LabelSize.Medium]).Aggregate((seed, inc) => $"{seed}+{inc}"),
+ > 2 => mods.Select(m => m.Labels[EZModifier.LabelSize.Small]).Aggregate((seed, inc) => $"{seed}+{inc}"),
+ _ => ""
+ };
}
}
}
\ No newline at end of file
diff --git a/src/InvvardDev.EZLayoutDisplay.Desktop/Helper/KeyContentTemplateSelector.cs b/src/InvvardDev.EZLayoutDisplay.Desktop/Helper/KeyContentTemplateSelector.cs
index 3724e9d1..f48a20cf 100644
--- a/src/InvvardDev.EZLayoutDisplay.Desktop/Helper/KeyContentTemplateSelector.cs
+++ b/src/InvvardDev.EZLayoutDisplay.Desktop/Helper/KeyContentTemplateSelector.cs
@@ -8,37 +8,14 @@ namespace InvvardDev.EZLayoutDisplay.Desktop.Helper
{
public class KeyContentTemplateSelector : DataTemplateSelector
{
- public DataTemplate SimpleLabelDataTemplate { private get; set; }
- public DataTemplate ModifierOnTopDataTemplate { private get; set; }
- public DataTemplate ModifierUnderDataTemplate { private get; set; }
+ public DataTemplate SingleFeatureDataTemplate { private get; set; }
+ public DataTemplate DoubleFeatureDataTemplate { private get; set; }
public override DataTemplate SelectTemplate(object item, DependencyObject container)
- {
- DataTemplate template = SimpleLabelDataTemplate;
-
- if (!(item is KeyTemplate key)) return template;
-
- switch (key.EZKey.DisplayType)
+ => item switch
{
- case KeyDisplayType.None:
- case KeyDisplayType.SimpleLabel:
- template = SimpleLabelDataTemplate;
-
- break;
- case KeyDisplayType.ModifierOnTop:
- template = ModifierOnTopDataTemplate;
-
- break;
- case KeyDisplayType.ModifierUnder:
- template = ModifierUnderDataTemplate;
-
- break;
- default:
-
- throw new ArgumentOutOfRangeException();
- }
-
- return template;
- }
+ KeyTemplate { Key.DisplayMode: KeyDisplayMode.DualFunction } => DoubleFeatureDataTemplate,
+ _ => SingleFeatureDataTemplate
+ };
}
}
\ No newline at end of file
diff --git a/src/InvvardDev.EZLayoutDisplay.Desktop/Helper/KeyFeatureTemplateSelector.cs b/src/InvvardDev.EZLayoutDisplay.Desktop/Helper/KeyFeatureTemplateSelector.cs
new file mode 100644
index 00000000..a4fb0e20
--- /dev/null
+++ b/src/InvvardDev.EZLayoutDisplay.Desktop/Helper/KeyFeatureTemplateSelector.cs
@@ -0,0 +1,27 @@
+using System.Windows;
+using System.Windows.Controls;
+using InvvardDev.EZLayoutDisplay.Desktop.Model.Ez.Content;
+
+namespace InvvardDev.EZLayoutDisplay.Desktop.Helper
+{
+ public class KeyFeatureTemplateSelector : DataTemplateSelector
+ {
+ public DataTemplate SimpleLabelDataTemplate { private get; set; }
+ public DataTemplate GlyphDataTemplate { private get; set; }
+ public DataTemplate ModdedGlyphDataTemplate { private get; set; }
+ public DataTemplate LayerDataTemplate { private get; set; }
+ public DataTemplate ColorPickerDataTemplate { private get; set; }
+
+ public override DataTemplate SelectTemplate(object item, DependencyObject container)
+ {
+ return item switch
+ {
+ Glyph glyph when !string.IsNullOrWhiteSpace(glyph.Modifier) => ModdedGlyphDataTemplate,
+ Glyph glyph when string.IsNullOrWhiteSpace(glyph.Modifier) => GlyphDataTemplate,
+ Layer => LayerDataTemplate,
+ ColorPicker => ColorPickerDataTemplate,
+ _ => SimpleLabelDataTemplate
+ };
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/InvvardDev.EZLayoutDisplay.Desktop/Helper/LoggerHelper.cs b/src/InvvardDev.EZLayoutDisplay.Desktop/Helper/LoggerHelper.cs
index 13f645d8..c31e3aac 100644
--- a/src/InvvardDev.EZLayoutDisplay.Desktop/Helper/LoggerHelper.cs
+++ b/src/InvvardDev.EZLayoutDisplay.Desktop/Helper/LoggerHelper.cs
@@ -58,24 +58,12 @@ private static void DebugParam(Logger logger,
internal static LogLevel GetLogLevel(string value)
{
- LogLevel level;
-
- switch (value.ToLower())
+ LogLevel level = value.ToLower() switch
{
- case "debug":
- level = LogLevel.Debug;
-
- break;
- case "trace":
- level = LogLevel.Trace;
-
- break;
- default:
- level = LogLevel.Warn;
-
- break;
- }
-
+ "debug" => LogLevel.Debug,
+ "trace" => LogLevel.Trace,
+ _ => LogLevel.Warn,
+ };
return level;
}
diff --git a/src/InvvardDev.EZLayoutDisplay.Desktop/InvvardDev.EZLayoutDisplay.Desktop.csproj b/src/InvvardDev.EZLayoutDisplay.Desktop/InvvardDev.EZLayoutDisplay.Desktop.csproj
index 962d6457..a5a0a3d4 100644
--- a/src/InvvardDev.EZLayoutDisplay.Desktop/InvvardDev.EZLayoutDisplay.Desktop.csproj
+++ b/src/InvvardDev.EZLayoutDisplay.Desktop/InvvardDev.EZLayoutDisplay.Desktop.csproj
@@ -10,6 +10,7 @@
InvvardDev.EZLayoutDisplay.Desktop
InvvardDev.EZLayoutDisplay.Desktop
v4.8
+ 10.0
512
{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
4
@@ -56,31 +57,6 @@
-
- ..\packages\CommonServiceLocator.2.0.4\lib\net47\CommonServiceLocator.dll
-
-
- ..\packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.dll
-
-
- ..\packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.Extras.dll
-
-
- ..\packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.Platform.dll
-
-
- ..\packages\Hardcodet.NotifyIcon.Wpf.1.0.8\lib\net451\Hardcodet.Wpf.TaskbarNotification.dll
-
-
-
- ..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll
-
-
- ..\packages\NLog.4.6.3\lib\net45\NLog.dll
-
-
- ..\packages\NonInvasiveKeyboardHookLibrary.1.4.0\lib\net452\NonInvasiveKeyboardHookLibrary.dll
-
@@ -90,9 +66,6 @@
-
- ..\packages\MvvmLightLibs.5.4.1.1\lib\net45\System.Windows.Interactivity.dll
-
@@ -108,10 +81,17 @@
MSBuild:Compile
Designer
+
-
-
+
+
+
+
+
+
+
+
@@ -128,19 +108,18 @@
-
+
-
-
+
-
-
-
+
+
+
@@ -221,7 +200,6 @@
Settings.settings
True
-
@@ -235,7 +213,7 @@
Designer
-
+
@@ -284,6 +262,27 @@
+
+
+ 2.0.4
+
+
+ 1.0.8
+
+
+ 5.4.1.1
+
+
+ 12.0.2
+
+
+ 4.6.3
+
+
+ 1.4.0
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+ SingleFeatureDataTemplate="{StaticResource SingleFeatureDataTemplate}"
+ DoubleFeatureDataTemplate="{StaticResource DoubleFeatureDataTemplate}" />
\ No newline at end of file
diff --git a/src/InvvardDev.EZLayoutDisplay.Desktop/View/Converter/KeyCategoryToBrushConverter.cs b/src/InvvardDev.EZLayoutDisplay.Desktop/View/Converter/KeyCategoryToBrushConverter.cs
index 87e5ebf4..ed41cdda 100644
--- a/src/InvvardDev.EZLayoutDisplay.Desktop/View/Converter/KeyCategoryToBrushConverter.cs
+++ b/src/InvvardDev.EZLayoutDisplay.Desktop/View/Converter/KeyCategoryToBrushConverter.cs
@@ -11,38 +11,39 @@ namespace InvvardDev.EZLayoutDisplay.Desktop.View.Converter
public class KeyCategoryToBrushConverter : IValueConverter
{
public SolidColorBrush DefaultBackgroundBrush { private get; set; }
+ public SolidColorBrush ColorControlBackgroundBrush { private get; set; }
+ public SolidColorBrush ComplexFeatureBackgroundBrush { private get; set; }
+ public SolidColorBrush CustomLabelBackgroundBrush { private get; set; }
public SolidColorBrush DualFunctionBackgroundBrush { private get; set; }
+ public SolidColorBrush MacroBackgroundBrush { private get; set; }
public SolidColorBrush ModifierBackgroundBrush { private get; set; }
- public SolidColorBrush ShineBackgroundBrush { private get; set; }
public KeyCategoryToBrushConverter()
{
- DefaultBackgroundBrush = Application.Current.Resources["BaseDefaultBackgroundBrush"] as SolidColorBrush;
- DualFunctionBackgroundBrush = Application.Current.Resources["BaseDualFunctionBackgroundBrush"] as SolidColorBrush;
- ModifierBackgroundBrush = Application.Current.Resources["BaseModifierBackgroundBrush"] as SolidColorBrush;
- ShineBackgroundBrush = Application.Current.Resources["BaseShineBackgroundBrush"] as SolidColorBrush;
+ DefaultBackgroundBrush = Application.Current.Resources["DefaultBackgroundBrush"] as SolidColorBrush;
+ ColorControlBackgroundBrush = Application.Current.Resources["ColorControlBackgroundBrush"] as SolidColorBrush;
+ ComplexFeatureBackgroundBrush = Application.Current.Resources["ComplexFeatureBackgroundBrush"] as SolidColorBrush;
+ CustomLabelBackgroundBrush = Application.Current.Resources["CustomLabelBackgroundBrush"] as SolidColorBrush;
+ DualFunctionBackgroundBrush = Application.Current.Resources["DualFunctionBackgroundBrush"] as SolidColorBrush;
+ MacroBackgroundBrush = Application.Current.Resources["MacroBackgroundBrush"] as SolidColorBrush;
+ ModifierBackgroundBrush = Application.Current.Resources["ModifierBackgroundBrush"] as SolidColorBrush;
}
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
- if (!(value is KeyCategory)) return null;
-
- SolidColorBrush brush;
- switch ((KeyCategory)value)
+ SolidColorBrush brush = null;
+ if (value is KeyDisplayMode displayMode)
{
- case KeyCategory.LayerShortcuts:
- case KeyCategory.DualFunction:
- brush = DualFunctionBackgroundBrush;
- break;
- case KeyCategory.Modifier:
- brush = ModifierBackgroundBrush;
- break;
- case KeyCategory.Shine:
- brush = ShineBackgroundBrush;
- break;
- default:
- brush = DefaultBackgroundBrush;
- break;
+ brush = displayMode switch
+ {
+ KeyDisplayMode.ColorControl => ColorControlBackgroundBrush,
+ KeyDisplayMode.ComplexFeature => ComplexFeatureBackgroundBrush,
+ KeyDisplayMode.CustomLabel => CustomLabelBackgroundBrush,
+ KeyDisplayMode.DualFunction => DualFunctionBackgroundBrush,
+ KeyDisplayMode.Macro => MacroBackgroundBrush,
+ KeyDisplayMode.Modifier => ModifierBackgroundBrush,
+ _ => DefaultBackgroundBrush
+ };
}
return brush;
diff --git a/src/InvvardDev.EZLayoutDisplay.Desktop/ViewModel/DisplayLayoutViewModel.cs b/src/InvvardDev.EZLayoutDisplay.Desktop/ViewModel/DisplayLayoutViewModel.cs
index 2dcc1a12..a7bcc0b7 100644
--- a/src/InvvardDev.EZLayoutDisplay.Desktop/ViewModel/DisplayLayoutViewModel.cs
+++ b/src/InvvardDev.EZLayoutDisplay.Desktop/ViewModel/DisplayLayoutViewModel.cs
@@ -11,12 +11,14 @@
using InvvardDev.EZLayoutDisplay.Desktop.Helper;
using InvvardDev.EZLayoutDisplay.Desktop.Model;
using InvvardDev.EZLayoutDisplay.Desktop.Model.Enum;
+using InvvardDev.EZLayoutDisplay.Desktop.Model.Ez.Content;
using InvvardDev.EZLayoutDisplay.Desktop.Model.Messenger;
using InvvardDev.EZLayoutDisplay.Desktop.Properties;
using InvvardDev.EZLayoutDisplay.Desktop.Service.Interface;
using InvvardDev.EZLayoutDisplay.Desktop.View;
using Newtonsoft.Json;
using NLog;
+using Key = InvvardDev.EZLayoutDisplay.Desktop.Model.Ez.Key;
namespace InvvardDev.EZLayoutDisplay.Desktop.ViewModel
{
@@ -182,29 +184,25 @@ public bool IsWindowPinned
/// Lost focus command.
///
public ICommand LostFocusCommand =>
- _lostFocusCommand
- ?? (_lostFocusCommand = new RelayCommand(LostFocus, LostFocusCanExecute));
+ _lostFocusCommand ??= new RelayCommand(LostFocus, LostFocusCanExecute);
///
/// Hide window command.
///
public ICommand HideWindowCommand =>
- _hideWindowCommand
- ?? (_hideWindowCommand = new RelayCommand(LostFocus));
+ _hideWindowCommand ??= new RelayCommand(LostFocus);
///
/// Next layer command.
///
public ICommand NextLayerCommand =>
- _nextLayerCommand
- ?? (_nextLayerCommand = new RelayCommand(NextLayer, NextLayerCanExecute));
+ _nextLayerCommand ??= new RelayCommand(NextLayer, NextLayerCanExecute);
///
/// Next layer command.
///
public ICommand ScrollLayerCommand =>
- _scrollLayerCommand
- ?? (_scrollLayerCommand = new RelayCommand(ScrollLayer));
+ _scrollLayerCommand ??= new RelayCommand(ScrollLayer);
#endregion
@@ -262,7 +260,7 @@ private async void LoadCompleteLayout()
if (_ezLayout?.EZLayers == null
|| !_ezLayout.EZLayers.Any()
- || !_ezLayout.EZLayers.SelectMany(l => l.EZKeys).Any())
+ || !_ezLayout.EZLayers.SelectMany(l => l.Keys).Any())
{
Logger.Info("No layout available");
NoLayoutWarningFirstLine = "No layout available!";
@@ -270,7 +268,8 @@ private async void LoadCompleteLayout()
NoLayoutAvailable = true;
return;
- } else if (!_layoutService.SupportsGeometry(_ezLayout.Geometry))
+ }
+ else if (!_layoutService.SupportsGeometry(_ezLayout.Geometry))
{
Logger.Info("Geometry not supported");
NoLayoutWarningFirstLine = "Not supported!";
@@ -301,30 +300,29 @@ private void LoadDesignTimeModel()
// ReSharper disable once UseObjectOrCollectionInitializer
CurrentLayoutTemplate = new ObservableCollection(layoutDefinition);
- CurrentLayoutTemplate[0].EZKey = new EZKey {
- Label = new KeyLabel("="),
- Modifier = new KeyLabel("Left Shift"),
- DisplayType = KeyDisplayType.ModifierOnTop,
- KeyCategory = KeyCategory.DualFunction,
- Color = "#111"
- };
-
- CurrentLayoutTemplate[1].EZKey = new EZKey {
- Label = new KeyLabel("LT \u2192 1"),
- DisplayType = KeyDisplayType.SimpleLabel,
- KeyCategory = KeyCategory.DualFunction,
- Color = "#BBB"
- };
-
- for (int i = 2 ; i < CurrentLayoutTemplate.Count ; i++)
+ CurrentLayoutTemplate[0].Key = new Key
+ {
+ Primary = new BaseContent { Label = "Shift + =" },
+ DisplayMode = KeyDisplayMode.Base,
+ GlowColor = "#111"
+ };
+
+ CurrentLayoutTemplate[1].Key = new Key
{
- CurrentLayoutTemplate[i].EZKey = new EZKey {
- Label = new KeyLabel("E"),
- Modifier = new KeyLabel("Left Shift"),
- KeyCategory = KeyCategory.French,
- InternationalHint = "fr",
- Color = "#777"
- };
+ Primary = new Layer { Label = "\u2192", Id = 1 },
+ Secondary = new Layer { Label = "\u2192", Id = 2 },
+ DisplayMode = KeyDisplayMode.DualFunction,
+ GlowColor = "#BBB"
+ };
+
+ for (int i = 2; i < CurrentLayoutTemplate.Count; i++)
+ {
+ CurrentLayoutTemplate[i].Key = new Key
+ {
+ Primary = new BaseContent { Label = "Shift + E", Tag = "fr" },
+ DisplayMode = KeyDisplayMode.Base,
+ GlowColor = "#777"
+ };
}
}
@@ -334,13 +332,14 @@ private async Task PopulateLayoutTemplates(string geometry)
foreach (var ezLayer in _ezLayout.EZLayers)
{
- if (!(await LoadLayoutDefinition(geometry) is List layoutTemplate)) break;
+ if (await LoadLayoutDefinition(geometry) is not List layoutTemplate)
+ break;
if (layoutTemplate.Count == 0) return;
- for (int j = 0 ; j < layoutTemplate.Count ; j++)
+ for (int j = 0; j < layoutTemplate.Count; j++)
{
- layoutTemplate[j].EZKey = ezLayer.EZKeys[j];
+ layoutTemplate[j].Key = ezLayer.Keys[j];
}
_layoutTemplates.Add(layoutTemplate);
@@ -389,7 +388,6 @@ private void LostFocus()
private void NextLayer()
{
Logger.TraceRelayCommand();
-
VaryLayer(1);
}
@@ -397,15 +395,14 @@ private void ScrollLayer(MouseWheelEventArgs e)
{
Logger.TraceRelayCommand();
- if (e.Delta < 0)
+ var variation = e switch
{
- VaryLayer(1);
- }
+ { Delta: < 0 } => 1,
+ { Delta: > 0 } => -1,
+ _ => 0
+ };
- if (e.Delta > 0)
- {
- VaryLayer(-1);
- }
+ VaryLayer(variation);
}
private void VaryLayer(int variation)
@@ -414,46 +411,21 @@ private void VaryLayer(int variation)
var maxLayerIndex = _ezLayout.EZLayers.Count - 1;
- switch (CurrentLayerIndex)
+ CurrentLayerIndex = variation switch
{
- case var _ when maxLayerIndex <= 0:
- CurrentLayerIndex = 0;
-
- break;
- case var _ when CurrentLayerIndex <= 0 && variation < 0:
- CurrentLayerIndex = maxLayerIndex;
-
- break;
- case var _ when CurrentLayerIndex > 0 && variation < 0:
- CurrentLayerIndex--;
-
- break;
- case var _ when CurrentLayerIndex >= maxLayerIndex && variation > 0:
- CurrentLayerIndex = 0;
-
- break;
- case var _ when CurrentLayerIndex < maxLayerIndex && variation > 0:
- CurrentLayerIndex++;
-
- break;
- }
+ < 0 when CurrentLayerIndex <= 0 => maxLayerIndex,
+ < 0 when CurrentLayerIndex > 0 => --CurrentLayerIndex,
+ > 0 when CurrentLayerIndex >= maxLayerIndex => 0,
+ > 0 when CurrentLayerIndex < maxLayerIndex => ++CurrentLayerIndex,
+ _ => CurrentLayerIndex
+ };
SwitchLayer();
}
- private bool NextLayerCanExecute()
- {
- var canExecute = _layoutTemplates.Any();
-
- return canExecute;
- }
+ private bool NextLayerCanExecute() => _layoutTemplates.Any();
- private bool LostFocusCanExecute()
- {
- var canExecute = !IsWindowPinned;
-
- return canExecute;
- }
+ private bool LostFocusCanExecute() => !IsWindowPinned;
#endregion
diff --git a/src/InvvardDev.EZLayoutDisplay.Desktop/ViewModel/SettingsViewModel.cs b/src/InvvardDev.EZLayoutDisplay.Desktop/ViewModel/SettingsViewModel.cs
index 0a993510..d11489e5 100644
--- a/src/InvvardDev.EZLayoutDisplay.Desktop/ViewModel/SettingsViewModel.cs
+++ b/src/InvvardDev.EZLayoutDisplay.Desktop/ViewModel/SettingsViewModel.cs
@@ -70,50 +70,43 @@ public class SettingsViewModel : ViewModelBase
/// Open tag search command.
///
public ICommand OpenTagSearchCommand =>
- _openTagSearchCommand
- ?? (_openTagSearchCommand = new RelayCommand(OpenTagSearchUrl));
+ _openTagSearchCommand ??= new RelayCommand(OpenTagSearchUrl);
///
/// Download HEX file.
///
public ICommand DownloadHexFileCommand =>
- _downloadHexFileCommand
- ?? (_downloadHexFileCommand = new RelayCommand(DownloadHexFile, LayoutIsCompiled));
+ _downloadHexFileCommand ??= new RelayCommand(DownloadHexFile, LayoutIsCompiled);
///
/// Download Sources ZIP.
///
public ICommand DownloadSourcesCommand =>
- _downloadSourcesCommand
- ?? (_downloadSourcesCommand = new RelayCommand(DownloadSources, LayoutIsCompiled));
+ _downloadSourcesCommand ??= new RelayCommand(DownloadSources, LayoutIsCompiled);
///
/// Cancel settings edition.
///
public ICommand CancelSettingsCommand =>
- _cancelSettingsCommand
- ?? (_cancelSettingsCommand = new RelayCommand(CancelSettings, IsDirty));
+ _cancelSettingsCommand ??= new RelayCommand(CancelSettings, IsDirty);
///
/// Applies the settings.
///
public ICommand ApplySettingsCommand =>
- _applySettingsCommand
- ?? (_applySettingsCommand = new RelayCommand(SaveSettings, IsDirty));
+ _applySettingsCommand ??= new RelayCommand(SaveSettings, IsDirty);
///
/// Update the layout from Ergodox website.
///
public ICommand UpdateLayoutCommand =>
- _updateLayoutCommand
- ?? (_updateLayoutCommand = new RelayCommand(SaveSettings));
+ _updateLayoutCommand ??= new RelayCommand(SaveSettings);
///
/// Closes the settings window.
///
public ICommand CloseSettingsCommand =>
- _closeSettingsCommand
- ?? (_closeSettingsCommand = new RelayCommand(CloseSettingsWindow));
+ _closeSettingsCommand ??= new RelayCommand(CloseSettingsWindow);
#endregion
@@ -179,13 +172,13 @@ public string LayoutStatus
public ObservableCollection Tags
{
- get => _tags ?? (_tags = new ObservableCollection());
+ get => _tags ??= new ObservableCollection();
private set => Set(ref _tags, value);
}
public ObservableCollection Layers
{
- get => _layers ?? (_layers = new ObservableCollection());
+ get => _layers ??= new ObservableCollection();
private set => Set(ref _layers, value);
}
@@ -382,8 +375,8 @@ private void UpdateButtonCanExecute()
{
Logger.TraceMethod();
- ((RelayCommand) ApplySettingsCommand).RaiseCanExecuteChanged();
- ((RelayCommand) CancelSettingsCommand).RaiseCanExecuteChanged();
+ ((RelayCommand)ApplySettingsCommand).RaiseCanExecuteChanged();
+ ((RelayCommand)CancelSettingsCommand).RaiseCanExecuteChanged();
}
private bool IsDirty()
@@ -451,7 +444,7 @@ private void ClearLayoutInfo()
LayoutTitle = "";
KeyboardModel = "";
LayoutStatus = "";
-
+
_layoutIsCompiled = false;
}
@@ -478,27 +471,13 @@ private void UpdateLayoutInfo(ErgodoxLayout layoutInfo)
private string GetKeyBoardDescription(string keyboardGeometry, string revisionModel)
{
- string keyboardDescription;
-
- switch (keyboardGeometry)
+ string keyboardDescription = keyboardGeometry switch
{
- case "ergodox-ez":
- keyboardDescription = "ErgoDox EZ ";
-
- break;
- case "planck-ez":
- keyboardDescription = "Planck EZ ";
-
- break;
- case "moonlander":
- keyboardDescription = "Moonlander ";
- break;
- default:
- keyboardDescription = $"{keyboardGeometry} ";
-
- break;
- }
-
+ "ergodox-ez" => "ErgoDox EZ ",
+ "planck-ez" => "Planck EZ ",
+ "moonlander" => "Moonlander ",
+ _ => $"{keyboardGeometry} ",
+ };
keyboardDescription += char.ToUpper(revisionModel[0]) + revisionModel.Substring(1);
return keyboardDescription;
@@ -510,8 +489,8 @@ private void UpdateLayoutButtons(Revision revision)
_layoutIsCompiled = Uri.IsWellFormedUriString(revision.HexUrl, UriKind.Absolute) && Uri.IsWellFormedUriString(revision.SourcesUrl, UriKind.Absolute);
- ((RelayCommand) DownloadHexFileCommand).RaiseCanExecuteChanged();
- ((RelayCommand) DownloadSourcesCommand).RaiseCanExecuteChanged();
+ ((RelayCommand)DownloadHexFileCommand).RaiseCanExecuteChanged();
+ ((RelayCommand)DownloadSourcesCommand).RaiseCanExecuteChanged();
_hexFileUri = revision.HexUrl;
_sourcesZipUri = revision.SourcesUrl;
@@ -568,7 +547,7 @@ private void ExtractLayoutUrlIds(string layoutUrl)
}
Logger.Debug($"Layout URL = {layoutUrl}");
- Logger.Debug($"Layout URL has {(match.Success ? "": "NOT ")}been matched");
+ Logger.Debug($"Layout URL has {(match.Success ? "" : "NOT ")}been matched");
Logger.Debug($"Layout Hash ID = {CurrentLayoutHashId}");
Logger.Debug($"Keyboard geometry = {CurrentGeometry}");
Logger.Debug($"Layout Revision ID = {CurrentLayoutRevisionId}");
diff --git a/src/InvvardDev.EZLayoutDisplay.Desktop/ViewModel/ViewModelLocator.cs b/src/InvvardDev.EZLayoutDisplay.Desktop/ViewModel/ViewModelLocator.cs
index c35fd667..28fd0452 100644
--- a/src/InvvardDev.EZLayoutDisplay.Desktop/ViewModel/ViewModelLocator.cs
+++ b/src/InvvardDev.EZLayoutDisplay.Desktop/ViewModel/ViewModelLocator.cs
@@ -48,9 +48,6 @@ static ViewModelLocator()
///
/// Gets the Main property.
///
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance",
- "CA1822:MarkMembersAsStatic",
- Justification = "This non-static member is needed for data binding purposes.")]
public MainViewModel Main => ServiceLocator.Current.GetInstance();
public DisplayLayoutViewModel DisplayLayout => ServiceLocator.Current.GetInstance();
diff --git a/src/InvvardDev.EZLayoutDisplay.Desktop/packages.config b/src/InvvardDev.EZLayoutDisplay.Desktop/packages.config
deleted file mode 100644
index 2a1178e3..00000000
--- a/src/InvvardDev.EZLayoutDisplay.Desktop/packages.config
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/InvvardDev.EZLayoutDisplay.Tests/InvvardDev.EZLayoutDisplay.Tests.csproj b/src/InvvardDev.EZLayoutDisplay.Tests/InvvardDev.EZLayoutDisplay.Tests.csproj
index d341b65c..13bb1ec6 100644
--- a/src/InvvardDev.EZLayoutDisplay.Tests/InvvardDev.EZLayoutDisplay.Tests.csproj
+++ b/src/InvvardDev.EZLayoutDisplay.Tests/InvvardDev.EZLayoutDisplay.Tests.csproj
@@ -1,8 +1,5 @@
-
-
-
Debug
@@ -42,35 +39,11 @@
4
-
- ..\packages\Castle.Core.4.3.1\lib\net45\Castle.Core.dll
-
-
- ..\packages\Moq.4.10.1\lib\net45\Moq.dll
-
-
- ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll
-
-
- ..\packages\System.Threading.Tasks.Extensions.4.5.2\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll
-
-
- ..\packages\xunit.assert.2.4.1\lib\netstandard1.1\xunit.assert.dll
-
-
- ..\packages\xunit.extensibility.core.2.4.1\lib\net452\xunit.core.dll
-
-
- ..\packages\xunit.extensibility.execution.2.4.1\lib\net452\xunit.execution.desktop.dll
-
-
- ..\packages\Xunit.StaFact.0.3.18\lib\net452\Xunit.StaFact.dll
-
@@ -93,10 +66,6 @@
SettingsSingleFileGenerator
ContinuousIntegration.Designer.cs
-
-
-
-
@@ -104,18 +73,34 @@
InvvardDev.EZLayoutDisplay.Desktop
+
+
+ 4.16.1
+
+
+ 2.2.8
+
+
+ 13.0.1
+
+
+ 2.1.1
+
+
+ 4.5.4
+
+
+ 2.4.1
+
+
+ 2.4.3
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+ all
+
+
+ 1.0.37
+
+
-
-
- This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/InvvardDev.EZLayoutDisplay.Tests/app.config b/src/InvvardDev.EZLayoutDisplay.Tests/app.config
index 591a25d4..0f7e6947 100644
--- a/src/InvvardDev.EZLayoutDisplay.Tests/app.config
+++ b/src/InvvardDev.EZLayoutDisplay.Tests/app.config
@@ -1,19 +1,19 @@
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
diff --git a/src/InvvardDev.EZLayoutDisplay.Tests/packages.config b/src/InvvardDev.EZLayoutDisplay.Tests/packages.config
deleted file mode 100644
index ac062fb4..00000000
--- a/src/InvvardDev.EZLayoutDisplay.Tests/packages.config
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/InvvardDev.EZLayoutDisplay.Tool.KeyDefinitionProvider/InvvardDev.EZLayoutDisplay.Tool.KeyDefinitionProvider.csproj b/src/InvvardDev.EZLayoutDisplay.Tool.KeyDefinitionProvider/InvvardDev.EZLayoutDisplay.Tool.KeyDefinitionProvider.csproj
new file mode 100644
index 00000000..663a310d
--- /dev/null
+++ b/src/InvvardDev.EZLayoutDisplay.Tool.KeyDefinitionProvider/InvvardDev.EZLayoutDisplay.Tool.KeyDefinitionProvider.csproj
@@ -0,0 +1,37 @@
+
+
+
+ Exe
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ True
+ True
+ KeyCategory.tt
+
+
+
+
+
+ TextTemplatingFileGenerator
+ KeyCategory.cs
+
+
+
+
diff --git a/src/InvvardDev.EZLayoutDisplay.Tool.KeyDefinitionProvider/KeyCategory.cs b/src/InvvardDev.EZLayoutDisplay.Tool.KeyDefinitionProvider/KeyCategory.cs
new file mode 100644
index 00000000..16a07e31
--- /dev/null
+++ b/src/InvvardDev.EZLayoutDisplay.Tool.KeyDefinitionProvider/KeyCategory.cs
@@ -0,0 +1,3 @@
+///
+/// Moved to
+///
\ No newline at end of file
diff --git a/src/InvvardDev.EZLayoutDisplay.Tool.KeyDefinitionProvider/KeyCategory.tt b/src/InvvardDev.EZLayoutDisplay.Tool.KeyDefinitionProvider/KeyCategory.tt
new file mode 100644
index 00000000..68ce5e89
--- /dev/null
+++ b/src/InvvardDev.EZLayoutDisplay.Tool.KeyDefinitionProvider/KeyCategory.tt
@@ -0,0 +1,53 @@
+<#@ template debug="false" hostspecific="true" language="C#" #>
+<#@ assembly name="System.Core" #>
+<#@ assembly name="Newtonsoft.Json" #>
+<#@ import namespace="System.Text" #>
+<#@ import namespace="System.Collections.Generic" #>
+<#@ import namespace="System.IO" #>
+<#@ import namespace="Newtonsoft.Json.Linq" #>
+<#
+ void SaveFile(string folder, string fileName, string content)
+ {
+ using (FileStream fs = new (Path.Combine(folder, fileName), FileMode.Create))
+ using (StreamWriter str = new (fs))
+ {
+ str.WriteLine(content);
+ str.Flush();
+ }
+ }
+
+ string rootPath = Directory.GetParent(Path.GetDirectoryName(this.Host.TemplateFile)).FullName;
+ string inputFileName = "keyCategories.output.json";
+ string inputFilePath = this.Host.ResolvePath($@"{rootPath}\InvvardDev.EZLayoutDisplay.Tool.KeyDefinitionProvider\bin\Debug\net6.0\{inputFileName}");
+ string outputFilename = "KeyCategory.cs";
+ string outputAssemblyPath = @"InvvardDev.EZLayoutDisplay.Desktop\Model\Enum";
+ string outputFilePath = $@"{rootPath}\{outputAssemblyPath}";
+
+ var oryxMetadata = JArray.Parse(File.ReadAllText(inputFilePath));
+#>
+///
+/// <#= outputFilename #> auto generated enumeration
+/// Generated on : <#= DateTime.UtcNow #> (UTC)
+///
+namespace <#= outputAssemblyPath.Replace(@"\", ".") #>
+{
+ public enum KeyCategory
+ {
+<#
+ foreach (var item in oryxMetadata!.Children())
+ {
+ var code = item["code"].ToString();
+ var upperCode = string.Concat(code[0].ToString().ToUpper(), code.Substring(1));
+ var id = item["id"];
+ WriteLine($" {upperCode} = {item["id"]},");
+ }
+#>
+ }
+}
+<#
+ SaveFile(outputFilePath, outputFilename, this.GenerationEnvironment.ToString());
+ this.GenerationEnvironment.Remove(0, this.GenerationEnvironment.Length);
+#>
+///
+/// Moved to .KeyCategory">
+///
\ No newline at end of file
diff --git a/src/InvvardDev.EZLayoutDisplay.Tool.KeyDefinitionProvider/KeyDefinitionProvider.cs b/src/InvvardDev.EZLayoutDisplay.Tool.KeyDefinitionProvider/KeyDefinitionProvider.cs
new file mode 100644
index 00000000..06285abe
--- /dev/null
+++ b/src/InvvardDev.EZLayoutDisplay.Tool.KeyDefinitionProvider/KeyDefinitionProvider.cs
@@ -0,0 +1,78 @@
+using InvvardDev.EZLayoutDisplay.Desktop.Model;
+using InvvardDev.EZLayoutDisplay.Tool.KeyDefinitionProvider.Models;
+using Newtonsoft.Json;
+using System.Text.RegularExpressions;
+
+internal class KeyDefinitionProvider
+{
+ private const string MetadataUrl = "https://oryx.zsa.io/metadata";
+ private const string OryxGlyphUrl = "https://configure.zsa.io/assets/index.d0847e58.css";
+ private const string GlyphPattern = @".icon-(?[a-z_]*):before{content:""\\(?[a-f0-9]{4})""}";
+ private const string KeyDefinitionOutputFilename = "keyDefinitions.output.json";
+ private const string KeyCategoriesOutputFilename = "keyCategories.output.json";
+
+ private OryxMetadataModel? _oryxMetadata;
+
+ internal async Task RunAsync()
+ {
+ await LoadZsaOryxMedadata();
+ await LoadZsaOryxGlyphs();
+ List ezKeys = PrepareEZLayoutKeys();
+ WriteJsonFile(ezKeys, KeyDefinitionOutputFilename);
+ var categories = _oryxMetadata!.Categories
+ .Where(c => !c.IsDeleted)
+ .OrderBy(c => c.CategoryId);
+ WriteJsonFile(categories, KeyCategoriesOutputFilename);
+ }
+
+ private async Task LoadZsaOryxMedadata()
+ {
+ using var client = new HttpClient();
+ var metadata = await client.GetStringAsync(MetadataUrl);
+ _oryxMetadata = JsonConvert.DeserializeObject(metadata);
+
+ // Special Cases
+ _oryxMetadata.Keys.FirstOrDefault(k => k.Code == "MOD_LGUI")!.Label = "Left Windows";
+ _oryxMetadata.Keys.FirstOrDefault(k => k.Code == "MOD_RGUI")!.Label = "Right Windows";
+ _oryxMetadata.Keys.FirstOrDefault(k => k.Code == "KC_LALT")!.Label = "Left Alt";
+ _oryxMetadata.Keys.FirstOrDefault(k => k.Code == "KC_RALT")!.Label = "Right Alt";
+ _oryxMetadata.Keys.FirstOrDefault(k => k.Code == "MOD_LALT")!.Label = "Left Alt";
+ _oryxMetadata.Keys.FirstOrDefault(k => k.Code == "MOD_RALT")!.Label = "Right Alt";
+ _oryxMetadata.Keys.FirstOrDefault(k => k.Code == "KC_F14")!.Label = "F14";
+ _oryxMetadata.Keys.FirstOrDefault(k => k.Code == "KC_F15")!.Label = "F15";
+ _oryxMetadata.Keys.FirstOrDefault(k => k.Code == "KC_LGUI")!.GlyphName = "windows_left";
+ _oryxMetadata.Keys.FirstOrDefault(k => k.Code == "KC_LGUI")!.Label = "Left Windows";
+ _oryxMetadata.Keys.FirstOrDefault(k => k.Code == "KC_RGUI")!.GlyphName = "windows_right";
+ _oryxMetadata.Keys.FirstOrDefault(k => k.Code == "KC_RGUI")!.Label = "Right Windows";
+ }
+
+ private async Task LoadZsaOryxGlyphs()
+ {
+ using var client = new HttpClient();
+ var glyphCss = await client.GetStringAsync(OryxGlyphUrl);
+
+ foreach (Match match in Regex.Matches(glyphCss, GlyphPattern, RegexOptions.IgnoreCase))
+ {
+ var keys = _oryxMetadata!.Keys.Where(k => k.GlyphName == match.Groups["glyphName"].Value);
+ foreach (var key in keys)
+ {
+ key.GlyphCode = @$"\u{match.Groups["glyphCode"].Value}";
+ }
+ }
+ }
+
+ private List PrepareEZLayoutKeys()
+ {
+ var ezKeys = _oryxMetadata!.Keys.Select((k) => (KeyDefinition) k).ToList();
+
+ return ezKeys;
+ }
+
+ private static void WriteJsonFile(object dataToWrite, string outputFilename)
+ {
+ var json = JsonConvert.SerializeObject(dataToWrite);
+ json = json.Replace(@"\\u", @"\u");
+
+ File.WriteAllText(outputFilename, json);
+ }
+}
\ No newline at end of file
diff --git a/src/InvvardDev.EZLayoutDisplay.Tool.KeyDefinitionProvider/Models/OryxCategory.cs b/src/InvvardDev.EZLayoutDisplay.Tool.KeyDefinitionProvider/Models/OryxCategory.cs
new file mode 100644
index 00000000..2f5cfcaa
--- /dev/null
+++ b/src/InvvardDev.EZLayoutDisplay.Tool.KeyDefinitionProvider/Models/OryxCategory.cs
@@ -0,0 +1,19 @@
+using Newtonsoft.Json;
+
+namespace InvvardDev.EZLayoutDisplay.Tool.KeyDefinitionProvider.Models
+{
+ public class OryxCategory
+ {
+ [JsonProperty("id")]
+ public int CategoryId { get; set; }
+
+ [JsonProperty("code")]
+ public string? Code { get; set; }
+
+ [JsonProperty("name")]
+ public string? Name { get; set; }
+
+ [JsonProperty("deleted")]
+ public bool IsDeleted { get; set; }
+ }
+}
diff --git a/src/InvvardDev.EZLayoutDisplay.Tool.KeyDefinitionProvider/Models/OryxKeyDefinition.cs b/src/InvvardDev.EZLayoutDisplay.Tool.KeyDefinitionProvider/Models/OryxKeyDefinition.cs
new file mode 100644
index 00000000..cc4d893a
--- /dev/null
+++ b/src/InvvardDev.EZLayoutDisplay.Tool.KeyDefinitionProvider/Models/OryxKeyDefinition.cs
@@ -0,0 +1,40 @@
+using InvvardDev.EZLayoutDisplay.Desktop.Model;
+using InvvardDev.EZLayoutDisplay.Desktop.Model.Enum;
+using Newtonsoft.Json;
+
+namespace InvvardDev.EZLayoutDisplay.Tool.KeyDefinitionProvider.Models
+{
+ public class OryxKeyDefinition
+ {
+ [JsonProperty("code")]
+ public string? Code { get; set; }
+
+ [JsonProperty("label")]
+ public string? Label { get; set; }
+
+ [JsonProperty("tag")]
+ public string? Tag { get; set; }
+
+ [JsonProperty("glyph")]
+ public string? GlyphName { get; set; }
+
+ [JsonProperty("key_category_id")]
+ public int? Category { get; set; }
+
+ public string? GlyphCode { get; set; }
+
+ public bool IsGlyph => !string.IsNullOrWhiteSpace(GlyphCode);
+
+ public static implicit operator KeyDefinition(OryxKeyDefinition oryxKey)
+ {
+ return new KeyDefinition
+ {
+ KeyCode = oryxKey.Code,
+ Label = !oryxKey.IsGlyph ? oryxKey.Label : oryxKey.GlyphCode,
+ IsGlyph = oryxKey.IsGlyph,
+ Tag = oryxKey.Tag,
+ Category = (KeyCategory)oryxKey.Category!,
+ };
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/InvvardDev.EZLayoutDisplay.Tool.KeyDefinitionProvider/Models/OryxMetadataModel.cs b/src/InvvardDev.EZLayoutDisplay.Tool.KeyDefinitionProvider/Models/OryxMetadataModel.cs
new file mode 100644
index 00000000..7a9611c0
--- /dev/null
+++ b/src/InvvardDev.EZLayoutDisplay.Tool.KeyDefinitionProvider/Models/OryxMetadataModel.cs
@@ -0,0 +1,13 @@
+using Newtonsoft.Json;
+
+namespace InvvardDev.EZLayoutDisplay.Tool.KeyDefinitionProvider.Models
+{
+ public class OryxMetadataModel
+ {
+ [JsonProperty("keys")]
+ public List Keys { get; set; } = new List();
+
+ [JsonProperty("categories")]
+ public List Categories { get; set; } = new List();
+ }
+}
diff --git a/src/InvvardDev.EZLayoutDisplay.Tool.KeyDefinitionProvider/Program.cs b/src/InvvardDev.EZLayoutDisplay.Tool.KeyDefinitionProvider/Program.cs
new file mode 100644
index 00000000..58db55eb
--- /dev/null
+++ b/src/InvvardDev.EZLayoutDisplay.Tool.KeyDefinitionProvider/Program.cs
@@ -0,0 +1 @@
+await new KeyDefinitionProvider().RunAsync();
\ No newline at end of file
diff --git a/src/InvvardDev.EZLayoutDisplay.sln b/src/InvvardDev.EZLayoutDisplay.sln
index 789d0169..d8d50491 100644
--- a/src/InvvardDev.EZLayoutDisplay.sln
+++ b/src/InvvardDev.EZLayoutDisplay.sln
@@ -1,13 +1,13 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 15
-VisualStudioVersion = 15.0.28307.271
+# Visual Studio Version 17
+VisualStudioVersion = 17.0.32014.148
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InvvardDev.EZLayoutDisplay.Desktop", "InvvardDev.EZLayoutDisplay.Desktop\InvvardDev.EZLayoutDisplay.Desktop.csproj", "{F12B94C1-40E4-429C-8EDE-5C410BE81FAF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InvvardDev.EZLayoutDisplay.Tests", "InvvardDev.EZLayoutDisplay.Tests\InvvardDev.EZLayoutDisplay.Tests.csproj", "{82704A9A-B010-4A00-8CF4-00D33F4E23DF}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InvvardDev.EZLayoutDisplay.Console", "InvvardDev.EZLayoutDisplay.Console\InvvardDev.EZLayoutDisplay.Console.csproj", "{CC579192-C568-42B4-969C-445D5F0D79E1}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InvvardDev.EZLayoutDisplay.Tool.KeyDefinitionProvider", "InvvardDev.EZLayoutDisplay.Tool.KeyDefinitionProvider\InvvardDev.EZLayoutDisplay.Tool.KeyDefinitionProvider.csproj", "{48997597-4E97-4FC9-B22B-00A64CFCE56C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -23,10 +23,10 @@ Global
{82704A9A-B010-4A00-8CF4-00D33F4E23DF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{82704A9A-B010-4A00-8CF4-00D33F4E23DF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{82704A9A-B010-4A00-8CF4-00D33F4E23DF}.Release|Any CPU.Build.0 = Release|Any CPU
- {CC579192-C568-42B4-969C-445D5F0D79E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {CC579192-C568-42B4-969C-445D5F0D79E1}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {CC579192-C568-42B4-969C-445D5F0D79E1}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {CC579192-C568-42B4-969C-445D5F0D79E1}.Release|Any CPU.Build.0 = Release|Any CPU
+ {48997597-4E97-4FC9-B22B-00A64CFCE56C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {48997597-4E97-4FC9-B22B-00A64CFCE56C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {48997597-4E97-4FC9-B22B-00A64CFCE56C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {48997597-4E97-4FC9-B22B-00A64CFCE56C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE