using System;

using System.Collections.Generic;

using System.Text;

using OpenNETCF.Web.UI;

using OpenNETCF.Web.Html;

using OpenNETCF.Web.Html.Meta;

using OpenNETCF.WindowsCE;

 

namespace SampleSite

{

    public class SystemInfo : Page

    {

        protected override void Page_Load(object sender, EventArgs e)

        {

            int et = Environment.TickCount;

 

            // create the document

            Document doc = new Document();

 

            // add a header to the document

            doc.Head = new DocumentHead("Padarn Server System Info", new StyleInfo("css/SampleSite.css"));

 

            // have the page refresh every 5 seconds

            doc.Head.MetaTags.Add(new Refresh(5));

 

            // set up any document-wide styles that won't come from the CSS

            DocumentStyle centerBodyTextStyle = new DocumentStyle("body");

            centerBodyTextStyle.Styles.Add(new ElementStyle("text-align", "center"));

            doc.Styles.Add(centerBodyTextStyle);

 

            Utility.AddPadarnHeaderToDocument(doc, true, "SystemInfo");

 

            DocumentStyle divTRStyle = new DocumentStyle("div.tr");

            divTRStyle.Styles.Add(new ElementStyle("text-align", "left"));

            divTRStyle.Styles.Add(new ElementStyle("color", "Navy"));

 

            DocumentStyle divTHStyle = new DocumentStyle("div.th");

            divTHStyle.Styles.Add(new ElementStyle("text-align", "left"));

            divTHStyle.Styles.Add(new ElementStyle("color", "Navy"));

 

            DocumentStyle divTDStyle = new DocumentStyle("div.td");

            divTDStyle.Styles.Add(new ElementStyle("text-align", "left"));

            divTDStyle.Styles.Add(new ElementStyle("color", "Navy"));

           

            doc.Styles.Add(divTRStyle);

            doc.Styles.Add(divTHStyle);

            doc.Styles.Add(divTDStyle);

 

            // fill the body

            #region --- SystemInfo field set

            // <div class="table">

            Div infoTableDiv = new Div("infoTableDiv", "table");

 

            // <fieldset>

            // <legend>System Information</legend>

            FieldSet fieldset = new FieldSet("System Information");

 

            //    <div class="tr">

            //          <div class="th wide">CLR Version:</div>

            //      <div class="td narrow left">{Environment.Version}</div>

            //    </div>

            Div clrVersion = new Div("clrVersion", "tr");

            Div clrVersionString = new Div("clrVersionString", "th wide");

            clrVersionString.Elements.Add(new RawText("CLR Version:"));

            clrVersion.Elements.Add(clrVersionString);

            Div clrVersionData = new Div("clrVersionData", "td wide");

            clrVersionData.Elements.Add(new RawText(Environment.Version.ToString(4)));

            clrVersion.Elements.Add(clrVersionData);

 

            fieldset.Elements.Add(clrVersion);

 

            //    <div class="tr">

            //          <div class="th wide">OS Version: </div>");

            //      <div class="td narrow left">{Environment.OSVersion}</div>

            //    </div>

            Div osVersion = new Div("osVersion", "tr");

            Div osVersionString = new Div("osVersionString", "th wide");

            osVersionString.Elements.Add(new RawText("OS Version:"));

            osVersion.Elements.Add(osVersionString);

            Div osVersionData = new Div("osVersionData", "td wide");

            osVersionData.Elements.Add(new RawText(Environment.OSVersion.ToString()));

            osVersion.Elements.Add(osVersionData);

 

            fieldset.Elements.Add(osVersion);

 

            // <div class="tr">

            // <div class="th wide">CPU Architecture: </div>

            // <div class="td narrow left">{ProcessorArchitecture}</div>

            // </div>

            OpenNETCF.WindowsCE.SystemInfo si = new OpenNETCF.WindowsCE.SystemInfo();

            Div processor = new Div("processor", "tr");

            Div processorString = new Div("processorString", "th wide");

            processorString.Elements.Add(new RawText("CPU Architecture:"));

            processor.Elements.Add(processorString);

            Div processorData = new Div("processorData", "td wide");

            processorData.Elements.Add(new RawText(si.ProcessorArchitecture.ToString()));

            processor.Elements.Add(processorData);

 

            fieldset.Elements.Add(processor);

 

            // <div class="tr">

            // <div class="th wide">Available Phys. Memory: </div>

            // <div class="td narrow left">{AvailablePhysicalMemory}</div>

            // </div>

            Div memory = new Div("memory", "tr");

            Div memoryString = new Div("memoryString", "th wide");

            memoryString.Elements.Add(new RawText("Available Phys. Memory:"));

            memory.Elements.Add(memoryString);

            Div memoryData = new Div("memoryData", "td wide");

            memoryData.Elements.Add(new RawText(MemoryManagement.AvailablePhysicalMemory.ToString("#,###,### bytes")));

            memory.Elements.Add(memoryData);

 

            fieldset.Elements.Add(memory);

 

            // <div class="tr">

            // <div class="th wide">Memory Load:</div>

            // <div class="td narrow left">{MemoryLoad}%</div>

            // </div>

            Div memoryLoad = new Div("memoryLoad", "tr");

            Div memoryLoadString = new Div("memoryLoadString", "th wide");

            memoryLoadString.Elements.Add(new RawText("Memory Load:"));

            memoryLoad.Elements.Add(memoryLoadString);

            Div memoryLoadData = new Div("memoryLoadData", "td wide");

            memoryLoadData.Elements.Add(new RawText(string.Format("{0}%", MemoryManagement.MemoryLoad)));

            memoryLoad.Elements.Add(memoryLoadData);

 

            fieldset.Elements.Add(memoryLoad);

 

            infoTableDiv.Elements.Add(fieldset);

            doc.Body.Elements.Add(infoTableDiv);

            #endregion

 

            #region --- load time ---

            et = Environment.TickCount - et;

 

            Paragraph loadTimeParagraph = new Paragraph(string.Format("Page loaded in {0:0.000} sec", (float)((float)et / 1000f)));

 

            // some elements allow setting element-specific styles

            loadTimeParagraph.Styles.Add(new ElementStyle("font-size", "10px"));

            loadTimeParagraph.Styles.Add(new ElementStyle("text-align", "center"));

            doc.Body.Elements.Add(loadTimeParagraph);

            #endregion

 

            // send the document html to the Response object

            Response.Write(doc.OuterHtml);

 

            // flush

            Response.Flush();

        }

    }

}