Esempio n. 1
0
        public BmpMidiEntry AddPlaylistEntry(string filename, int track = 0)
        {
            BmpMidiEntry entry = new BmpMidiEntry(filename, track);

            int entryIndex = 0;

            if (PlaylistView.SelectedRows.Count == 1)
            {
                DataGridViewRow row = PlaylistView.SelectedRows[0];
                row.Selected = false;

                entryIndex = row.Index + 1;
                playlistEntries.Insert(entryIndex, entry);
            }
            else
            {
                playlistEntries.Add(entry);
                entryIndex = playlistEntries.Count - 1;
            }

            if (entryIndex < PlaylistView.Rows.Count)
            {
                PlaylistView.Rows[entryIndex].Selected = true;
            }

            playlistBinding         = new BindingList <BmpMidiEntry>(playlistEntries);
            PlaylistView.DataSource = playlistBinding;
            return(entry);
        }
Esempio n. 2
0
        public BmpMidiEntry AddPlaylistEntry(string filename, int track = 0, int dropIndex = -1)
        {
            BmpMidiEntry entry = new BmpMidiEntry(filename, track);

            int entryIndex = 0;

            if (dropIndex >= 0)
            {
                entryIndex = dropIndex;
                playlistEntries.Insert(entryIndex, entry);
            }
            else if (PlaylistView.SelectedRows.Count == 1)
            {
                DataGridViewRow row = PlaylistView.SelectedRows[0];
                row.Selected = false;

                entryIndex = row.Index + 1;
                playlistEntries.Insert(entryIndex, entry);
            }
            else
            {
                playlistEntries.Add(entry);
                entryIndex = playlistEntries.Count - 1;
            }

            playlistBinding         = new BindingList <BmpMidiEntry>(playlistEntries);
            PlaylistView.DataSource = playlistBinding;

            // select the newly added track here
            Select(entryIndex);
            SaveSettings();

            return(entry);
        }
Esempio n. 3
0
        // Helpers

        private bool GetSelectedMidiEntry(out BmpMidiEntry entry)
        {
            if (PlaylistView.SelectedRows.Count == 1)
            {
                entry = PlaylistView.SelectedRows[0].DataBoundItem as BmpMidiEntry;
                return(true);
            }
            entry = new BmpMidiEntry();
            return(false);
        }
Esempio n. 4
0
 private void BmpMidiEntryList_MouseMove(object sender, MouseEventArgs e)
 {
     if ((e.Button & MouseButtons.Left) == MouseButtons.Left)
     {
         if (dragBox != Rectangle.Empty && !dragBox.Contains(e.X, e.Y))
         {
             BmpMidiEntry    data       = PlaylistView.Rows[rowIndex].DataBoundItem as BmpMidiEntry;
             DragDropEffects dropEffect = this.DoDragDrop(data, DragDropEffects.Move);
         }
     }
 }
Esempio n. 5
0
 private void Playlist_OnMidiSelect(object o, BmpMidiEntry entry)
 {
     if (Explorer.SelectFile(entry.FilePath.FilePath))
     {
         Explorer.Invoke(t => t.SelectTrack(entry.Track.Track));
         Explorer.EnterFile();
     }
     Playlist.Select(entry.FilePath.FilePath);
     if (proceedPlaylistMidi && Playlist.AutoPlay)
     {
         Player.Player.Play();
         proceedPlaylistMidi = false;
     }
 }
Esempio n. 6
0
        private void BmpMidiEntryList_DragDrop(object sender, DragEventArgs e)
        {
            Point clientPoint = this.PointToClient(new Point(e.X, e.Y));

            DataGridView.HitTestInfo hit = PlaylistView.HitTest(clientPoint.X, clientPoint.Y);

            // for internal drag-and-drop
            if (actuallyMoving)
            {
                int targetRowIndex = hit.RowIndex - 1;
                if (hit.Type == DataGridViewHitTestType.None)
                {
                    // user has dnd onto empty space, simply move midi to the end of the playlist
                    targetRowIndex = PlaylistView.RowCount - 1;
                }

                BmpMidiEntry oldData = PlaylistView.Rows[initialRowIndexForMovement].DataBoundItem as BmpMidiEntry;
                RemovePlaylistEntry(initialRowIndexForMovement);
                AddPlaylistEntry(oldData.FilePath.FilePath, oldData.Track.Track, targetRowIndex);
                actuallyMoving = false;

                return;
            }

            int dropIndex = 0;

            if (hit.Type == DataGridViewHitTestType.Cell)
            {
                // user has dnd onto an existing cell, move above the hovered midi
                dropIndex = hit.RowIndex - 1;
            }
            else if (hit.Type == DataGridViewHitTestType.None)
            {
                // user has dnd onto empty space, simply add midi to the end of the playlist
                dropIndex = playlistEntries.Count;
            }

            if (e.Effect == DragDropEffects.Move)
            {
                // just in case the user gets fancy with it and dnd's multiple midis
                string[] midiList = (string[])e.Data.GetData(DataFormats.FileDrop, false);
                foreach (string midiFilePath in midiList)
                {
                    string filename = Path.GetFileName(midiFilePath);
                    BmpPlaylistRequestAddEvent addEvent = new BmpPlaylistRequestAddEvent(filename, 0, dropIndex);
                    OnPlaylistManualRequestAdd?.Invoke(this, addEvent);
                }
            }
        }
Esempio n. 7
0
 public void Select(string filePath)
 {
     for (int i = 0; i < PlaylistView.Rows.Count; i++)
     {
         BmpMidiEntry entry = PlaylistView.Rows[i].DataBoundItem as BmpMidiEntry;
         if (entry != null)
         {
             if (entry.FilePath.FilePath == filePath)
             {
                 this.Select(i);
                 return;
             }
         }
     }
 }
Esempio n. 8
0
        private void SongBrowser_EnterFile(object sender, BmpMidiEntry file)
        {
            if (initState)
            {
                selectFlashingTimer.Stop();
                SelectorSong.BackColor = Color.White;
                SelectorSong.Text      = string.Empty;
            }

            BmpMidiEntry entry = new BmpMidiEntry(file.FilePath.FilePath, decimal.ToInt32(SelectorTrack.Value));

            OnBrowserSelect?.Invoke(this, entry);

            SelectorTrack.Focus();
        }
Esempio n. 9
0
        // Use invoke on gui changing properties
        private void Browser_OnMidiSelect(object o, BmpMidiEntry entry)
        {
            bool error = false;
            bool diff  = (entry.FilePath.FilePath != Player.Player.LoadedFilename);

            try {
                Player.LoadFile(entry.FilePath.FilePath, entry.Track.Track);
                Player.Player.Stop();
            } catch (Exception e) {
                this.LogMidi(string.Format("[{0}] cannot be loaded:", entry.FilePath.FilePath));
                this.LogMidi(e.Message);
                Console.WriteLine(e.StackTrace);
                error = true;
            }
            if (!error)
            {
                if (diff && Properties.Settings.Default.Verbose)
                {
                    this.LogMidi(string.Format("[{0}] loaded.", entry.FilePath.FilePath));
                }
                Properties.Settings.Default.LastLoaded = entry.FilePath.FilePath;
                Properties.Settings.Default.Save();
            }
            Playlist.Deselect();

            this.SuspendLayout();
            Explorer.SetTrackName(entry.FilePath.FilePath);
            Explorer.SetTrackNums(Player.Player.CurrentTrack, Player.Player.MaxTrack);
            this.ResumeLayout(true);

            Explorer.SongBrowserVisible = false;

            Statistics.SetBpmCount(Player.Tempo);
            Statistics.SetTotalTrackCount(Player.Player.MaxTrack);
            Statistics.SetTotalNoteCount(Player.TotalNoteCount);
            Statistics.SetTrackNoteCount(Player.CurrentNoteCount);

            if (LocalOrchestra.OrchestraEnabled)
            {
                LocalOrchestra.Sequencer = Player.Player;
            }
        }
Esempio n. 10
0
        private void BmpMidiEntryList_CellMouseMove(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                // if we don't yet have an initial row index
                if (!actuallyMoving)
                {
                    // and we've moved the cursor with the button held down for
                    // a decently sufficient time, i.e. 10 pixels. seems good.
                    if (Math.Abs(mouseYCoordForMovement - e.Y) >= 10)
                    {
                        actuallyMoving = true;

                        Console.WriteLine("initialRow detected as {0}", initialRowIndexForMovement);

                        BmpMidiEntry data = PlaylistView.Rows[initialRowIndexForMovement].DataBoundItem as BmpMidiEntry;
                        this.DoDragDrop(data, DragDropEffects.Move);
                    }
                }
            }
        }