Exemple #1
0
        void PlaySong(int index)
        {
            ListBoxSequence lbs = (ListBoxSequence)lbSequences.Items[index];

            this.BeginInvoke(new MethodInvoker(delegate(){ lblStatus.Text = "Playing " + lbs.ToString(); }));

            switch (lbs.Sequence.Version)
            {
            case 1:
                this._player = new SequencePlayerV1(lbs.Sequence);
                this._player.SequenceStopped += new EventHandler(_sp_SequenceStopped);
                this._player.Start();
                break;

            case 2:
                this._player = new SequencePlayerV2(lbs.Sequence);
                this._player.SequenceStopped += new EventHandler(_sp_SequenceStopped);
                this._player.Start();
                break;
            }
        }
Exemple #2
0
        private void CreateSequence()
        {
            // clear out the current grids
            dgvHeader.Rows.Clear();
            dgvHeader.Columns.Clear();
            dgvMain.Rows.Clear();
            dgvMain.Columns.Clear();

            // make our grids invisible while drawing to speed it up
            dgvMain.Visible   = false;
            dgvHeader.Visible = false;

            // columns per second = 1 second / length of time for each square
            _colsPerSec = 1000 / (int)_sequence.Interval;

            // draw the grid
            switch (_sequence.Version)
            {
            case 1:
            case 2:
                // for the length of the music track
                for (int sec = 0; sec < _sequence.MusicLength; sec++)
                {
                    // for each second in the time specified, create a column in the header
                    string header = "{0:0#}:{1:0#}.00";
                    dgvHeader.Columns.Add(sec.ToString(), String.Format(header, sec / 60, sec % 60));
                    dgvHeader.Columns[sec].FillWeight = 0.0001f;                                // this value must be < 65535 for the entire grid (?)
                    // set the width to an appropriate size for display
                    dgvHeader.Columns[sec].Width = _colsPerSec * COL_WIDTH;

                    // now draw the squares contained within each second
                    for (int partSec = 0; partSec < _colsPerSec; partSec++)
                    {
                        // no name, FillWeight requirement, set the appropriate width
                        dgvMain.Columns.Add("", "");
                        dgvMain.Columns[(sec * _colsPerSec) + partSec].FillWeight = 0.0001f;
                        dgvMain.Columns[(sec * _colsPerSec) + partSec].Width      = COL_WIDTH;
                    }
                }
                break;

            default:
                throw new Exception("Unknown sequence version!");
            }

            // add the row headers (Ch. 1, Ch. 2, etc.)
            for (int channel = 0; channel < _sequence.Channels.Count; channel++)
            {
                // create the row and text
                DataGridViewRow dvr = new DataGridViewRow();
                dvr.HeaderCell.Value = "Ch. " + (channel + 1);

                // store away the actual Channel object for later use
                dvr.Tag = _sequence.Channels[channel];

                // add the row
                dgvMain.Rows.Add(dvr);
            }

            // set the width of those row headers
            dgvMain.RowHeadersWidth   = 100;
            dgvHeader.RowHeadersWidth = 100;

            // turn the grids back on
            dgvMain.Visible   = true;
            dgvHeader.Visible = true;

            // load up the sequence player
            if (_sequencePlayer != null)
            {
                _sequencePlayer.Unload();
            }

            switch (_sequence.Version)
            {
            case 1:
                _sequencePlayer = new SequencePlayerV1(_sequence);
                break;

            case 2:
                _sequencePlayer = new SequencePlayerV2(_sequence);
                break;

            default:
                throw new ApplicationException("Unknown sequence version!");
            }

            // setup an event handler for when the sequence has ended
            _sequencePlayer.SequenceStopped += new EventHandler(_sequencePlayer_SequenceStopped);

            // turn on the appropriate menus
            EnableMenus(true);
        }