Exemplo n.º 1
0
        public FlowDocument DebugDocument(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;

            FlowDocument doc = null;
            try
            {
                string xamlstr = fdg.DebugDoc(text, lex);
                doc = LoadXaml(xamlstr);
            }
            catch (Exception exc)
            {
                throw new DocFormatException(exc.Message);
            }

            return doc;
        }
        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>"));
        }
Exemplo n.º 3
0
        /// <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);
        }