// Click to either create new config for current app or remove the existing config. private void Button_AppBinding_Click(object sender, RoutedEventArgs e) { var tag = (sender as Button).Tag; switch (tag) { case null: // This should never happen as the button cannot be pressed while disabled. break; case true: var result = MessageBox.Show( Application.Current.MainWindow, "Are you sure you want to delete this configuration?", "OpenVR2Key", MessageBoxButton.YesNo, MessageBoxImage.Warning ); if (result == MessageBoxResult.Yes) { MainModel.ClearBindings(); MainModel.DeleteConfig(); _controller.LoadConfig(true); // Loads default UpdateConfigButton(false); } break; case false: MainModel.SetConfigName(_currentlyRunningAppId); MainModel.StoreConfig(new Dictionary <string, Key[]>()); _controller.LoadConfig(); // Loads the empty new one UpdateConfigButton(true); break; } }
// Load config, if it exists public void LoadConfig(bool forceDefault = false) { var configName = forceDefault ? MainModel.CONFIG_DEFAULT : _currentApplicationId; var config = MainModel.RetrieveConfig(configName); if (config != null) { MainModel.SetConfigName(configName); } Debug.WriteLine($"Config for {configName} found: {config != null}"); ConfigRetrievedAction.Invoke(config, _currentApplicationId == MainModel.CONFIG_DEFAULT); }