Esempio n. 1
0
        /// <summary>
        /// Export to PDF
        /// </summary>
        public void CreatePDF(string modelNameToExport)
        {
            var pdfWriter = new PDFWriter(explorerPresenter, portraitOrientation: true);

            // write image files
            Image banner;

            banner = new Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("ApsimNG.Resources.AIBanner.png"));

            // Convert all models in file to tags.
            var tags = new List <AutoDocumentation.ITag>();

            // Add banner and version.
            tags.Add(new AutoDocumentation.Image()
            {
                image = banner, name = "AIBanner"
            });
            tags.Add(new AutoDocumentation.Paragraph(explorerPresenter.ApsimXFile.ApsimVersion, 0));

            foreach (IModel child in explorerPresenter.ApsimXFile.Children)
            {
                AutoDocumentation.DocumentModel(child, tags, headingLevel: 1, indent: 0);
                if (child.Name == "TitlePage")
                {
                    AddBackground(tags);
                    AddUserDocumentation(tags, modelNameToExport);

                    // Document model description.
                    int modelDescriptionIndex = tags.Count;
                    tags.Add(new AutoDocumentation.Heading("Model description", 1));
                    explorerPresenter.ApsimXFile.DocumentModel(modelNameToExport, tags, 1);

                    // If no model was documented then remove the 'Model description' tag.
                    if (modelDescriptionIndex == tags.Count - 1)
                    {
                        tags.RemoveAt(modelDescriptionIndex);
                    }
                }
                else if (child.Name == "Validation")
                {
                    AddStatistics(tags);
                }
            }
            // Scan for citations.
            ScanForCitations(tags);

            // Create a bibliography.
            CreateBibliography(tags);

            // Write the PDF.
            pdfWriter.CreatePDF(tags, FileNameWritten);
        }
Esempio n. 2
0
        /// <summary>
        /// Perform the command
        /// </summary>
        public void Do(CommandHistory commandHistory)
        {
            // Get a list of tags for each type.
            var tags = new List <AutoDocumentation.ITag>();

            for (int i = 0; i < typesToDocument.Count; i++)
            {
                tags.AddRange(DocumentType(typesToDocument[i]));
            }

            // Convert the list of models into a list of tags.
            var pdfWriter = new PDFWriter(explorerPresenter, portraitOrientation: false);

            pdfWriter.CreatePDF(tags, FileNameWritten);
        }
Esempio n. 3
0
        /// <summary>
        /// Perform the command
        /// </summary>
        public void Do(CommandHistory commandHistory)
        {
            if (modelToDocument is ModelCollectionFromResource)
            {
                parameterNames = (modelToDocument as ModelCollectionFromResource).GetModelParameterNames();
            }

            // Get a list of tags for each type.
            var tags = new List <AutoDocumentation.ITag>();

            // Document the model.
            tags.AddRange(DocumentObject(modelToDocument));

            // Document any other referenced types.
            for (int i = 0; i < typesToDocument.Count; i++)
            {
                tags.AddRange(DocumentType(typesToDocument[i]));
            }

            // Convert the list of models into a list of tags.
            var pdfWriter = new PDFWriter(explorerPresenter, portraitOrientation: false);

            pdfWriter.CreatePDF(tags, FileNameWritten);
        }