Exemplo n.º 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);
            }
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 3
0
        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            try
            {
                if (_mapper != null)
                {
                    _mapper.Stop();
                    _mapper.Dispose();
                    _mapper = null;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.ToString(), Text,
                                MessageBoxButtons.OK, MessageBoxIcon.Error);

                e.Cancel = true;

                return;
            }

            DialogResult result = DialogResult.No;

            if (Program.Document != null &&
                Program.Document.IsDirty)
            {
                result = MessageBox.Show(this, "Do you want to save your map?", Text,
                                         MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation);

                if (result == DialogResult.Yes)
                {
                    SaveDocument(false);
                }
            }

            e.Cancel = (result == DialogResult.Cancel);
        }