예제 #1
0
        public ListViewItem ToItem(DataSet1.PlaylistRow row)
        {
            ListViewGroup in_group   = null;
            string        group_name = (row.artist ?? "") + " - " + (row.album ?? "");

            foreach (ListViewGroup group in listViewTracks.Groups)
            {
                if (group.Name == group_name)
                {
                    in_group = group;
                    break;
                }
            }
            if (in_group == null)
            {
                in_group = new ListViewGroup(group_name, group_name);
                listViewTracks.Groups.Add(in_group);
            }
            int          iconIndex = _icon_mgr.GetIconIndex(new FileInfo(row.path), true);
            ListViewItem item      = new ListViewItem(row.title, iconIndex);
            TimeSpan     Length    = TimeSpan.FromSeconds(row.length);
            string       lenStr    = string.Format("{0:d}.{1:d2}:{2:d2}:{3:d2}", Length.Days, Length.Hours, Length.Minutes, Length.Seconds).TrimStart('0', ':', '.');

            item.SubItems.Add(new ListViewItem.ListViewSubItem(item, lenStr));
            item.Group = in_group;
            item.Tag   = row;
            return(item);
        }
예제 #2
0
        private void listViewTracks_DragDrop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
                if (files.Length == 1)
                {
                    string path = files[0];
                    try
                    {
                        CUESheet cue = new CUESheet(_config);
                        cue.Open(path);
                        for (int iTrack = 0; iTrack < cue.TrackCount; iTrack++)
                        {
                            DataSet1.PlaylistRow row = dataSet.Playlist.AddPlaylistRow(
                                path,
                                cue.Metadata.Artist,
                                cue.Metadata.Tracks[iTrack].Title,
                                cue.Metadata.Title,
                                (int)cue.TOC[cue.TOC.FirstAudio + iTrack].Length / 75,
                                iTrack + 1);
                            listViewTracks.Items.Add(ToItem(row));
                        }
                        cue.Close();
                        return;
                    }
                    catch (Exception ex)
                    {
                        Trace.WriteLine(ex.Message);
                    }

                    FileInfo fi = new FileInfo(path);
                    if (fi.Extension != ".cue")
                    {
                        DataSet1.PlaylistRow row = dataSet.Playlist.AddPlaylistRow(
                            path,
                            null,                          // cue.Artist,
                            null,                          // cue.Tracks[iTrack].Title,
                            null,                          // cue.Title,
                            0,                             // (int)cue.TOC[cue.TOC.FirstAudio + iTrack].Length / 75,
                            0);
                        listViewTracks.Items.Add(ToItem(row));
                    }
                }
            }
        }
 public void createPlaylist(string name)
 {
     DataSet1.PlaylistRow plRow = dataset.Playlist.NewPlaylistRow();
     plRow.PlaylistName = name;
     dataset.Playlist.AddPlaylistRow(plRow);
 }