Xsemmel/PrintEngine/Printing.cs
/// <summary>
/// Converts a TextDocument to Block.
/// </summary>
Converts a TextDocument to Block.
Converts a TextDocument to Block .
static Block ConvertTextDocumentToBlock(TextDocument document, IHighlighter highlighter)
        {
            if (document == null)
                throw new ArgumentNullException("document");
            Paragraph p = new Paragraph();
            foreach (DocumentLine line in document.Lines)
            {
                int lineNumber = line.LineNumber;
                HighlightedInlineBuilder inlineBuilder = new HighlightedInlineBuilder(document.GetText(line));
                if (highlighter != null)
                {
                    HighlightedLine highlightedLine = highlighter.HighlightLine(lineNumber);
                    int lineStartOffset = line.Offset;
                    foreach (HighlightedSection section in highlightedLine.Sections)
                        inlineBuilder.SetHighlighting(section.Offset - lineStartOffset, section.Length, section.Color);
                }
                p.Inlines.AddRange(inlineBuilder.CreateRuns());
                p.Inlines.Add(new LineBreak());
            }
            return p;
        }
static Block ConvertTextDocumentToBlock ( TextDocument document , IHighlighter highlighter ) { if ( document == null ) throw new ArgumentNullException ( " " ) ; Paragraph p = new Paragraph ( ) ; foreach ( DocumentLine line in document . Lines ) { int lineNumber = line . LineNumber ; HighlightedInlineBuilder inlineBuilder = new HighlightedInlineBuilder ( document . GetText ( line ) ) ; if ( highlighter != null ) { HighlightedLine highlightedLine = highlighter . HighlightLine ( lineNumber ) ; int lineStartOffset = line . Offset ; foreach ( HighlightedSection section in highlightedLine . Sections ) inlineBuilder . SetHighlighting ( section . Offset - lineStartOffset , section . Length , section . Color ) ; } p . Inlines . AddRange ( inlineBuilder . CreateRuns ( ) ) ; p . Inlines . Add ( new LineBreak ( ) ) ; } return p ; }
Converts a TextDocument to Block.
Converts a TextDocument to Block .
// ref.:  http://community.sharpdevelop.net/forums/t/12012.aspx
document
TextDocument
highlighter
IHighlighter