private void buttonDownloadSelect_Click(object sender, RoutedEventArgs e) { IList list = listSagas.SelectedItems; List <String> listContent = new List <string>(); foreach (ListBoxItem o in list) { listContent.Add(o.Content.ToString()); } new Thread(() => { Thread.CurrentThread.IsBackground = true; foreach (String o in listContent) { foreach (KeyValuePair <String, String> m in printMangas) { if (o == m.Key) { ISaga newSaga = getCurrentSaga(); currentSaga.load_chapters(m); List <Chapters> allBooks = currentSaga.get_chapters(); if (allBooks.Count > 0 && allBooks[0].getIndex() == -1) { newSaga = null; } else { List <Chapters> allChaps = newSaga.get_chapters(); List <Chapters> newList = new List <Chapters>(); for (int i = allBooks.Count - 1; i >= 0; --i) { newList.Add(new Chapters(allBooks[i])); } int index; if (listDownload.Count <= 0) { index = 0; } else { index = listDownload.Last().index + 1; } Download dl = new Download(index, selectedSite, currentSaga.getName(), currentSaga.getImgLink(), newList); listDownload.Add(dl); isDownloadRefresh = true; } break; } } } saveDownload(); }).Start(); }
private void loadChapter() { if (listSagas.SelectedIndex < 0) { return; } int id = listSagas.SelectedIndex; new Thread(() => { Thread.CurrentThread.IsBackground = true; currentSaga = getCurrentSaga(); currentSaga.load_chapters(printMangas[id]); allBooks = currentSaga.get_chapters(); isOneSagaRefresh = true; }).Start(); }
private ISaga getCurrentSaga() { currentSaga = null; switch (selectedSite) { case 1: currentSaga = new SagaJapscan(); break; case 2: currentSaga = new SagaMangaReader(); break; case 3: currentSaga = new SagaMangaHere(); break; case 4: currentSaga = new SagaReadManga(); break; } return(currentSaga); }