This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user