/* void myPdflatexOutputParser_OnTexError(object sender, TexOutputParser.TexError e, Job tjob) { _OnTexError.Raise(sender, new CompileEventArgs() { Error = e, job = tjob } ); } */ /// <summary> /// This is called when PDFLatex has exited /// </summary> /// <param name="sender"></param> /// <param name="e"></param> //void texProcess_Exited(object sender, EventArgs e) void texprocess_Exited(string StdOutput1, string ErrOutput1, TexOutputParser.ParseResult OutputParseResult) { timer.Stop(); // Note: Try to do as much work as possible in the backgroundworker, to not delay the UI thread // Some tasks require synchronization, ... so do them here MyBackgroundWorker.BeginInvoke(new Action(delegate() { Job job = CurrentJob; if (JobNumberChanged != null) JobNumberChanged(this, EventArgs.Empty); // invoke here... it would also be possible to invoke on start of compilation... if (texProcess.ExitCode == 0) { // if (job.BBWritten && !job.GeneratePrecompiledHeaders) // { // ReadBBFromFile(job); // } if (OnCompileEvent != null) OnCompileEvent(this, new CompileEventArgs() { Message = "Compilation done", Type = CompileEventType.Success }); //for thumbnail generation if (job.CreateBMP && !job.GeneratePrecompiledHeaders) { string pathnoext = Helper.RemoveFileExtension(job.path); if (!mypdfDoc.LoadPdf(pathnoext + ".pdf")) { //GlobalUI.ShowMessageBox("Couldn't load pdf " + pathnoext + ".pdf", "Error", MessageBoxButton.OK, MessageBoxImage.Error); GlobalUI.UI.AddStatusLine(this, "Couldn't load pdf " + pathnoext + ".pdf", true); } else if (mypdfDoc.IsEmpty()) { // MessageBox.Show("Image is empty. Did you fill out the sample code block?" public static MessageBoxResult ShowMessageBox); GlobalUI.UI.AddStatusLine(this, "Image is empty. Did you fill out the sample code block?"); } else { //mypdfDoc.SaveBmp(pathnoext + ".bmp", Resolution); mypdfDoc.SaveBmp(pathnoext + ".png", Resolution, true, System.Drawing.Imaging.ImageFormat.Png); if (BitmapGenerated != null) BitmapGenerated(this, EventArgs.Empty); } } else if (job.GeneratePrecompiledHeaders == true) { //if the header should have been generated but it was not if (!File.Exists(Helper.GetPrecompiledHeaderFMTFilePath() )) { todo_tex.Clear(); if (OnCompileEvent != null) OnCompileEvent(this, new CompileEventArgs() { Message = "Compilation of pre-compiled header succeded but the pre-compiled header file could not be found." + " It is supposed to be here: " + Helper.GetPrecompiledHeaderFMTFilePath() + Environment.NewLine + "Compilation of main document stopped. Check settings and read/write permissions!", Type = CompileEventType.Error }); } else { //clear source and temp files of compilation of header //note: the .tex file must not be deleted! Helper.DeleteTemporaryFiles(job.path, false); } } } else // ExitCode != 0 => Error { //if generating pre-compiled header failed. it will not work next time. //so clear job queue and tell user to fix header code. if (job.GeneratePrecompiledHeaders == true) { todo_tex.Clear(); if (OnCompileEvent != null) OnCompileEvent(this, new CompileEventArgs() { Message = "Compilation of pre-compiled header failed with exit code " + texProcess.ExitCode + ". Compilation of main document stopped. Check that all necessary packages are installed and that the pre-compiled header code (in the settings) has no errors!", Type = CompileEventType.Error }); if (JobNumberChanged != null) JobNumberChanged(this, EventArgs.Empty); } else { if (OnCompileEvent != null) OnCompileEvent(this, new CompileEventArgs() { Message = "Compilation failed with exit code " + texProcess.ExitCode, Type = CompileEventType.Error }); } //_JobFailed.Raise(this, new JobEventArgs( job, OutputParseResult )); } if (JobDone != null) JobDone(this, new JobEventArgs(job, OutputParseResult, texProcess.ExitCode)); //parse output from pdflatex. //myPdflatexOutputParser.parseOutput(); //This does not work because something texProcess_Exited is called //before the complete output was received by texProcess_OutputDataReceived(). //isRunning = false; //SetValue(CompilingPropertyKey, false); SetCompiling(false); if (todo_tex.Count > 0) doCompile(); })); }
void myPdflatexOutputParser_OnTexError(object sender, TexOutputParser.TexError e, Job job) { if (OnTexError != null) { OnTexError(sender, e, job); } }
public int ExitCode; // the exitcode of the pdflatex process //public JobEventArgs(Job tjob) { job = tjob; } public JobEventArgs(Job tjob, TexOutputParser.ParseResult presult, int exitCode) { job = tjob; OutputParseResult = presult; ExitCode = exitCode; }
// this is called upon latex error,... the error is extracted from the latex output in the TexCompiler class void addProblemMarker(object sender, TexOutputParser.TexError err, TexCompiler.Job job = null) //String error, int linenr, TexCompiler.Severity severity) { // if job = null, the error was generated by the parser => always display // otherwise display only if the job really was the current document if (job == null || job.DocumentID == CurDocumentID) TexErrors.Add(err); }