/// <summary> /// Thread completed management /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void bw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { // First, handle the case where an exception was thrown. if (e.Error != null) { Tracer.Error("TemplateDocument.bw_RunWorkerCompleted", e.Error); return; } else { Tracer.Verbose("TemplateDocument:bw_RunWorkerCompleted", "START"); try { if (e.Result != null && e.Result is string) { this.SyntaxEditor.Text = e.Result as string; } WaitPanel.Stop(); } catch (Exception all) { Tracer.Error("TemplateDocument.bw_RunWorkerCompleted", all); } finally { Tracer.Verbose("TemplateDocument:bw_RunWorkerCompleted", "END"); } } }
/// <summary> /// Start a thread to load the document /// </summary> override internal void LoadDocument() { Tracer.Verbose("XpsReportDocument:LoadDocument", "START"); try { base.LoadDocument(); Worker.DoWork += new DoWorkEventHandler(bw_DoWork); Worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bw_RunWorkerCompleted); // Start the asynchronous operation. if (!string.IsNullOrEmpty(Context.FullName) || Context.Entity != null) { Worker.RunWorkerAsync(base.Context); } else { WaitPanel.Stop(); } } catch (Exception all) { Tracer.Error("XpsReportDocument.LoadDocument", all); } finally { Tracer.Verbose("XpsReportDocument:LoadDocument", "END"); } }
/// <summary> /// Thread completed management /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void bw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { // First, handle the case where an exception was thrown. if (e.Error != null) { Tracer.Error("HelpDocument.bw_RunWorkerCompleted", e.Error); } else { Tracer.Verbose("HelpDocument:bw_RunWorkerCompleted", "START"); try { if (e.Result != null && e.Result is XpsDocument) { XpsDocument xps = (XpsDocument)e.Result; documentViewer1.Document = xps.GetFixedDocumentSequence(); ContentData = xps; } WaitPanel.Stop(); } catch (Exception all) { Tracer.Error("HelpDocument.bw_RunWorkerCompleted", all); } finally { Tracer.Verbose("HelpDocument:bw_RunWorkerCompleted", "END"); } } }
/// <summary> /// After the thread complete, load the xaml home document /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void bw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { // First, handle the case where an exception was thrown. if (e.Error != null) { Tracer.Error("HomeDocument.bw_RunWorkerCompleted", e.Error); } else { Tracer.Verbose("HomeDocument:bw_RunWorkerCompleted", "START"); UrlSaveHelper hlp = (UrlSaveHelper)e.Result; // Finally, handle the case where the operation succeeded. if (File.Exists(base.Context.FullName)) { try { FileStream fs = File.OpenRead(base.Context.FullName); FlowDocViewer.Document = (FlowDocument)XamlReader.Load(fs); fs.Close(); Tracer.Verbose("HomeDocument:bw_RunWorkerCompleted", "Internet document loaded"); } catch (Exception) { //load the config from resources using (Stream fs = Application.ResourceAssembly.GetManifestResourceStream("ReflectionStudio.Resources.Embedded.Home.xaml")) { if (fs == null) { throw new InvalidOperationException("Could not find embedded resource"); } FlowDocViewer.Document = (FlowDocument)XamlReader.Load(fs); fs.Close(); Tracer.Verbose("HomeDocument:bw_RunWorkerCompleted", "Local document loaded"); } } ParseHyperlink(FlowDocViewer.Document); WaitPanel.Stop(); Tracer.Verbose("HomeDocument:bw_RunWorkerCompleted", "END"); } } }