/// <summary> /// 添加章节 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void addChapterToolStripMenuItem_Click(object sender, EventArgs e) { AddChapterForm acForm = new AddChapterForm(++maxChapId); acForm.ShowDialog(); if (acForm.isOK) { Model.Chapter chap = new Model.Chapter(); chap.Cid = acForm.cid; chap.Name = acForm.cName; chap.IsEmpty = acForm.isEmpty; if (acForm.cContent != "") { chap.Content = new Model.novel_chapter_content(); chap.Content.cid = chap.Cid; chap.Content.content = acForm.cContent; chap.IsUpdate = true; } allChaps.Add(chap); allChapterCount++; allPage = (allChapterCount - 1) / everyPageCount + 1; acForm.Dispose(); statusLabel.Text = "添加成功!请刷新查看"; } else { statusLabel.Text = "添加已取消"; } }
/// <summary> /// 根据nid获得并解析为chapter /// </summary> /// <param name="nid"></param> /// <returns></returns> private List <Model.Chapter> getChapters(string nid) { DataSet ds = ndetail.GetList("Nid='" + nid + "'"); string chapContent = ds.Tables[0].Rows[0][8].ToString(); string blankChap = ds.Tables[0].Rows[0][9].ToString(); string[] chapCons = chapContent.Split(new string[] { "$-$" }, StringSplitOptions.None); string[] blankChps = blankChap.Split(','); List <Model.Chapter> chaps = new List <Model.Chapter>(); foreach (string chap in chapCons) { string[] infos = chap.Split(new string[] { "#-#" }, StringSplitOptions.None); if (infos.Length != 2) { continue; } Model.Chapter c = new Model.Chapter(); try { c.Cid = int.Parse(infos[0]); maxChapId = Math.Max(maxChapId, c.Cid); } catch (Exception e) { c.Cid = -1; statusLabel.Text = "章节获取错误:" + e.Message; } c.Name = infos[1]; c.IsEmpty = getIsBlank(blankChps, c.Cid + ""); chaps.Add(c); } allChapterCount = chaps.Count; allPage = (allChapterCount - 1) / everyPageCount + 1; return(chaps); }
/// <summary> /// 显示nid对应的章节信息 /// </summary> /// <param name="nid"></param> private void showCidContent(Model.Chapter chap) { statusLabel.Text = "正在加载小说信息,cid为:" + allChaps[nowChapIndex].Cid + " 请稍候。。。。"; statusStrip1.Refresh(); try { if (chap.Content == null || chap.Content.content == null || chap.Content.content == "") { chap.Content = nchapCon.GetModel(nidTxt.Text, chap.Cid); } if (chap.Content == null) { chap.Content = new Model.novel_chapter_content(); } cidTxt.Text = chap.Cid.ToString(); cNameTxt.Text = chap.Name; emptyTxt.Text = chap.IsEmpty.ToString(); if (chap.Content != null) { cContentTxt.Text = chap.Content.content; statusLabel.Text = "加载章节信息成功,nid为:" + nidTxt.Text + " ,cid为:" + chap.Cid; } else { cContentTxt.Text = ""; statusLabel.Text = "章节内容为空,nid为:" + nidTxt.Text + " ,cid为:" + chap.Cid; } statusStrip1.Refresh(); } catch (Exception ee) { statusLabel.Text = "获取小说内容出错:" + ee.Message; } saveInfoBtn.Enabled = false; saveInfoBtn.Enabled = false; }
/// <summary> /// 根据nid获得并解析为chapter /// </summary> /// <param name="nid"></param> /// <returns></returns> private List<Model.Chapter> getChapters(string nid) { DataSet ds = ndetail.GetList("Nid='" + nid + "'"); string chapContent = ds.Tables[0].Rows[0][8].ToString(); string blankChap = ds.Tables[0].Rows[0][9].ToString(); string[] chapCons = chapContent.Split(new string[] { "$-$" }, StringSplitOptions.None); string[] blankChps = blankChap.Split(','); List<Model.Chapter> chaps = new List<Model.Chapter>(); foreach (string chap in chapCons) { string[] infos = chap.Split(new string[] { "#-#" }, StringSplitOptions.None); if (infos.Length != 2) continue; Model.Chapter c = new Model.Chapter(); try { c.Cid = int.Parse(infos[0]); maxChapId = Math.Max(maxChapId, c.Cid); } catch (Exception e) { c.Cid = -1; statusLabel.Text = "章节获取错误:" + e.Message; } c.Name = infos[1]; c.IsEmpty = getIsBlank(blankChps, c.Cid + ""); chaps.Add(c); } allChapterCount = chaps.Count; allPage = (allChapterCount - 1) / everyPageCount + 1; return chaps; }