Ejemplo n.º 1
0
        /// <summary>
        /// 下载
        /// </summary>
        /// <param name="ifonlydownloadlrc"></param>
        /// <param name="ifonlydownloadpic"></param>
        private async void Download(bool ifonlydownloadlrc = false, bool ifonlydownloadpic = false)
        {
            List <DownloadList> dl = new List <DownloadList>();

            for (int i = 0; i < SearchListItem.Count; i++)
            {
                if (SearchListItem[i].IsSelected)
                {
                    if (ifonlydownloadlrc)
                    {
                        dl.Add(new DownloadList
                        {
                            Id              = musicinfo[i].Id.ToString(),
                            IfDownloadLrc   = true,
                            IfDownloadMusic = false,
                            IfDownloadPic   = false,
                            Album           = musicinfo[i].Album,
                            LrcUrl          = musicinfo[i].LrcUrl,
                            PicUrl          = musicinfo[i].PicUrl,
                            Quality         = setting.DownloadQuality,
                            Singer          = musicinfo[i].Singer,
                            Title           = musicinfo[i].Title,
                            Api             = musicinfo[i].Api,
                            strMediaMid     = musicinfo[i].strMediaMid
                        });
                    }
                    else if (ifonlydownloadpic)
                    {
                        dl.Add(new DownloadList
                        {
                            Id              = musicinfo[i].Id,
                            IfDownloadLrc   = false,
                            IfDownloadMusic = false,
                            IfDownloadPic   = true,
                            Album           = musicinfo[i].Album,
                            LrcUrl          = musicinfo[i].LrcUrl,
                            PicUrl          = musicinfo[i].PicUrl,
                            Quality         = setting.DownloadQuality,
                            Singer          = musicinfo[i].Singer,
                            Title           = musicinfo[i].Title,
                            Api             = musicinfo[i].Api,
                            strMediaMid     = musicinfo[i].strMediaMid
                        });
                    }
                    else
                    {
                        dl.Add(new DownloadList
                        {
                            Id              = musicinfo[i].Id,
                            IfDownloadLrc   = setting.IfDownloadLrc,
                            IfDownloadMusic = true,
                            IfDownloadPic   = setting.IfDownloadPic,
                            Album           = musicinfo[i].Album,
                            LrcUrl          = musicinfo[i].LrcUrl,
                            PicUrl          = musicinfo[i].PicUrl,
                            Quality         = setting.DownloadQuality,
                            Singer          = musicinfo[i].Singer,
                            Title           = musicinfo[i].Title,
                            Api             = musicinfo[i].Api,
                            strMediaMid     = musicinfo[i].strMediaMid
                        });
                    }
                }
            }
            if (dl.Count != 0)
            {
                int api = apiComboBox.SelectedIndex + 1;
                var pb  = PendingBox.Show("请求处理中...", null, false, Application.Current.MainWindow, new PendingBoxConfigurations()
                {
                    MinHeight = 110,
                    MaxHeight = 110,
                    MinWidth  = 280,
                    MaxWidth  = 280
                });
                string res = "";
                await Task.Run(() =>
                {
                    //res = music.Download(dl,api);
                    res = music.AddToDownloadList(dl);
                });

                pb.Close();
                if (res != "")
                {
                    AduMessageBox.Show(res, "提示", MessageBoxButton.OK);
                }
            }
        }