private void comboBoxMidiOutSelect_SelectedIndexChanged(object sender, EventArgs e) { if (Device != null) { Trace.WriteLine("Opening MIDI-OUT: " + comboBoxMidiOutSelect.Items[comboBoxMidiOutSelect.SelectedIndex]); Device.OpenOut(comboBoxMidiOutSelect.SelectedIndex); try { Config.lastSelectedMidiOut = MidiOut.GetDeviceNames()[comboBoxMidiOutSelect.SelectedIndex]; } catch { } } }
public void SetDevice(XGMidiIODevice device) { Debug.Assert(this.Device == null); this.Device = device; comboBoxMidiInSelect.Items.AddRange(MidiIn.GetDeviceNames()); comboBoxMidiOutSelect.Items.AddRange(MidiOut.GetDeviceNames()); int inIndex = Array.IndexOf(MidiIn.GetDeviceNames(), Config.lastSelectedMidiIn); if (inIndex < 0) { inIndex = 0; } if (comboBoxMidiInSelect.Items.Count > 0) { comboBoxMidiInSelect.SelectedIndex = inIndex; } int outIndex = Array.IndexOf(MidiOut.GetDeviceNames(), Config.lastSelectedMidiOut); if (outIndex < 0) { outIndex = 0; } if (comboBoxMidiOutSelect.Items.Count > 0) { comboBoxMidiOutSelect.SelectedIndex = outIndex; } pictureBox1.Height = pictureBox1.Width; timer1.Interval = 10; timer1.Tick += Timer1_Tick; timer1.Enabled = true; CreateXGPControls(); }