public void TestFlowDocGen() { DocLexElement.JumpPositions = new List<int>(); FlowDocGenerator gen = new FlowDocGenerator(); List<DocLexElement> lexes = new List<DocLexElement>(); lexes.Add(new DocLexElement(DocLexElement.LexTypeEnum.word, text: "Hallo", spcCount: 1)); lexes.Add(new DocLexElement(DocLexElement.LexTypeEnum.bold)); lexes.Add(new DocLexElement(DocLexElement.LexTypeEnum.word, text:"fett")); lexes.Add(new DocLexElement(DocLexElement.LexTypeEnum.bold)); lexes.Add(new DocLexElement(DocLexElement.LexTypeEnum.parabreak)); string answ = gen.ProduceDoc(lexes); Assert.IsTrue(answ.StartsWith("<FlowDocument")); Assert.IsTrue(answ.Contains("Hallo <Bold>fett</Bold>")); Assert.IsTrue(answ.EndsWith("</FlowDocument>")); }
/// <summary> /// Das FlowDocument aus dem Markup-Text aufbauen /// </summary> /// <param name="text">Text in Markup-Form</param> /// <returns>Test als FlowDocument formatiert</returns> public string FormatDocument(string text) { MarkDownLexicalAnalyzer ana = new MarkDownLexicalAnalyzer(text + "\n\n"); List<DocLexElement> lex = ana.GetDocLexList(); FlowDocGenerator fdg = new FlowDocGenerator(); fdg.DocumentFontFamily = DocumentFontFamily; fdg.DocumentNormalFontSize = DocumentNormalFontSize; fdg.DocumentHeadline1FontSize = DocumentHeadline1FontSize; fdg.DocumentHeadline2FontSize = DocumentHeadline2FontSize; fdg.DocumentHeadline3FontSize = DocumentHeadline3FontSize; fdg.DocumentHeadline4FontSize = DocumentHeadline4FontSize; fdg.DocumentHeadline5FontSize = DocumentHeadline5FontSize; fdg.CodingFontSize = CodingFontSize; fdg.CodingFontFamily = CodingFontFamily; fdg.TextAlignment = TextAlignment; fdg.HeadingTextAlignment = HeadingTextAlignment; return fdg.ProduceDoc(lex); }