public EditDialog(M3UEntry entry) { InitializeComponent(); _entry = entry; txtTitle.Text = entry.Title; numDuration.Value = (decimal)entry.Duration.TotalSeconds; txtPath.Text = entry.Path.IsFile ? entry.Path.LocalPath : entry.Path.ToString(); }
/// <summary> /// save current playlist as a M3U file /// </summary> private void SaveCurrentPlToFile() { string lblAudioFileType = rm.GetString("plAudioFilterType"); using (var sfd = new SaveFileDialog { Filter = lblAudioFileType + " (*.m3u)|*.m3u", Title = rm.GetString("savePlDlgTitle") }) { sfd.InitialDirectory = ""; sfd.OverwritePrompt = true; sfd.RestoreDirectory = true; if (sfd.ShowDialog() == DialogResult.OK) { _m3uFile = null; try { _m3uFile = new M3UFile(); foreach (ListViewItem lvItem in l.Items) { /*AudioFileInfo afInfo = new AudioFileInfo( * Path.GetFileName(lvItem.SubItems[2].Text), lvItem.SubItems[2].Text); * afInfo.SetDuration();*/ M3UEntry _m3uEntry = new M3UEntry(TimeSpan.Zero, lvItem.SubItems[0].Text, new Uri(lvItem.SubItems[2].Text)); _m3uFile.Add(_m3uEntry); } // save files into playlist file _m3uFile.Save(sfd.FileName); } catch (Exception) { MessageBox.Show("Error saving playlist to file", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
private void UpdateEntryItem(M3UEntry entry, int index = -1) { if (index == -1) { index = listEntries.Items.Count; } var lvi = new ListViewItem(new[] { entry.Title, string.Format("{0:D2}:{1:D2}", entry.Duration.Minutes, entry.Duration.Seconds), entry.Path.IsFile ? entry.Path.LocalPath : entry.Path.ToString() }); if (index > listEntries.Items.Count - 1) { listEntries.Items.Add(lvi); } else { listEntries.Items[index] = lvi; } }