コード例 #1
0
 string SavePlaylist(string path = null)
 {
     if (!SelectedSongs.Any())
     {
         return(null);
     }
     Playlist.Clear();
     foreach (var item in SelectedSongs)
     {
         Playlist.Add(string.Format("#EXTINF:{0}", item.Id));
         if (string.IsNullOrEmpty(item.Song.FilePath))
         {
             Playlist.Add(System.IO.Path.Combine(".", item.Dir, item.FileNameBase + ".mp3"));
         }
         else
         {
             Playlist.Add(item.Song.FilePath);
         }
     }
     if (path == null)
     {
         path = Global.AppSettings["DownloadFolder"] + "\\default.m3u";
     }
     File.WriteAllLines(path, Playlist, Encoding.UTF8);
     return(path);
 }
コード例 #2
0
 protected override void item_double_click(object sender, System.Windows.Input.MouseButtonEventArgs e)
 {
     if (SelectedSongs.Any())
     {
         btn_play_Click(sender, e);
     }
     else
     {
         base.item_double_click(sender, e);
     }
 }
コード例 #3
0
 void btn_complete_Click(object sender, RoutedEventArgs e)
 {
     if (!SelectedSongs.Any())
     {
         return;
     }
     DownloadManager.Instance.StopByTag(SelectedSongs.Select(x => x.Id).ToArray());
     foreach (var item in SelectedSongs)
     {
         item.HasMp3 = true; item.HasLrc = true; item.HasArt = true;
         MessageBus.Instance.Publish(new MsgDownloadStateChanged
         {
             Id   = item.Id,
             Item = item,
         });
     }
 }
コード例 #4
0
        void btn_save_playlist_Click(object sender, RoutedEventArgs e)
        {
            if (!SelectedSongs.Any())
            {
                return;
            }
            var win = new System.Windows.Forms.SaveFileDialog
            {
                InitialDirectory = Global.AppSettings["DownloadFolder"],
                Filter           = "播放列表文件 (*.m3u)|*.m3u",
                OverwritePrompt  = true,
                Title            = "存为播放列表"
            };

            if (win.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                SavePlaylist(win.FileName);
            }
        }