IfcDoc.DocumentationISO.FormatFigure C# (CSharp) Méthode

FormatFigure() private static méthode

If matching figure exists, generates HTML including the figure and increments the figure count.
private static FormatFigure ( DocProject docProject, DocObject definition, DocTemplateDefinition dtd, string caption, List listFigures, string path ) : string
docProject DocProject The project
definition DocObject Object for which to find figure.
dtd DocTemplateDefinition Optional template for which to find figure.
caption string Caption of definition used in determining figure caption, e.g. 'Beam'
listFigures List List of figures for determining numbering; appended as applicable by function.
path string
Résultat string
        private static string FormatFigure(DocProject docProject, DocObject definition, DocTemplateDefinition dtd, string caption, List<ContentRef> listFigures, string path)
        {
            string title = null;
            string desc = null;
            if (!String.IsNullOrEmpty(caption))
            {
                title = caption;
                desc = caption.Substring(0, 1).ToUpper() + caption.Substring(1);
            }
            else
            {
                title = "<i>" + definition.Name + "</i>";
                desc = title;
            }

            StringBuilder sb = new StringBuilder();

            if (definition is DocDefinition) //TODO: property set figures
            {
                DocSchema docSchema = docProject.GetSchemaOfDefinition((DocDefinition)definition);

                string filename = MakeLinkName(definition);
                if (dtd != null)
                {
                    filename += "-" + MakeLinkName(dtd);
                }
                filename += ".png";

                string filepath = path + @"\figures\" + filename;
                if (System.IO.File.Exists(filepath))
                {
                    listFigures.Add(new ContentRef(desc, definition));

                    // "Sensor", "Port Use Definition" ==> "Sensor Port Use"
                    string figuredef = "usage";
                    if (dtd != null)
                    {
                        figuredef = dtd.Name.ToLower();
                    }

                    // Per ISO guidelines, all figures must be referenced from text.
                    sb.Append("<p>Figure ");
                    sb.Append(listFigures.Count);
                    sb.Append(" illustrates ");
                    sb.Append(title.ToLower());
                    sb.Append(" ");
                    sb.Append(figuredef.ToLower());
                    sb.Append(".</p>\r\n");

                    // include the figure with formatting below per ISO
                    sb.Append("<table><tr><td><img src=\"../../../figures/");
                    sb.Append(filename);
                    sb.Append("\" alt=\"");
                    sb.Append(figuredef);
                    sb.Append("\"></td></tr><tr><td><p class=\"figure\">Figure ");
                    sb.Append(listFigures.Count);
                    sb.Append(" &mdash; ");
                    sb.Append(desc);
                    sb.Append(" ");
                    sb.Append(figuredef);
                    sb.Append("</p></td></tr></table>\r\n");
                    sb.AppendLine();
                }
            }

            return sb.ToString();
        }