private void SearchComic(string response) { var result = decoder.GetSearchComic(response); if (result == null && result.SearchQueue == null) { return; } this.Invoke(new Action(() => { progressBar1.Value = 0; progressBar1.Maximum = result.SearchQueue.Count; resultLabel.Text = "共找到:" + result.Count.ToString() + "本漫画"; searchListView.Items.Clear(); mainFrame.SelectedPageIndex = 2; })); ViewStruct view = new ViewStruct(); view.Queue = result.SearchQueue; view.ViewAdd = searchListView; //resource.NextPage = result.NextPageUrl; //resource.LastPage = result.LastPageUrl; getThread = new Thread(new ParameterizedThreadStart(GetImagesList)); getThread.Start(view); }
private void DecodeCategory(string listUrl)//解析每一栏的标签页 { Task task = new Task(() => { var msg = AnalyseTool.HttpGet(listUrl); decoder = DecoderDistrution.GiveDecoder(listUrl); decoder.BackUrl = listUrl; var cateCollect = decoder.FindComicByCategory(msg); resource.NextPage = cateCollect.NextPageUrl; resource.LastPage = cateCollect.LastPageUrl; progressBar1.Invoke(new Action(() => { progressBar1.Value = 0; progressBar1.Maximum = cateCollect.ComicQueue.Count; resultListView.Items.Clear(); })); ViewStruct view = new ViewStruct(); view.Queue = cateCollect.ComicQueue; view.ViewAdd = resultListView; if (m_exitLoad == false) { m_exitLoad = true; } getThread = new Thread(new ParameterizedThreadStart(GetImagesList)); getThread.Start(view); }); task.Start(); }
public void GetImagesList(object b)//获取批量图片 { var count = 0; var comicDic = new Dictionary <string, string>(); Image image = null; ViewStruct view = (ViewStruct)b; Queue <BasicComicInfo> queue = view.Queue; ProcessbarDelegate progress = new ProcessbarDelegate(AddProgress); AddListViewItem addItem = new AddListViewItem(ListViewItemAdd); ListViewItem item = null; lock (objLock) { this.Invoke(new Action(() => { m_exitLoad = false; resultListView.Items.Clear(); showImageList.Images.Clear(); view.ViewAdd.LargeImageList = showImageList; })); foreach (var i in queue) { if (m_exitLoad == false) { progressBar1.Invoke(progress, progressBar1); image = AnalyseTool.GetImage(i.ComicImgUrl); item = new ListViewItem(); item.Text = i.ComicName; item.ImageIndex = count++; // Console.WriteLine("漫画名字:{0},图片索引:{1}", item.Text, item.ImageIndex); this.Invoke(addItem, item, image, view.ViewAdd); if (comicDic.ContainsKey(i.ComicName) == false) { comicDic.Add(i.ComicName, i.ComicHref); } resourse.SearchResultURL = comicDic; } else { count = 0; m_exitLoad = true; return; } } m_exitLoad = true; runGif.Invoke(new Action(() => { runGif.Visible = false; })); } }
public void GetImagesList(object b)//获取批量图片 { var count = 0; Image image = null; ViewStruct view = (ViewStruct)b; Queue <BasicComicInfo> queue = view.Queue; ProcessbarDelegate progress = new ProcessbarDelegate(AddProgress); AddListViewItem addItem = new AddListViewItem(ListViewItemAdd); ListViewItemInfo item = null; lock (getLock) { this.Invoke(new Action(() => { m_exitLoad = false; resultListView.Items.Clear(); showImageList.Images.Clear(); view.ViewAdd.LargeImageList = showImageList; })); DateTime time = DateTime.Now; foreach (var i in queue) { if (m_exitLoad == false) { progressBar1.Invoke(progress, progressBar1); image = AnalyseTool.GetImage(i.ComicImgUrl); item = new ListViewItemInfo(); item.Text = i.ComicName; item.ImageIndex = count++; item.ReferUrl = i.ComicHref; this.Invoke(addItem, item, image, view.ViewAdd); } else { count = 0; m_exitLoad = true; SetGifHidden(); return; } } m_exitLoad = true; SetGifHidden(); } }
private void SetProgressBar(Queue <BasicComicInfo> queue)//设置进度条 { this.Invoke(new Action(() => { progressBar1.Value = 0; progressBar1.Maximum = queue.Count; resultListView.Items.Clear(); ViewStruct view = new ViewStruct(); view.Queue = queue; view.ViewAdd = resultListView; if (m_exitLoad == false) { m_exitLoad = true; } getThread = new Thread(new ParameterizedThreadStart(GetImagesList)); getThread.Start(view); })); }