Пример #1
0
        public override Stream Render(IDataSource dataSource)
        {
            // If we have not written anything _yet_ to the Stream, we will
            // be writing a complete page with this call.
            if (Writer.BaseStream.Position == 0)
            {
                return(RenderPage(dataSource));
            }

            XhtmlTextWriter xhtmlWriter = new XhtmlTextWriter(Writer);

            xhtmlWriter.Indent = 3;

            // Flush writer contents to output.
            xhtmlWriter.Flush();

            // Emit Core of Page
            HTMLReportView <RenderType> view = new HTMLReportView <RenderType>(Writer);

            view.Text = Text;
            view.Render(dataSource);

            // Flush writer contents to output.
            xhtmlWriter.Flush();

            return(Writer.BaseStream);
        }
Пример #2
0
        public virtual Stream Render(IEnumerable dataSource)
        {
            XhtmlTextWriter xhtmlWriter = new XhtmlTextWriter(_writer);

            //-----------------------------------------------------------------
            // If the 'Renderer' supports the ITextControl interface, we will
            // defer rendering of the 'Text' block to it. The assignment needs
            // to take place before 'DataBind' so the 'Renderer' can act
            // on the Text. (Maybe a token substitution will happen, perhaps!)
            //-----------------------------------------------------------------
            ITextControl _textControl = Renderer as ITextControl;

            if (_textControl != null)
            {
                _textControl.Text = Text;
            }

            // Bind the Data to the Renderer
            Renderer.DataSource = dataSource;
            Renderer.DataBind();

            xhtmlWriter.Flush();

            // Render unto the Stream that which belongs to the Stream...
            Renderer.RenderControl(xhtmlWriter);

            xhtmlWriter.Flush();

            return(_writer.BaseStream);
        }
Пример #3
0
        public Stream RenderPageEnd()
        {
            XhtmlTextWriter xhtmlWriter = new XhtmlTextWriter(Writer);

            xhtmlWriter.Indent = 3;

            // Flush writer contents to output.
            xhtmlWriter.Flush();

            if (ReportFooter != null && ReportFooter.Length > 0)
            {
                xhtmlWriter.RenderBeginTag("hr");
                xhtmlWriter.WriteEndTag("hr");

                //
                xhtmlWriter.AddAttribute("class", "footer");
                xhtmlWriter.RenderBeginTag("div");

                xhtmlWriter.Write(ReportFooter);
                xhtmlWriter.WriteEndTag("div");

                xhtmlWriter.RenderBeginTag("hr");
                xhtmlWriter.WriteEndTag("hr");

                xhtmlWriter.WriteLine(Writer.NewLine);
                // </h2>
            }
            //--------------------------------------------------------
            // No matter what state the Renderer left us in, close
            // off the <body> and <html> elements.
            //--------------------------------------------------------

            // </body>
            xhtmlWriter.WriteEndTag("body");

            // </html>
            xhtmlWriter.WriteEndTag("html");

            // Flush writer contents to output.
            xhtmlWriter.Flush();

            return(Writer.BaseStream);
        }
Пример #4
0
        public virtual Stream Render(IDataSource dataSource)
        {
            XhtmlTextWriter xhtmlWriter = new XhtmlTextWriter(_writer);

            // <div class='core'>
            xhtmlWriter.AddAttribute("class", "core");
            xhtmlWriter.RenderBeginTag("div");
            xhtmlWriter.WriteLine(Writer.NewLine);


            //-----------------------------------------------------------------
            // If the 'Renderer' supports the ITextControl interface, we will
            // defer rendering of the 'Text' block to it. The assignment needs
            // to take place before 'DataBind' so the 'Renderer' can act
            // on the Text. (Maybe a token substitution will happen, perhaps!)
            //-----------------------------------------------------------------
            ITextControl _textControl = Renderer as ITextControl;

            if (_textControl != null)
            {
                _textControl.Text = Text;
            }

            // Bind the Data to the Renderer
            if (dataSource != null)
            {
                Renderer.DataSource = dataSource;
                Renderer.DataBind();
            }

            xhtmlWriter.Flush();

            // Render unto the Stream that which belongs to the Stream...
            Renderer.ID = ID;
            Renderer.RenderControl(xhtmlWriter);

            // </div>
            xhtmlWriter.WriteEndTag("div");

            xhtmlWriter.Flush();

            return(_writer.BaseStream);
        }
Пример #5
0
        public Stream RenderPage(IDataSource dataSource)
        {
            RenderPageBegin();

            XhtmlTextWriter xhtmlWriter = new XhtmlTextWriter(Writer);

            xhtmlWriter.Indent = 3;

            // Flush writer contents to output.
            xhtmlWriter.Flush();

            // Emit Core of Page
            HTMLReportView <RenderType> view = new HTMLReportView <RenderType>(Writer);

            view.Text = Text;
            view.Render(dataSource);

            RenderPageEnd();

            // Flush writer contents to output.
            xhtmlWriter.Flush();

            return(Writer.BaseStream);
        }
Пример #6
0
        /// <summary>
        /// Visit XHTMLElement and write it to stream
        /// </summary>
        /// <param name="element">Element to visit</param>
        public void Visit(XHTMLElement element)
        {
            if (element.GetTag() == "cdata")
            {   //CData need different handling
                WriteCData(element);
            }
            else if (element.GetTag() == "comment")
            {   //Write comment
                WriteComment(element);
            }
            else
            {   //Normal XHTML tag handling
                XhtmlWriter.BeginRender();

                //Check if element is tag, if not write tag, otherwise handle as XHTML tag
                if (!element.GetTagState())
                {
                    XhtmlWriter.BeginRender();

                    //Get escape chars out of this tag
                    CharIterator charIterator = new CharIterator();
                    String       tag          = charIterator.ParseText(element.GetTag());
                    XhtmlWriter.Write(tag);
                    XhtmlWriter.EndRender();
                    XhtmlWriter.Flush();
                    return;
                }

                XhtmlWriter.WriteBeginTag(element.GetTag());
                foreach (KeyValuePair <String, String> pair in element.GetAttributes())
                {
                    XhtmlWriter.WriteAttribute(pair.Key, pair.Value, false);
                }

                if (IsEmptyElement(element))
                {   //Nothing inside element, so write tag end
                    XhtmlWriter.Write(XhtmlTextWriter.SelfClosingTagEnd);
                }
                else if (IsXHTMLTag(element.GetTag()))
                {
                    //Write tag opening closing
                    XhtmlWriter.Write(XhtmlTextWriter.TagRightChar);

                    //Write content
                    XhtmlWriter.Write(element.GetContent());

                    //Visit children
                    foreach (XHTMLElement child in element.GetChildren())
                    {
                        Visit(child);
                    }

                    //Write closing tag
                    XhtmlWriter.WriteEndTag(element.GetTag());
                    XhtmlWriter.Flush();
                }
                else
                {
                    //Just write it
                    XhtmlWriter.Write(element.GetTag());
                    XhtmlWriter.EndRender();
                    XhtmlWriter.Flush();
                }
            }
        }
Пример #7
0
        public Stream RenderPageBegin()
        {
            XhtmlTextWriter xhtmlWriter = new XhtmlTextWriter(Writer);

            xhtmlWriter.Indent = 3;

            xhtmlWriter.AddAttribute("xmlns", "http://www.w3.org/1999/xhtml");
            xhtmlWriter.RenderBeginTag("html");

            xhtmlWriter.RenderBeginTag("head");
            if (ReportHeading != null && ReportHeading.Length > 0)
            {
                xhtmlWriter.RenderBeginTag("title");
                xhtmlWriter.Write(ReportHeading);
                xhtmlWriter.WriteEndTag("title");
            }

            // <style type='text/css'>
            xhtmlWriter.WriteLine(Writer.NewLine);
            xhtmlWriter.AddAttribute(HtmlTextWriterAttribute.Type, "text/css");
            xhtmlWriter.RenderBeginTag("style");
            foreach (var style in _styles)
            {
                xhtmlWriter.WriteLine(style.Key);
                xhtmlWriter.WriteLine("{");
                xhtmlWriter.WriteLine(style.Value);
                xhtmlWriter.WriteLine("}");
            }
            xhtmlWriter.WriteEndTag("style");
            xhtmlWriter.WriteLine(Writer.NewLine);
            // </style>

            xhtmlWriter.WriteEndTag("head");

            // <body>
            xhtmlWriter.RenderBeginTag("body");

            if (ReportHeading != null && ReportHeading.Length > 0)
            {
                // <h2 class='heading'>
                xhtmlWriter.AddAttribute("class", "heading");
                xhtmlWriter.RenderBeginTag("h2");
                xhtmlWriter.Write(ReportHeading);
                xhtmlWriter.WriteEndTag("h2");
                xhtmlWriter.WriteLine(Writer.NewLine);
                // </h2>
            }

            if (!(Renderer is ITextControl) && Text != null && Text.Length > 0)
            {
                // <p class='text'>
                xhtmlWriter.AddAttribute("class", "caption");
                xhtmlWriter.RenderBeginTag("p");
                xhtmlWriter.Write(Text);
                xhtmlWriter.WriteEndTag("p");
                xhtmlWriter.WriteLine(Writer.NewLine);
                // </p>
            }

            // Flush writer contents to output.
            xhtmlWriter.Flush();

            return(Writer.BaseStream);
        }