Allow configuration of XBE-24 keyboard layout
Test / Run tests (push) Successful in 37s

This commit is contained in:
2026-10-14 16:38:23 +02:00
parent 4b9bcc6ad3
commit c005378368
7 changed files with 263 additions and 110 deletions
+19
View File
@@ -12,8 +12,11 @@ namespace PamhagenSysCtrl.Helpers {
public string? UpdateUrl;
public bool UpdateAuto;
public PamhagenPlant.ShortcutKey?[] Xbe24KeyMap;
public Config(string filename) {
FileName = filename;
Xbe24KeyMap = new PamhagenPlant.ShortcutKey?[24];
Read();
}
@@ -23,10 +26,26 @@ namespace PamhagenSysCtrl.Helpers {
PlcPort = config["plc:port"] ?? "COM1";
UpdateUrl = config["update:url"];
UpdateAuto = TrueValues.Contains(config["update:auto"]?.ToLower());
var xbe24 = config.GetSection("xbe24");
for (char c = 'a'; c <= 'd'; c++) {
for (int r = 1; r <= 6; r++) {
int n = (c - 'a') * 6 + r - 1;
var s = xbe24[$"{c}{r}"]?.ToUpper();
Xbe24KeyMap[n] = s == null ? null : Enum.Parse<PamhagenPlant.ShortcutKey>(s);
}
}
} catch (Exception exc) {
MessageBox.Show($"Die Konfigurationsdatei konnte nicht gelesen werden:\n\n{exc.Message}", "Konfigurationsdatei lesen", MessageBoxButton.OK, MessageBoxImage.Error);
Application.Current.Shutdown();
}
}
public PamhagenPlant.ShortcutKey? MapKey(int n) {
return n < 0 || Xbe24KeyMap.Length < n ? null : Xbe24KeyMap[n];
}
public int? MapKey(PamhagenPlant.ShortcutKey key) {
return Xbe24KeyMap.IndexOf(key) is int n ? n == -1 ? null : n : null;
}
}
}