/// <summary> /// Change the active input MIDI device /// </summary> /// <param name="sender">Element that fired the event</param> /// <param name="e">Event arguments</param> private void inputDevices_SelectionChanged(object sender, SelectionChangedEventArgs e) { // Get the selected input MIDI device int selectedInputDeviceIndex = inputDevices.SelectedIndex; // Try to display the appropriate device properties if (selectedInputDeviceIndex < 0) { // Clear input device properties InputDeviceProperties.Clear(); InputDeviceProperties.Add("Select a MIDI input device to view its properties"); inputDeviceProperties.IsEnabled = false; NotifyUser("Select a MIDI input device to view its properties"); return; } DeviceInformationCollection devInfoCollection = _midiInDeviceWatcher.GetDeviceInformationCollection(); if (devInfoCollection == null) { InputDeviceProperties.Clear(); InputDeviceProperties.Add("Device not found!"); inputDeviceProperties.IsEnabled = false; NotifyUser("Device not found!"); return; } DeviceInformation devInfo = devInfoCollection[selectedInputDeviceIndex]; if (devInfo == null) { InputDeviceProperties.Clear(); InputDeviceProperties.Add("Device not found!"); inputDeviceProperties.IsEnabled = false; NotifyUser("Device not found!"); return; } // Display the found properties DisplayDeviceProperties(devInfo, inputDeviceProperties, InputDeviceProperties); NotifyUser("Device information found!"); }
/// <summary> /// Clear all input and output MIDI device lists and properties /// </summary> private void ClearAllDeviceValues() { // Clear input devices InputDevices.Clear(); InputDevices.Add("Click button to list input MIDI devices"); inputDevices.IsEnabled = false; // Clear output devices OutputDevices.Clear(); OutputDevices.Add("Click button to list output MIDI devices"); outputDevices.IsEnabled = false; // Clear input device properties InputDeviceProperties.Clear(); InputDeviceProperties.Add("Select a MIDI input device to view its properties"); inputDeviceProperties.IsEnabled = false; // Clear output device properties OutputDeviceProperties.Clear(); OutputDeviceProperties.Add("Select a MIDI output device to view its properties"); outputDeviceProperties.IsEnabled = false; }