private void ShowTrans(PanelEx rpanel) { if (qv.SelectedIndex != -1) { TextBoxEx txtpnl = (TextBoxEx)rpanel.Controls[0]; tafseerStruct r = GettafseerFromTitle(rpanel.SelectedText); txtpnl.RightToLeft = (r.dir == "rtl") ? RightToLeft.Yes : RightToLeft.No; if (wc.Contains(r.id)) /* retreive from the web */ { txtpnl.ShowLoading(); lblstatus.Text = "Retrieving Content From Web..."; string rpath = (r.location + qv.SelectedAya.ID + ".html"); BackgroundWorker bwText = new BackgroundWorker(); bwText.DoWork += new DoWorkEventHandler(bwText_DoWork); bwText.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwText_RunWorkerCompleted); bwText.RunWorkerAsync(new BackgroundWorkerTextArgument( rpanel, rpath)); } else /* reteieve local translations */ { XmlDocument rxml; rxml = (rpanel.Name == "pnla") ? xmlpnla : xmlpnlb; XmlNode x = rxml.SelectSingleNode("//AYA[@id='" + qv.SelectedAya.ID + "']"); if (x != null) { txtpnl.Text = x.InnerText; } } } }
private void bwText_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { BackgroundWorkerTextArgument rArgument = ((BackgroundWorkerTextArgument)e.Result); PanelEx rpanel = rArgument.Panel; TextBoxEx txtpnl = (TextBoxEx)rpanel.Controls[0]; tafseerStruct r = GettafseerFromTitle(rpanel.SelectedText); if (rArgument.Text == "-1") { lblstatus.Text = DOWNLOAD_TRANSLATION_ERROR; txtpnl.HideLoading(); txtpnl.Text = ""; return; } txtpnl.RightToLeft = (r.dir == "rtl") ? RightToLeft.Yes : RightToLeft.No; string rText = ((BackgroundWorkerTextArgument)e.Result).Text; txtpnl.Text = RemoveDiacritics(RemoveHtml(rText, r.id)); lblstatus.Text = "Ready"; txtpnl.HideLoading(); }