private void GetNovelChapters()
        {
            TryCatchBlock th = new TryCatchBlock(delegate
            {
                _module = Constants.MODULE_NOVELCHAPTERS;

                SetMessage(string.Format("刷新[{0}]的章节...", _currentNovel.Name), true);

                Collection<ChapterInfo> chapters = new Collection<ChapterInfo>();
                string content = HH.Get(_currentNovel.ChapterUrl);
                if (string.IsNullOrEmpty(content))
                {
                    LogHelper.Write("GetNovelChapters()--" + _currentNovel.ChapterUrl, "Empty http response!!!", LogSeverity.Warn);
                    return;
                }

                content = StringHelper.GetMid(content, "<table border=\"0\" width=\"950\" cellspacing=\"0\" cellpadding=\"0\">", "</div>");
                if (content != null)
                {
                    int temp = 1;
                    string strTemp ="";
                    do
                    { 
                        strTemp = string.Format(CHAPTER, temp);
                        if (content.Contains(strTemp))
                            temp++;
                        else
                            break;
                    }
                    while (temp < 10000);

                    for (int ix = 1; ix < temp; ix++)
                    {
                        ChapterInfo chapter = new ChapterInfo();
                        chapter.ChapterId = ix;
                        chapter.ChapterName = string.Format(CHAPTER, ix);
                        chapter.Url = _currentNovel.ChapterUrl.Substring(0, _currentNovel.ChapterUrl.LastIndexOf('/') + 1) + ix + ".html";
                        chapters.Add(chapter);
                    }
                }

                _currentNovel.Chapters = chapters;

                SetMessage("小说章节获取成功!", true);

                if (NovelChaptersFetched != null)
                    NovelChaptersFetched(chapters);
            });
            base.ExecuteTryCatchBlock(th, "发生异常,获取小说章节失败!");
        }
Beispiel #2
0
 private void btnLast_Click(object sender, EventArgs e)
 {
     try
     {
         StartLoading();
         _currentChapterIndex = _currentNovel.Chapters.Count - 1;
         _currentChapter = _currentNovel.Chapters[_currentChapterIndex];
         _requestHandler.GetNovelContentByThread(_currentChapterIndex);
     }
     catch (Exception ex)
     {
         Program.ShowMessageBox("MainForm.btnLast_Click", ex);
         StopLoading();
     }
 }
Beispiel #3
0
        private void txtContentPage_KeyDown(object sender, KeyEventArgs e)
        {
            try
            {
                if (e.KeyCode == Keys.Enter)
                {
                    if (!DataValidation.IsNaturalNumber2(txtContentPage.Text))
                    {
                        txtContentPage.Select();
                        MessageBox.Show("章节数必须是大于0的整数!", "内容翻页", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }

                    StartLoading();
                    _currentChapterIndex = DataConvert.GetInt32(txtContentPage.Text) - 1;
                    if (_currentChapterIndex >= _currentNovel.Chapters.Count)
                        _currentChapterIndex = _currentNovel.Chapters.Count - 1;
                    _currentChapter = _currentNovel.Chapters[_currentChapterIndex];
                    _requestHandler.GetNovelContentByThread(_currentChapterIndex);
                }
            }
            catch (Exception ex)
            {
                Program.ShowMessageBox("MainForm.txtContentPage_KeyDown", ex);
                StopLoading();
            }
        }
Beispiel #4
0
 void btnChapter_Click(object sender, EventArgs e)
 {
     try
     {
         LinkLabel btnChapter = sender as LinkLabel;
         if (btnChapter != null)
         {
             StartLoading();
             _currentChapter = btnChapter.Tag as ChapterInfo;
             _currentChapterIndex = _currentChapter.ChapterId - 1;
             _requestHandler.GetNovelContentByThread(_currentChapterIndex);
             btnChapter.LinkVisited = true;
         }
     }
     catch (Exception ex)
     {
         Program.ShowMessageBox("MainForm.btnChapter_Click", ex);
         StopLoading();
     }
 }