private void startReadBtn_Click(object sender, EventArgs e) { DownLoadFile downFile = null; DownTask downTask; ComicReader reader = new ComicReader(); foreach (CheckBox i in checkPanel.Controls) { if (i.Checked) { if (downUrlDic.ContainsKey(i.Text)) { downFile = new DownLoadFile(); downFile.ComicUrl = downUrlDic[i.Text]; downFile.ComicName = comicNameLabel.Text.Substring(4) + i.Text; downFile.SavePath = "temp\\"; break; } } } if (downFile == null) { return; } downTask = new DownTask(); downTask.addFileEvent += reader.AddFileToList; downTask.ComicName = downFile.ComicName; downTask.DownLoadPath = downFile.SavePath; downTask.ReferUrl = downFile.ComicUrl; downTask.GetNetComic(downFile); reader.StartRead(); reader.Show(); }
public void GetNetComic(DownLoadFile downFile) { Task task = new Task(() => { FileStream file; var path = ""; var decoder = DecoderDistrution.GiveDecoder(downFile.ComicUrl); var response = AnalyseTool.HttpGet(downFile.ComicUrl); decoder.currentUrl = downFile.ComicUrl; var ds = decoder.GetDownImageList(response); path = DownLoadPath + "\\" + ComicName + "\\"; if (File.Exists(path) == false) { Directory.CreateDirectory(path); } int errorCount = 0; int read = 0; int count = 0; foreach (var i in ds.ImageList) { file = new FileStream(path + (count++) + ".jpg", FileMode.Create); var stream = DownLoad(i, SourceUrl); while (stream == null && errorCount < 3) { Thread.Sleep(100); stream = DownLoad(i, SourceUrl); errorCount++; } byte[] buffer = new byte[32768]; while ((read = stream.Read(buffer, 0, buffer.Length)) > 0) { file.Write(buffer, 0, read); } if (addFileEvent != null) { addFileEvent(this, file.Name); } file.Flush(); stream.Flush(); file.Close(); stream.Close(); } }); task.Start(); }
private void downnLoadTool_Click(object sender, EventArgs e)//下载漫画 { try { string savaPath = ""; DownLoadFile downFile; List <DownLoadFile> downFileList; downFileList = new List <DownLoadFile>(); ListViewItemInfo item = currentItem as ListViewItemInfo; if (downForm == null) { downForm = new DownLoadForm(); } if (File.Exists("CONFIG.INI")) { savaPath = ComicConfig.ReadConfig("savePath"); } else { savaPath = ".\\"; } foreach (Controls.CheckBoxEx i in checkPanel.Controls) { if (i.Checked) { if (item.UrlDictronary.ContainsKey(i.FullText)) { downFile = new DownLoadFile(); downFile.ComicUrl = item.UrlDictronary[i.FullText]; downFile.ComicName = comicNameLabel.Text.Substring(4) + i.Text; downFile.SavePath = savaPath; downFileList.Add(downFile); } } } downForm.StartPosition = FormStartPosition.Manual; downForm.Location = new Point(this.Left + 55, this.Bottom - downForm.Height - 50); downForm.Start(downFileList, decoder); downForm.Show(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void downnLoadTool_Click(object sender, EventArgs e)//下载漫画 { try { DownLoadFile downFile; List <DownLoadFile> downFileList; downFileList = new List <DownLoadFile>(); if (downForm == null) { downForm = new DownLoadForm(); } foreach (CheckBox i in checkPanel.Controls) { if (i.Checked) { if (downUrlDic.ContainsKey(i.Text)) { downFile = new DownLoadFile(); downFile.ComicUrl = downUrlDic[i.Text]; downFile.ComicName = comicNameLabel.Text.Substring(4) + i.Text; downFile.SavePath = "D:\\漫画\\"; downFileList.Add(downFile); } } } downForm.StartPosition = FormStartPosition.Manual; downForm.Location = new Point(this.Left + 55, this.Bottom - downForm.Height - 50); downForm.Start(downFileList, decoder); downForm.Show(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void startReadBtn_Click(object sender, EventArgs e) { DownLoadFile downFile = null; DownTask downTask; ComicReader reader = new ComicReader(); reader.readFinishedEvent += Reader_readFinishedEvent; ListViewItemInfo item = currentItem as ListViewItemInfo; foreach (Controls.CheckBoxEx i in checkPanel.Controls) { if (i.Checked) { if (item.UrlDictronary.ContainsKey(i.FullText)) { downFile = new DownLoadFile(); downFile.ComicUrl = item.UrlDictronary[i.FullText]; downFile.ComicName = comicNameLabel.Text.Substring(4) + i.Text; downFile.SavePath = "temp\\"; break; } } } if (downFile == null) { return; } downTask = new DownTask(); downTask.addFileEvent += reader.AddFileToList; downTask.ComicName = downFile.ComicName; downTask.DownLoadPath = downFile.SavePath; downTask.SourceUrl = downFile.ComicUrl; downTask.GetNetComic(downFile); reader.StartRead(); reader.Show(); }
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(); } }