예제 #1
0
        private void UpdatePlaylist()
        {
            try
            {
                for (int i = 0; i < Playlist.Count; i++)
                {
                    var skipChapters = new List <int>();
                    int endChapter   = -1;

                    var skipChapterCell = dgv_PlayList.Rows[i].Cells[skipCellIndex];
                    var endChapterCell  = dgv_PlayList.Rows[i].Cells[endCellIndex];

                    if (skipChapterCell.Value != null && skipChapterCell.Value.ToString() != "")
                    {
                        skipChapters = skipChapterCell.Value.ToString().Split(',').Select(int.Parse).ToList();
                        Playlist.ElementAt(i).HasChapter = true;
                    }

                    if (endChapterCell.Value != null && endChapterCell.Value.ToString() != "")
                    {
                        endChapter = int.Parse(endChapterCell.Value.ToString());
                    }

                    Playlist.ElementAt(i).SkipChapters = skipChapters;
                    Playlist.ElementAt(i).EndChapter   = endChapter;
                }
            }
            catch (Exception ex)
            {
                PlayerControl.HandleException(ex);
            }
        }
예제 #2
0
        void dgv_PlayList_DragDrop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                var files = (string[])e.Data.GetData(DataFormats.FileDrop);
                if (files.Length == 1)
                {
                    var filename = files[0];

                    if (Directory.Exists(filename))
                    {
                        var media = playListUi.GetMediaFiles(filename);
                        AddFiles(media.ToArray());
                        return;
                    }
                    else if (PlayerExtensions.Playlist.Playlist.IsPlaylistFile(filename))
                    {
                        OpenPlaylist(filename);
                        return;
                    }
                }

                var actualFiles = files.Where(file => !Directory.Exists(file)).Where(file => openFileDialog.Filter.Contains(Path.GetExtension(file)));
                AddFiles(actualFiles.ToArray());
                dgv_PlayList.CurrentCell = dgv_PlayList.Rows[dgv_PlayList.Rows.Count - 1].Cells[titleCellIndex];
                SetPlayStyling();
            }
            else if (e.Data.GetDataPresent(typeof(DataGridViewRow)))
            {
                var clientPoint    = dgv_PlayList.PointToClient(new Point(e.X, e.Y));
                int destinationRow = dgv_PlayList.HitTest(clientPoint.X, clientPoint.Y).RowIndex;

                if (destinationRow == -1 || destinationRow >= Playlist.Count)
                {
                    return;
                }
                var playItem = Playlist.ElementAt(dragRowIndex);
                Playlist.RemoveAt(dragRowIndex);
                NotifyPlaylistChanged();
                Playlist.Insert(destinationRow, playItem);
                PopulatePlaylist();
                dgv_PlayList.CurrentCell = dgv_PlayList.Rows[destinationRow].Cells[titleCellIndex];
            }
        }