private void SearchNovel() { Message = "正在搜索..."; NovelList = NovelHtmlHelper.SearchNovel(SearchNovelName); if (NovelList.Count != 0) { Message = "获取小说列表成功..."; IsCanDownload = true; } else { Message = "获取小说列表失败..."; IsCanDownload = false; } }
private void SaveNovel() { try { isDownloading = true; Novel selectNovel = NovelList[SelectNovelIndex]; GetChapter(); FileStream novelText = new FileStream(Environment.CurrentDirectory + @"\" + selectNovel.NovelName + ".txt", FileMode.Create); StreamWriter novelTextWriter = new StreamWriter(novelText, Encoding.Unicode); Message = "准备下载..."; for (var chapterIndex = 0; chapterIndex < selectNovel.ChapterUrl.Count; chapterIndex++) { if (isStopThread) { selectNovel.ChapterUrl.Clear(); break; } string url = selectNovel.ChapterUrl[chapterIndex]; string textString = selectNovel.NovelChapter[chapterIndex] + NovelHtmlHelper.GetText(url) + "\r\n"; byte[] textByte = Encoding.Unicode.GetBytes(textString); novelTextWriter.Write(textString); Message = "下载进度:" + (chapterIndex + 1).ToString() + "/" + (selectNovel.ChapterUrl.Count).ToString(); } novelText.Close(); isDownloading = false; if (isStopThread) { Message = "已取消下载"; } else { Message = "下载完成"; } isStopThread = false; } catch (Exception e) { Message = e.Message; } }
private void GetChapter() { Message = "正在获取章节..."; NovelHtmlHelper.GetChapter(NovelList[SelectNovelIndex]); Message = "获取成功..."; }