예제 #1
0
파일: Renderer.cs 프로젝트: Sl0vi/MigraDoc
        /// <summary>
        /// Creates a fitting renderer for the render info to render and layout with.
        /// </summary>
        /// <param name="gfx">The XGraphics object to render on.</param>
        /// <param name="documentRenderer">The document renderer.</param>
        /// <param name="renderInfo">The RenderInfo object stored after a previous call of Format().</param>
        /// <param name="fieldInfos">The field infos.</param>
        /// <returns>The fitting Renderer.</returns>
        internal static Renderer Create(XGraphics gfx, DocumentRenderer documentRenderer, RenderInfo renderInfo, FieldInfos fieldInfos)
        {
            Renderer renderer = null;

            if (renderInfo.DocumentObject is Paragraph)
                renderer = new ParagraphRenderer(gfx, renderInfo, fieldInfos);
            else if (renderInfo.DocumentObject is Table)
                renderer = new TableRenderer(gfx, renderInfo, fieldInfos);
            else if (renderInfo.DocumentObject is PageBreak)
                renderer = new PageBreakRenderer(gfx, renderInfo, fieldInfos);
            else if (renderInfo.DocumentObject is TextFrame)
                renderer = new TextFrameRenderer(gfx, renderInfo, fieldInfos);
            else if (renderInfo.DocumentObject is Chart)
                renderer = new ChartRenderer(gfx, renderInfo, fieldInfos);
            //else if (renderInfo.DocumentObject is Chart)
            //  renderer = new ChartRenderer(gfx, renderInfo, fieldInfos);
            else if (renderInfo.DocumentObject is Image)
                renderer = new ImageRenderer(gfx, renderInfo, fieldInfos);

            if (renderer != null)
                renderer._documentRenderer = documentRenderer;

            return renderer;
        }
예제 #2
0
        /// <summary>
        /// Creates a fitting renderer for the given document object for formatting.
        /// </summary>
        /// <param name="gfx">The XGraphics object to do measurements on.</param>
        /// <param name="documentRenderer">The document renderer.</param>
        /// <param name="documentObject">the document object to format.</param>
        /// <param name="fieldInfos">The field infos.</param>
        /// <returns>The fitting Renderer.</returns>
        internal static Renderer Create(XGraphics gfx, DocumentRenderer documentRenderer, DocumentObject documentObject, FieldInfos fieldInfos)
        {
            Renderer renderer = null;
            if (documentObject is Paragraph)
                renderer = new ParagraphRenderer(gfx, (Paragraph)documentObject, fieldInfos);
            else if (documentObject is Table)
                renderer = new TableRenderer(gfx, (Table)documentObject, fieldInfos);
            else if (documentObject is PageBreak)
                renderer = new PageBreakRenderer(gfx, (PageBreak)documentObject, fieldInfos);
            else if (documentObject is TextFrame)
                renderer = new TextFrameRenderer(gfx, (TextFrame)documentObject, fieldInfos);
            else if (documentObject is Chart)
                renderer = new ChartRenderer(gfx, (Chart)documentObject, fieldInfos);
            else if (documentObject is Image)
                renderer = new ImageRenderer(gfx, (Image)documentObject, fieldInfos);
            else if (documentObject is Barcode)
                renderer = new BarcodeRenderer(gfx, (Barcode)documentObject, fieldInfos);

            if (renderer != null)
                renderer.documentRenderer = documentRenderer;

            return renderer;
        }