コード例 #1
0
 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);
 }
コード例 #2
0
        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);
        }
コード例 #3
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();
        }
コード例 #4
0
        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)));
        }
コード例 #5
0
        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)));
        }
コード例 #6
0
 private void RemoveMappingEditorControl(OptionPageMappingEditor control)
 {
     pnlMappingListItems.Controls.Remove(control);
     control.Dispose();
 }
コード例 #7
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();
        }
コード例 #8
0
 private void RemoveMappingEditorControl(OptionPageMappingEditor control)
 {
     pnlMappingListItems.Controls.Remove(control);
     control.Dispose();
 }