// 选中行更改 private void ListTitle_SelectedIndexChanged(object sender, EventArgs e) { try { ListView.SelectedIndexCollection indexes = this.listBook.SelectedIndices; if (indexes.Count > 0) { int index = indexes[0]; string stitleName = this.listBook.Items[index].SubItems[1].Text; //书名 string sPartName = this.listBook.Items[index].SubItems[3].Text; //目录地址 XmlServices.AddHomeDirectory(stitleName, sPartName); SoTitle objForm = new SoTitle() { titleUrl = sPartName, bookName = this.txtBookName.Text, sFrom = sFrom, pShow = pShow }; this.Close(); //再主窗体中加载 章节窗体 sFrom?.Invoke(objForm); } } catch (Exception ex) { MessageBox.Show("操作失败!\n" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } }
//单击历史列表内容时触发 private void ListTitle_CellContentClick(object sender, DataGridViewCellEventArgs e) { int rowindex = e.RowIndex; //1章节2内容 int comIndex = e.ColumnIndex; if (rowindex >= 0 && comIndex != 0) { ps.MessageBoxShow(this.PointToScreen(new Point(0, 0)), "正在获取目录,请稍后..."); string bookName = listTitle.CurrentRow.Cells["Title"].Value.ToString(); //获取书名 string pathurl = listTitle.CurrentRow.Cells["Path"].Value.ToString(); //获取目录URL string contentUrl = listTitle.CurrentRow.Cells["Historyurl"].Value.ToString(); //获取具体内容URL //目录章节 if (comIndex == 1) { this.Close(); SoTitle objForm = new SoTitle() { sFrom = sFrom, titleUrl = pathurl, bookName = bookName, pShow = pShow }; //再主窗体中加载 章节窗体 sFrom?.Invoke(objForm); } //具体内容 else if (comIndex == 2) { if (contentUrl == "") { return; } latch = new CountdownEvent(1); //创建TestClass类的对象 ThreadServices threadClass = new ThreadServices() { //在testclass对象的mainThread(委托)对象上搭载方法,在线程中调用mainThread对象时相当于调用了这方法。 mainThread = new ThreadServices.WebDataDelegate(GetChapterData) }; //启动线程,启动之后线程才开始执行 void starter() { threadClass.QueryData(pathurl); } new Thread(starter).Start(); latch.Wait(); ThreadRefund(pathurl, contentUrl, bookName); } ps.MessageBoxClose(); this.Close(); } }
// 返回 private void BtnReturn_Click(object sender, EventArgs e) { if (catalogUrl == "") { return; } SoTitle objForm = new SoTitle() { sFrom = sFrom, bookName = bookName, titleUrl = catalogUrl }; //再主窗体中加载 章节窗体 sFrom?.Invoke(objForm); this.Close(); }