コード例 #1
0
        public static void PrintBehaviorGroup(WordprocessingDocument document, BehaviorGroup bg, bool book, bool isForAppendix = false)
        {
            ArtifactPrinter.AddArtifactContent(document, bg.Artifact, book, isForAppendix);

            _log.Info("Printing Behavior Group Properties: " + bg.Artifact.Name);
            var body = document.MainDocumentPart.Document.Body;

            var aDef  = body.AppendChild(new Paragraph());
            var adRun = aDef.AppendChild(new Run());

            adRun.AppendChild(new Text("Behavior Group Details"));
            Utils.ApplyStyleToParagraph(document, "Heading1", "Heading1", aDef, JustificationValues.Center);

            foreach (var br in bg.Behaviors)
            {
                BehaviorPrinter.AddBehaviorReferenceProperties(document, br);
            }
            if (!book)
            {
                return;
            }
            var pageBreak = body.AppendChild(new Paragraph());
            var pbr       = pageBreak.AppendChild(new Run());

            pbr.AppendChild(new Text(""));

            if (pageBreak.ParagraphProperties == null)
            {
                pageBreak.ParagraphProperties = new ParagraphProperties();
            }

            pageBreak.ParagraphProperties.PageBreakBefore = new PageBreakBefore();
            Utils.ApplyStyleToParagraph(document, "Normal", "Normal", pageBreak);
        }
コード例 #2
0
        public static void PrintSpecification(WordprocessingDocument document, TokenSpecification spec, bool isForAppendix = false)
        {
            var classification = ModelMap.GetClassification(spec);

            ArtifactPrinter.AddArtifactSpecification(document, spec.Artifact, classification, true);
            _log.Info("Printing Token Specification Properties: " + spec.Artifact.Name);
            var body = document.MainDocumentPart.Document.Body;

            var beDef = body.AppendChild(new Paragraph());
            var beRun = beDef.AppendChild(new Run());

            beRun.AppendChild(new Text(spec.Artifact.Name + " is:"));
            Utils.ApplyStyleToParagraph(document, "Heading1", "Heading1", beDef);

            var behaviorList = spec.Behaviors.Select(b => b.Artifact.Name).ToList();

            Utils.AddBulletList(document, behaviorList);

            if (spec.PropertySets.Count > 0)
            {
                var bgDef = body.AppendChild(new Paragraph());
                var bgRun = bgDef.AppendChild(new Run());
                bgRun.AppendChild(new Text("It includes the following Property Sets:"));
                Utils.ApplyStyleToParagraph(document, "Heading3", "Heading3", bgDef, JustificationValues.Center);

                var propSetList = spec.PropertySets.Select(b => b.Artifact.Name).ToList();
                Utils.AddBulletList(document, propSetList);
            }

            if (spec.ChildTokens.Count > 0)
            {
                var cDef = body.AppendChild(new Paragraph());
                var cRun = cDef.AppendChild(new Run());
                cRun.AppendChild(new Text("As a Hybrid " + spec.Artifact.Name + " has the following Child Tokens:"));
                Utils.ApplyStyleToParagraph(document, "Heading3", "Heading3", cDef, JustificationValues.Center);
                foreach (var c in spec.ChildTokens)
                {
                    ArtifactPrinter.AddChildArtifactSpecification(document, c);
                    var bbDef = body.AppendChild(new Paragraph());
                    var bbRun = bbDef.AppendChild(new Run());
                    bbRun.AppendChild(new Text(""));
                    Utils.ApplyStyleToParagraph(document, "Normal", "Normal", bbDef, JustificationValues.Center);
                }
            }

            var detailsDef = body.AppendChild(new Paragraph());
            var detailsRun = detailsDef.AppendChild(new Run());

            detailsRun.AppendChild(new Text(spec.Artifact.Name + " Details"));
            Utils.ApplyStyleToParagraph(document, "Heading1", "Heading1", detailsDef, JustificationValues.Center);

            BasePrinter.AddBaseSpecification(document, spec.TokenBase);

            var dDef = body.AppendChild(new Paragraph());
            var dRun = dDef.AppendChild(new Run());

            dRun.AppendChild(new Text("Behaviors"));
            Utils.ApplyStyleToParagraph(document, "Heading2", "Heading2", dDef);

            foreach (var b in spec.Behaviors)
            {
                BehaviorPrinter.AddBehaviorSpecification(document, b);
            }

            foreach (var bg in spec.BehaviorGroups)
            {
                BehaviorGroupPrinter.AddBehaviorGroupSpecification(document, bg);
            }

            foreach (var ps in spec.PropertySets)
            {
                PropertySetPrinter.AddPropertySetSpecification(document, ps);
            }

            foreach (var c in spec.ChildTokens)
            {
                PrintSpecification(document, c, false);
                var bbDef = body.AppendChild(new Paragraph());
                var bbRun = bbDef.AppendChild(new Run());
                bbRun.AppendChild(new Text(""));
                Utils.ApplyStyleToParagraph(document, "Normal", "Normal", bbDef, JustificationValues.Center);
            }

            if (isForAppendix)
            {
                return;
            }
            var pageBreak = body.AppendChild(new Paragraph());
            var pbr       = pageBreak.AppendChild(new Run());

            pbr.AppendChild(new Text(""));

            if (pageBreak.ParagraphProperties == null)
            {
                pageBreak.ParagraphProperties = new ParagraphProperties();
            }
            pageBreak.ParagraphProperties.PageBreakBefore = new PageBreakBefore();
            Utils.ApplyStyleToParagraph(document, "Normal", "Normal", pageBreak);
        }
コード例 #3
0
        public static void PrintDefinition(WordprocessingDocument document, TemplateDefinition definition, bool book, bool isForAppendix = false)
        {
            ArtifactPrinter.AddArtifactContent(document, definition.Artifact, book, isForAppendix);
            _log.Info("Printing Template Definition Properties: " + definition.Artifact.Name);
            var body = document.MainDocumentPart.Document.Body;

            var aDef  = body.AppendChild(new Paragraph());
            var adRun = aDef.AppendChild(new Run());

            adRun.AppendChild(new Text("Template Definition"));
            Utils.ApplyStyleToParagraph(document, "Heading1", "Heading1", aDef, JustificationValues.Center);

            var tDef = body.AppendChild(new Paragraph());
            var tRun = tDef.AppendChild(new Run());

            var formulaName =
                Utils.GetNameForId(definition.FormulaReference.Id, ArtifactType.TemplateFormula);

            tRun.AppendChild(new Text("Template Formula Reference: " + formulaName));
            Utils.ApplyStyleToParagraph(document, "Heading2", "Heading2", tDef);

            ArtifactPrinter.AddArtifactReference(document, definition.FormulaReference);

            BasePrinter.AddBaseReference(document, definition.TokenBase);

            var beDef = body.AppendChild(new Paragraph());
            var beRun = beDef.AppendChild(new Run());

            beRun.AppendChild(new Text("Behaviors"));
            Utils.ApplyStyleToParagraph(document, "Heading1", "Heading1", beDef, JustificationValues.Center);
            foreach (var b in definition.Behaviors)
            {
                BehaviorPrinter.AddBehaviorReferenceProperties(document, b);
                var bbDef = body.AppendChild(new Paragraph());
                var bbRun = bbDef.AppendChild(new Run());
                bbRun.AppendChild(new Text(""));
                Utils.ApplyStyleToParagraph(document, "Normal", "Normal", bbDef, JustificationValues.Center);
            }

            var bgDef = body.AppendChild(new Paragraph());
            var bgRun = bgDef.AppendChild(new Run());

            bgRun.AppendChild(new Text("Behavior Groups"));
            Utils.ApplyStyleToParagraph(document, "Heading2", "Heading2", bgDef, JustificationValues.Center);
            foreach (var bg in definition.BehaviorGroups)
            {
                ArtifactPrinter.AddArtifactReference(document, bg.Reference);
                foreach (var b in bg.BehaviorArtifacts)
                {
                    var bbeDef = body.AppendChild(new Paragraph());
                    var bbeRun = bbeDef.AppendChild(new Run());
                    bbeRun.AppendChild(new Text("Behavior"));
                    Utils.ApplyStyleToParagraph(document, "Heading2", "Heading2", bbeDef);

                    BehaviorPrinter.AddBehaviorReferenceProperties(document, b);
                }
            }

            var pDef = body.AppendChild(new Paragraph());
            var pRun = pDef.AppendChild(new Run());

            pRun.AppendChild(new Text("Property Sets"));
            Utils.ApplyStyleToParagraph(document, "Heading2", "Heading2", pDef, JustificationValues.Center);
            foreach (var p in definition.PropertySets)
            {
                ArtifactPrinter.AddArtifactReference(document, p.Reference);
                var bbDef = body.AppendChild(new Paragraph());
                var bbRun = bbDef.AppendChild(new Run());
                bbRun.AppendChild(new Text(""));
                Utils.ApplyStyleToParagraph(document, "Heading2", "Heading2", bbDef, JustificationValues.Center);
                CommonPrinter.BuildPropertiesTable(document, p.Properties, false);
            }

            var cDef = body.AppendChild(new Paragraph());
            var cRun = cDef.AppendChild(new Run());

            cRun.AppendChild(new Text("Child Tokens"));
            Utils.ApplyStyleToParagraph(document, "Heading2", "Heading2", cDef, JustificationValues.Center);
            foreach (var c in definition.ChildTokens)
            {
                PrintDefinition(document, c, false);
                Utils.InsertSpacer(document);
            }

            if (!book)
            {
                return;
            }
            var pageBreak = body.AppendChild(new Paragraph());
            var pbr       = pageBreak.AppendChild(new Run());

            pbr.AppendChild(new Text(""));

            if (pageBreak.ParagraphProperties == null)
            {
                pageBreak.ParagraphProperties = new ParagraphProperties();
            }

            pageBreak.ParagraphProperties.PageBreakBefore = new PageBreakBefore();
            Utils.ApplyStyleToParagraph(document, "Normal", "Normal", pageBreak);
        }