Esempio n. 1
0
        private void LoadDownLoadRecord()
        {
            DateTime   time    = DateTime.Now;
            SqlOperate operate = new SqlOperate();

            operate.CreateOrOpenDataBase("task.db");
            var list = operate.GetRecordList();

            Console.WriteLine("查找消耗时间:{0}", DateTime.Now.Subtract(time).Milliseconds);
            time = DateTime.Now;
            operate.CloseDataBase();

            List <DownListBox> itemList = new List <DownListBox>();

            foreach (var i in list)
            {
                DownListBox downBox = new DownListBox();
                downBox.deleteEvent         += downItem_deleteEvent;
                downBox.resumeDownLoadEvent += downItem_resumeDownLoadEvent;
                downBox.SetMaxPage(i.PageCount);  //下载最大值
                downBox.Title       = i.TaskName; //漫画名字
                downBox.Pages       = i.PageCount;
                downBox.CurrentPage = i.DownLoadProgress;
                downBox.FilePath    = i.Path;
                itemList.Add(downBox);
                downlistCollection.Add(downBox);
            }

            filePanel.Controls.AddRange(itemList.ToArray());
            Console.WriteLine("绘制消耗时间:{0}", DateTime.Now.Subtract(time).Milliseconds);
        }
Esempio n. 2
0
        void downItem_resumeDownLoadEvent(object sender, EventArgs args)//继续下载
        {
            DownTask    task    = null;
            DownListBox listBox = sender as DownListBox;

            foreach (var i in taskQueue)
            {
                if (i.ComicName == listBox.Title)
                {
                    task = i;
                }
            }

            if (task == null)
            {
                SqlOperate operate = new SqlOperate();
                operate.CreateOrOpenDataBase("task.db");
                var list = operate.GetRecordList();

                foreach (var i in list)
                {
                    if (i.TaskName == listBox.Title)
                    {
                        List <DownLoadFile> downList = new List <DownLoadFile>();
                        DownLoadFile        file     = new DownLoadFile();
                        file.ComicName = i.TaskName;
                        file.ComicUrl  = i.Url;
                        file.SavePath  = i.Path;
                        downList.Add(file);
                        StartNewDownLoad(downList, DecoderDistrution.GiveDecoder(i.Url), i.DownLoadProgress - 1);
                    }
                }

                operate.CloseDataBase();
            }
        }