private void KeyboardRemap_OnLoaded(object sender, RoutedEventArgs e) { try { _mGlobalHook = Hook.GlobalEvents(); _mGlobalHook.KeyDown += GlobalHookKeyDown; if (!File.Exists("KeyboardMap.xml")) { return; } var kbMap = KeyboardHelper.DeSerialize(); SetTextBoxText(kbMap.P1B1, TxtP1B1); SetTextBoxText(kbMap.P1B2, TxtP1B2); SetTextBoxText(kbMap.P1B3, TxtP1B3); SetTextBoxText(kbMap.P1B4, TxtP1B4); SetTextBoxText(kbMap.P1B5, TxtP1B5); SetTextBoxText(kbMap.P1B6, TxtP1B6); SetTextBoxText(kbMap.P2B1, TxtP2B1); SetTextBoxText(kbMap.P2B2, TxtP2B2); SetTextBoxText(kbMap.P2B3, TxtP2B3); SetTextBoxText(kbMap.P2B4, TxtP2B4); SetTextBoxText(kbMap.P2B5, TxtP2B5); SetTextBoxText(kbMap.P2B6, TxtP2B6); SetTextBoxText(kbMap.P1Up, TxtP1Up); SetTextBoxText(kbMap.P1Down, TxtP1Down); SetTextBoxText(kbMap.P1Left, TxtP1Left); SetTextBoxText(kbMap.P1Right, TxtP1Right); SetTextBoxText(kbMap.P1Start, TxtP1Start); SetTextBoxText(kbMap.P2Up, TxtP2Up); SetTextBoxText(kbMap.P2Down, TxtP2Down); SetTextBoxText(kbMap.P2Left, TxtP2Left); SetTextBoxText(kbMap.P2Right, TxtP2Right); SetTextBoxText(kbMap.P2Start, TxtP2Start); SetTextBoxText(kbMap.P1Service, TxtP1Service); SetTextBoxText(kbMap.P2Service, TxtP2Service); SetTextBoxText(kbMap.TestSw, TxtTestSw); } catch (Exception exception) { MessageBox.Show($"Error while loading: {exception}", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }