void ShowDetailContent(CurseDetail cd) { if (toolStripContainer2.InvokeRequired) { this.Invoke(new ShowDetailContentDelegate(ShowDetailContentFunction), cd); } }
void ShowDetailContentFunction(CurseDetail cd) { if (null != cd) { foreach (var p in cd.pages) { ToolStripButton tb = new ToolStripButton(); tb.Name = p.title; tb.Text = p.title; tb.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; tb.Font = new System.Drawing.Font("Microsoft YaHei UI", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); tb.Click += DetailPage_click; toolStripDetail.Items.Add(tb); } richTextBoxContent.Text = cd.content; } }
private void PraseDetail() { CleanToolstrip(toolStripDetail); UpdateDetailHeader(currentItem); string html = Curl.GetHtmlAsync(baseHref + currentItem.href); SetProgress(50); if (null != html) { try { CurseDetail cd = Curse.PraseDetail(html); currentDetail = cd; ShowDetailContent(cd); }catch (Exception e) { Settings.LogException(e); } } else { SetStatus("Error!"); SetProgress(0); } try { foreach (var li in flowLayoutPanel1.Controls) { var cli = (ListItem)li; cli.Invoke(new EventHandler(delegate { cli.SetClickEnable(true); cli.Refresh(); })); } }catch (Exception e) { Settings.LogException(e); } SetStatus(null); SetProgress(100); }
private void DetailPage_click(object sender, EventArgs e) { try { var t = ((ToolStripButton)sender).Name; foreach (var p in currentDetail.pages) { if (p.title.ToLower().Equals(t.ToLower())) { string html = Curl.GetHtmlAsync(baseHref + p.href); if (null != html) { CurseDetail cd = Curse.PraseDetail(html); richTextBoxContent.Text = cd.content; } } } }catch (Exception ex) { Settings.LogException(ex); } }