Exemplo n.º 1
0
 private void btnSelectDownload_Click(object sender, EventArgs e)
 {
     if (dataGridView1.SelectedRows.Count > 0)//小于等于0 为没有选中任何行
     {
         m3u8DownloadCallBack cb = new m3u8DownloadCallBack(OnSelectDownloadDataReceived);
         int          t          = dataGridView1.SelectedRows[0].Index;// 获取当前行的 行号
         m3u8Download download   = new m3u8Download((m3u8File)(dt.Rows[t][5]), t, chkMerge.Checked, cb);
         download.start();
     }
     else
     {
         MessageBox.Show("请选择一行!");
     }
 }
Exemplo n.º 2
0
        public void OnDownloadAllDataReceived(Aria2Download.Status status, int id, string str)
        {
            dt.Rows[id][4] = str;
            if (status == Aria2Download.Status.Failed || status == Aria2Download.Status.Finished)
            {//处理完成一个(包括下载成功或失败),处理下一个
                finishList[id] = status;

                for (id = id + 1; id < dt.Rows.Count; id++)
                {
                    if (finishList[id] == Aria2Download.Status.NoStart)
                    {//未下载
                        m3u8Download download = new m3u8Download((m3u8File)(dt.Rows[id][5]), id, chkMerge.Checked, DownloadAllDataReceived);
                        download.start();
                        finishList[id] = Aria2Download.Status.Running;
                        break;
                    }
                }

                if (id >= dt.Rows.Count)
                {
                    for (int i = 0; i < finishList.Count; i++)
                    {
                        if (finishList[i] == Aria2Download.Status.Running)
                        {
                            falseList.Clear();
                            successList.Clear();
                            return;//等待其他下载完毕
                        }
                        else if (finishList[i] == Aria2Download.Status.Failed)
                        {
                            falseList.Add(i);
                        }
                        else if (finishList[i] == Aria2Download.Status.Finished)
                        {
                            successList.Add(i);
                        }
                    }
                    MessageBox.Show("成功:" + successList.Count + ",失败" + falseList.Count + "个", "下载完成");
                }
            }
        }
Exemplo n.º 3
0
 private void btnDownloadAll_Click(object sender, EventArgs e)
 {
     DownloadParamterInit();
     DownloadAllDataReceived = new m3u8DownloadCallBack(OnDownloadAllDataReceived);;
     if (dataGridView1.Rows.Count > 0)//小于等于0 为没有任何行
     {
         for (int i = 0; i < dataGridView1.Rows.Count; i++)
         {
             finishList.Add(Aria2Download.Status.NoStart);
         }
         int t = 0;
         for (int i = 0; i < MAX_DOWNLOAD_COUNT && i < dataGridView1.Rows.Count; i++)
         {
             m3u8Download download = new m3u8Download((m3u8File)(dt.Rows[t][5]), t, chkMerge.Checked, DownloadAllDataReceived);
             finishList[t] = Aria2Download.Status.Running;
             download.start();
             t++;
         }
     }
     else
     {
         MessageBox.Show("内容为空!");
     }
 }