private void lstKeys_SelectedIndexChanged(object sender, EventArgs e) { if (lstKeys.SelectedIndex == -1) { return; } kpMapping = Newtonsoft.Json.JsonConvert.DeserializeObject <KeypadMapping>(System.IO.File.ReadAllText(lstKeys.SelectedItem.ToString())); }
public Form1() { InitializeComponent(); mapping = Newtonsoft.Json.JsonConvert.DeserializeObject <GamepadMapping>(System.IO.File.ReadAllText("./Gamepads/Speedlink.json")); kpMapping = Newtonsoft.Json.JsonConvert.DeserializeObject <KeypadMapping>(System.IO.File.ReadAllText("./Layouts/WingCommander4.json")); var pads = System.IO.Directory.EnumerateFiles(@".\Gamepads", "*.json"); var mappings = System.IO.Directory.EnumerateFiles(@".\Layouts", "*.json"); foreach (var k in mappings) { this.lstKeys.Items.Add(k); } foreach (var p in pads) { this.lstPads.Items.Add(p); } }