private void AddMappingEditorControl(MidiMappingRecord record) { var newEditor = new OptionPageMappingEditor(); newEditor.Dock = DockStyle.Top; newEditor.MidiInputLearnRequested += mappingEditor_MidiInputLearnRequested; newEditor.DeleteRequested += mappingEditor_DeleteRequested; newEditor.SetMappingRecord(record); pnlMappingListItems.Controls.Add(newEditor); pnlMappingListItems.Controls.SetChildIndex(newEditor, 0); }
private void mappingEditor_MidiInputLearnRequested(object sender, EventArgs e) { chkTestMidiInputDevice.Checked = false; if (midiInputLearnTargetControl != null && midiInputLearnTargetControl != sender) { midiInputLearnTargetControl.TeachMidiInput(null); } midiInputLearnTargetControl = (OptionPageMappingEditor)sender; // Hold on for a short time and allow other notes from this chord to be received. Interlocked.CompareExchange(ref eventBuffer, new MidiEventBuffer(), null); StartReceivingMidi(); }
private void WaitAndFinalizeChord() { // Allow to store other chord notes in the buffer. Thread.Sleep(chordWaitTime); StopReceivingMidi(); // Process collected events. var bufferedEvents = eventBuffer.Flush(); var inputTrigger = new MidiInputTrigger(bufferedEvents.Select(e => e.Pitch).OrderBy(p => p).ToArray()); // Reset the buffer to return to normal mode. Interlocked.CompareExchange(ref eventBuffer, null, eventBuffer); var oldTargetControl = midiInputLearnTargetControl; midiInputLearnTargetControl = null; Invoke(new Action(() => oldTargetControl.TeachMidiInput(inputTrigger))); }
private void RemoveMappingEditorControl(OptionPageMappingEditor control) { pnlMappingListItems.Controls.Remove(control); control.Dispose(); }