ReportXHTML.cs :  » Game » SokoSolve-Sokoban » SokoSolve » Core » Reporting » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Game » SokoSolve Sokoban 
SokoSolve Sokoban » SokoSolve » Core » Reporting » ReportXHTML.cs
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Xml;
using SokoSolve.Common;

namespace SokoSolve.Core.Reporting{
    /// <summary>
    /// An XHTML Helper class to make well-formed simpleXHTML content
    /// </summary>
    public class ReportXHTML
    {
        protected XmlDocument report;
        private XmlElement xmlHEAD;

       

        public ReportXHTML(string title)
        {

            report = new XmlDocument();
            XmlElement xmlHTML = report.CreateElement("html");
            xmlHTML.SetAttribute("xmlns", "http://www.w3.org/1999/xhtml");
            report.AppendChild(xmlHTML);

            xmlHEAD = report.CreateElement("head");
            xmlHTML.AppendChild(xmlHEAD);

            XmlElement xmlTITLE = report.CreateElement("title");
            xmlTITLE.InnerText = title;
            xmlHEAD.AppendChild(xmlTITLE);

            xmlLINK = report.CreateElement("link");
            xmlLINK.SetAttribute("type", "text/css");
            xmlLINK.SetAttribute("rel", "Stylesheet");
            xmlLINK.SetAttribute("href", "style.css");
            xmlHEAD.AppendChild(xmlLINK);

            xmlSTYLE = report.CreateElement("style");
            xmlSTYLE.SetAttribute("type", "text/css");
            xmlHEAD.AppendChild(xmlSTYLE);

            xmlBODY = report.CreateElement("body");
            xmlHTML.AppendChild(xmlBODY);

            xmlBODYBODY = report.CreateElement("div");
            xmlBODY.AppendChild(xmlBODYBODY);

            xmlFOOTER = report.CreateElement("div");
            xmlFOOTER.SetAttribute("class", "footer");
            xmlBODY.AppendChild(xmlFOOTER);

        }

        XmlElement xmlBODY;
        XmlElement xmlBODYBODY;
        XmlElement xmlFOOTER;
        XmlElement xmlSTYLE;
        XmlElement xmlLINK;

        public void Add(XmlElement addInBody)
        {
            xmlBODYBODY.AppendChild(addInBody);
        }

        public void Add(string addInBody)
        {
            XmlElement xml = report.CreateElement("div");
            xml.InnerXml = addInBody;
            Add(xml);
        }

        public XmlElement Body
        {
            get { return xmlBODYBODY; }
        }

        public void SetCSSLink(string linkURL)
        {
            xmlLINK.SetAttribute("href", linkURL);
            xmlHEAD.RemoveChild(xmlSTYLE);
        }

        public void SetCSSInline(string fileName)
        {
            xmlSTYLE.InnerText = File.ReadAllText(fileName);
            xmlHEAD.RemoveChild(xmlLINK);
        }

        public void AddFooter()
        {

            string html =
                string.Format(
@"Produced by <a href=""http://sokosolve.sourceforge.net"">SokoSolve Sokoban</a> version {0}<br/>
<a href=""http://sourceforge.net""> 
    <img src=""http://sourceforge.net/sflogo.php?group_id=85742&amp;type=5"" width=""210"" height=""62""  alt=""SourceForge.net Logo"" />
</a>", ProgramVersion.VersionString);

            xmlFOOTER.InnerXml = html;


        }

        public XmlElement CreateContentTag(string tagName, string innerText)
        {
            XmlElement xml = report.CreateElement(tagName);
            xml.InnerText = innerText;
            return xml;
        }

        public virtual void Save(string filename)
        {


            report.Save(filename);
        }

        public override string ToString()
        {
            return report.OuterXml;
        }
    }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.