Program.cs 2.12 KB
Newer Older
Uwe Wienkop's avatar
Uwe Wienkop committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
using HTML;

class Program
{
    // Test program for HTML generation:

    static void Main()
    {
        // Generate HTML document and store result in string:

        string html = Engine.Generate
        (
          new DocumentType(),

          new Html
          (
            new Head
            (
              new Title("Generated HTML Example")
            ),

            new Body
            (
              new Heading("Welcome to the Technical University of Nuremberg"),

              new Paragraph
              (
                "We have a ", new Italic("distinct profile"), " and strive to maintain our ", new Italic("leading position"), " among comparable universities."
              ),

              new Heading("Study for your future"),

              new Paragraph
              (
                12, " departments provide more than ", 40, " degree programs in ", new Bold("engineering, business, design and social sciences."),
                new LineBreak(),
                "If you have questions, please contact the ", new Italic("Student Counseling Service"), " or the ", new Italic("Student Office.")
              )
            )
          )
        );

        // Write resulting HTML string:

        System.Console.WriteLine("GENERATED HTML DOCUMENT:");

        System.Console.WriteLine(html);

        System.Console.ReadKey(true);

        /*
          // Write reformatted HTML string:

          System.Console.WriteLine("\nREFORMATTED HTML DOCUMENT:");

          System.Console.WriteLine("\n<" + new DocumentType().TagId + ">\n" + System.Xml.Linq.XElement.Parse(html.Replace("\n", "")));

          System.Console.ReadKey(true);
        */

        // Show (original) HTML string in default browser:

        System.Console.WriteLine("\nSTARTING BROWSER WITH GENERATED DOCUMENT...");

        System.IO.File.WriteAllText("Example.html", html);

Uwe Wienkop's avatar
Uwe Wienkop committed
67 68 69
        System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo("Example.html");
        startInfo.UseShellExecute = true;
        System.Diagnostics.Process.Start(startInfo);
Uwe Wienkop's avatar
Uwe Wienkop committed
70
        //System.Diagnostics.Process.Start("Example.html");
Uwe Wienkop's avatar
Uwe Wienkop committed
71 72 73
    }
}