private void SaveButton_Click(object sender, RoutedEventArgs e) { ApplicationSettings.CallbackDeviceID = ((KeyValuePair <int, string>)cbAudioDevices.SelectedItem).Value; if (((KeyValuePair <int, string>)cbMidiInDevice.SelectedItem).Key == -1) { ApplicationSettings.MidiInputDeviceID = null; } else { ApplicationSettings.MidiInputDeviceID = ((KeyValuePair <int, string>)cbMidiInDevice.SelectedItem).Value; } if (((KeyValuePair <int, string>)cbMidiOutDevice.SelectedItem).Key == -1) { ApplicationSettings.MidiOutputDeviceID = null; } else { ApplicationSettings.MidiOutputDeviceID = ((KeyValuePair <int, string>)cbMidiOutDevice.SelectedItem).Value; } if (((KeyValuePair <int, string>)cbMidiOutRepeaterDevice.SelectedItem).Key == -1) { ApplicationSettings.MidiOutputRepeatedDeviceID = null; } else { ApplicationSettings.MidiOutputRepeatedDeviceID = ((KeyValuePair <int, string>)cbMidiOutRepeaterDevice.SelectedItem).Value; } ApplicationSettings.SaveConfig(); //Reload Midi Devices GlobalStaticContext.DetachAllMidiDevices(); if (((KeyValuePair <int, string>)cbMidiInDevice.SelectedItem).Key != -1) { GlobalStaticContext.AttachMidiInDevice(((KeyValuePair <int, string>)cbMidiInDevice.SelectedItem).Key); } if (((KeyValuePair <int, string>)cbMidiOutDevice.SelectedItem).Key != -1) { GlobalStaticContext.AttachMidiOutDevice(((KeyValuePair <int, string>)cbMidiOutDevice.SelectedItem).Key); } if (((KeyValuePair <int, string>)cbMidiOutRepeaterDevice.SelectedItem).Key != -1) { GlobalStaticContext.AttachMidiRepeatDevice(((KeyValuePair <int, string>)cbMidiOutRepeaterDevice.SelectedItem).Key); } this.Close(); }
private void Application_Exit(object sender, ExitEventArgs e) { ApplicationSettings.SaveConfig(); GlobalStaticContext.DetachAllMidiDevices(); }