Ejemplo n.º 1
0
        /// <summary>
        /// Detect the toggle state of the Devicewatcher button.
        /// If auto-detect is on, disable manual enumeration buttons and start device watchers
        /// If auto-detect is off, enable manual enumeration buttons and stop device watchers
        /// </summary>
        /// <param name="sender">Element that fired the event</param>
        /// <param name="e">Event arguments</param>
        private void DeviceAutoDetectToggle_Toggled(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            if (deviceAutoDetectToggle.IsOn)
            {
                listInputDevicesButton.IsEnabled  = false;
                listOutputDevicesButton.IsEnabled = false;

                if (_midiInDeviceWatcher != null)
                {
                    _midiInDeviceWatcher.Start();
                }
                if (_midiOutDeviceWatcher != null)
                {
                    _midiOutDeviceWatcher.Start();
                }
            }
            else
            {
                listInputDevicesButton.IsEnabled  = true;
                listOutputDevicesButton.IsEnabled = true;

                if (_midiInDeviceWatcher != null)
                {
                    _midiInDeviceWatcher.Stop();
                }
                if (_midiOutDeviceWatcher != null)
                {
                    _midiOutDeviceWatcher.Stop();
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Constructor: Empty device lists, start the device watchers and
        /// set initial states for buttons
        /// </summary>
        public MidiDeviceEnumerationTests()
        {
            InitializeComponent();

            rootGrid.DataContext = this;

            // Start with a clean slate
            ClearAllDeviceValues();

            // Ensure Auto-detect devices toggle is on
            deviceAutoDetectToggle.IsOn = true;

            // Set up the MIDI input and output device watchers
            _midiInDeviceWatcher  = new MidiDeviceWatcher(MidiInPort.GetDeviceSelector(), Dispatcher, inputDevices, InputDevices);
            _midiOutDeviceWatcher = new MidiDeviceWatcher(MidiOutPort.GetDeviceSelector(), Dispatcher, outputDevices, OutputDevices);

            // Start watching for devices
            _midiInDeviceWatcher.Start();
            _midiOutDeviceWatcher.Start();

            // Disable manual enumeration buttons
            listInputDevicesButton.IsEnabled  = false;
            listOutputDevicesButton.IsEnabled = false;

            Unloaded += MidiDeviceEnumerationTests_Unloaded;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Constructor: Start the device watcher and populate MIDI message types
        /// </summary>
        public MidiDeviceOutputTests()
        {
            InitializeComponent();

            rootGrid.DataContext = this;

            // Initialize the list of active MIDI output devices
            _midiOutPorts = new List <IMidiOutPort>();

            // Set up the MIDI output device watcher
            _midiOutDeviceWatcher = new MidiDeviceWatcher(MidiOutPort.GetDeviceSelector(), Dispatcher, outputDevices, OutputDevices);

            // Start watching for devices
            _midiOutDeviceWatcher.Start();

            // Populate message types into list
            PopulateMessageTypes();

            Unloaded += MidiDeviceOutputTests_Unloaded;
        }