コード例 #1
0
        private void StartStop_Click(object sender, EventArgs e)
        {
            try
            {
                if (_mapper != null)
                {
                    // stop mapper;
                    _mapper.Stop();
                    _mapper.Dispose();
                    _mapper = null;

                    StartStop.Text = "Start";
                }
                else
                {
                    if (MidiInList.SelectedIndex == -1 ||
                        MidiOutList.SelectedIndex == -1)
                    {
                        MessageBox.Show(this, Properties.Resources.Midi_NoInOrOutPortSelected, Text,
                                        MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }

                    // start mapper;
                    _mapper = new MidiNoteMapper();

                    if (ListenChannel.SelectedIndex > 0)
                    {
                        _mapper.InChannel = Byte.Parse(ListenChannel.Text);
                    }

                    if (SendChannel.SelectedIndex > 0)
                    {
                        _mapper.OutChannel = Byte.Parse(SendChannel.Text);
                    }

                    _mapper.VelocityOffset = (byte)VelocityOffsetCtrl.Value;
                    _mapper.MidiThru       = MidiThruChk.Checked;

                    _mapper.Start(MidiInList.SelectedIndex, MidiOutList.SelectedIndex,
                                  NoteMapView.MidiNoteMap.CompileIndex());

                    StartStop.Text = "Stop";
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.ToString(), Text,
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #2
0
        private void StartStop_Click(object sender, EventArgs e)
        {
            try
            {
                if (_mapper != null)
                {
                    // stop mapper
                    _mapper.Stop();
                    _mapper.Dispose();
                    _mapper = null;

                    StartStop.Text = "Start";
                }
                else
                {
                    if (MidiInList.SelectedIndex == -1 ||
                        MidiOutList.SelectedIndex == -1)
                    {
                        MessageBox.Show(this, "You must select a midi in and an out port. If the list is empty your system has no Midi installed.", Text,
                                        MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }

                    // start mapper
                    _mapper = new MidiNoteMapper();

                    if (ListenChannel.SelectedIndex > 0)
                    {
                        _mapper.InChannel = Byte.Parse(ListenChannel.Text);
                    }

                    if (SendChannel.SelectedIndex > 0)
                    {
                        _mapper.OutChannel = Byte.Parse(SendChannel.Text);
                    }

                    _mapper.VelocityOffset = (byte)VelocityOffsetCtrl.Value;
                    _mapper.MidiThru       = MidiThruChk.Checked;

                    _mapper.Start(MidiInList.SelectedIndex, MidiOutList.SelectedIndex,
                                  NoteMapView.MidiNoteMap.CompileIndex());

                    StartStop.Text = "Stop";
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.ToString(), Text,
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }