Пример #1
0
        /// <summary>
        /// If the tex code is changed, this method Reompiles it.
        /// The action taken depends upon the currently active mode:
        /// Wysiwyg Mode:
        ///     Starts asynchronous parse and compile operations.
        ///     The compilation is done on a temporary file in the current document's folder.
        /// Preview Mode:
        ///     Compilation only, done on a temporary file in the current document's folder.
        /// Production Mode:
        ///     Compilation only, done on the current document directly (not on temp file).
        /// </summary>
        /// <param name="NoParse">Skip the parsing step if true. (compile only)</param>
        public void Recompile(bool NoParse = false)
        {
            // Parse and compile, depending on current mode
            string path;

            if (FilePath != null)
            {
                path = FilePath + Helper.GetPreviewFilename() + Helper.GetPreviewFilenameExt();
            }
            else
            {
                path = "";      // use a temp file
            }
            if (MainWindow.TheVM == null || MainWindow.TheVM.EditorMode == TEMode.Wysiwyg)
            {
                if (!ProgrammaticTextChange && !NoParse)
                {
                    if (Document.Text.Trim() != "")
                    {
                        AllowEditing = false;   // overlay out of date->turn off editing
                        ParseNeeded  = true;
                    }
                    else
                    {
                        ParseTree    = null;
                        AllowEditing = true;
                    }
                }

                //compiling only must be started if there is latex code
                if (Document.Text.Trim() != "")
                {
                    TheCompiler.Instance.AddJobExclusive(Document.Text, path, true, DocumentID);
                }
                else
                {
                    PdfPath = "";
                }
            }
            else if (MainWindow.TheVM.EditorMode == TEMode.Preview)
            {
                TheCompiler.Instance.AddJobExclusive(Document.Text, path, false, DocumentID);
            }
            else
            {
                if (SaveCurFile())
                {
                    TheCompiler.Instance.AddJobExclusive(FilePath, DocumentID);
                }
                else
                {
                    PdfPath = "";
                }
            }

            TexErrors.Clear();
        }
Пример #2
0
        /*      private string SavePdf(bool SaveAs)
         *    {
         *        if (SaveAs == false && CurFileNeverSaved)
         *        {
         *            MainWindow.AddStatusLine("Please save document first", true);
         *            return "";
         *        }
         *
         *        string s = Helper.GetCurrentWorkingDir();
         *        string t = Helper.GetPreviewFilename();
         *        string PreviewPdfFilePath = System.IO.Path.GetFullPath(CurFile) + t + ".pdf";
         *        string PdfFilePath = Helper.RemoveFileExtension(System.IO.Path.GetFullPath(CurFile)) + ".pdf";
         *        //            string PreviewPdfFilePath = s + "\\" + CurFile + t + ".pdf";
         *        //            string PdfFilePath = s + "\\" + Helper.RemoveFileExtension(CurFile) + ".pdf";
         *
         *        if (SaveAs == true)
         *        {
         *            SaveFileDialog sfd = new SaveFileDialog();
         *
         *            sfd.Filter = "Pdf Files|*.pdf" +
         *         "|All Files|*.*";
         *            sfd.OverwritePrompt = true;
         *            sfd.ValidateNames = true;
         *
         *            sfd.FileName = System.IO.Path.GetFileName(CurFile);
         *            // change file extension to .pdf
         *            sfd.FileName = Helper.RemoveFileExtension(sfd.FileName) + ".pdf";
         *            sfd.InitialDirectory = System.IO.Path.GetDirectoryName(CurFile);
         *            if (sfd.ShowDialog() != true)
         *                return "";
         *            PdfFilePath = sfd.FileName;
         *        }
         *
         *        try
         *        {
         *            File.Copy(PreviewPdfFilePath, PdfFilePath, true);
         *        }
         *        catch (Exception Ex)
         *        {
         *            AddStatusLine("Could not save PDF. " + Ex.Message, true);
         *            return "";
         *        }
         *
         *        AddStatusLine("Preview PDF file saved as " + PdfFilePath);
         *        return PdfFilePath;
         *    } */



        // 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 == DocumentID)
            {
                TexErrors.Add(err);
            }
        }
Пример #3
0
 void clearProblemMarkers()
 {
     TexErrors.Clear();
 }