content.aspx.cs
using System;
using System.Collections.Generic;
using System.Web.UI.WebControls;

namespace ExWeb
{
    public partial class Content : System.Web.UI.Page
    {
        TreeNode GetTreeNode(string Text, string ix, int Index, string NavigateUrl)
        {
            TreeNode tn;
            tn = new TreeNode(Text, Index.ToString(), "", NavigateUrl, "");
            if (ix == Index.ToString()) tn.Selected = true;
            return tn;
        }
        List<string> SourceCodeToShow = new List<string>();
        void AddSourceCodeToList(string SourceCode)
        {
            SourceCodeToShow.Add(SourceCode);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Treeview_ExWeb.Nodes.Add(GetTreeNodeWebs("Layouts", WebPakete));
                Treeview_ExWeb.Nodes.Add(GetTreeNodeDoc());
                Treeview_ExWeb.Nodes.Add(GetTreeNodeModules());
                Treeview_ExWeb.CollapseAll();
            }
        }
        protected TreeNode GetDoc(string Title, string Directory, bool Source, bool Links, bool Images)
        {
            int Index = 0;
            TreeNode tn;
            if (Source)
                tn = GetTreeNode(Title, "0", Index, "~/Mod.aspx?mod=directory&mode=high&pat=" + Directory + "&recursive=0&showfile=code&link=inline&src=1");
            else
                tn = GetTreeNode(Title, "0", Index, "");
            if (Links) tn.ChildNodes.Add(GetTreeNode("Link", "0", Index, "~/Mod.aspx?mod=directory&pat=" + Directory + "&recursive=0&showfile=web&link=frame"));
            if (Images) tn.ChildNodes.Add(GetTreeNode("Image", "0", Index, "~/Mod.aspx?mod=directory&pat=" + Directory + "&recursive=0&showfile=image&link=inline"));
            return tn;
        }

        protected TreeNode GetTreeNodeDoc()
        {
            int Index = 0;
            TreeNode tn_root = GetTreeNode("Dokumentation", "0", Index++, "~/Mod.aspx?mod=directory&pat=/documentation/&recursive=0&showfile=web&link=inline&noext=1");
            tn_root.ChildNodes.Add(GetTreeNodeWebs("Webs-Demo", WebDemos));
            tn_root.ChildNodes.Add(GetTreeNodeProg());
            tn_root.ChildNodes.Add(GetDoc("Dokumentation-Sources", "/documentation", true, false, false));
            return tn_root;
        }
        protected TreeNode GetTreeNodeProg()
        {
            int Index = 0;
            TreeNode tn_root = GetDoc("Programmdateien", "/", true, false, false);
            tn_root.ChildNodes.Add(GetDoc("StyleSheets", "/css/", true, false, false));
            tn_root.ChildNodes.Add(GetDoc("JavaScript", "/js/", true, false, false));
            tn_root.ChildNodes.Add(GetDoc("SyntaxH", "/sh/", true, true, false));
            tn_root.ChildNodes.Add(GetDoc("SyntaxH/script", "/sh/scripts/", true, false, false));
            tn_root.ChildNodes.Add(GetDoc("SyntaxH/tests/brushes", "/sh/tests/brushes/", true, false, false));
            tn_root.ChildNodes.Add(GetDoc("SyntaxH/tests/cases", "/sh/tests/cases/", true, true, false));
            tn_root.ChildNodes.Add(GetDoc("SyntaxH/tests/js", "/sh/tests/js/", true, false, false));
            tn_root.ChildNodes.Add(GetDoc("Image", "/images/", false, false, true));
            tn_root.ChildNodes.Add(GetDoc("Image/examples", "/images/examples/", false, false, true));
            tn_root.ChildNodes.Add(GetDoc("Testfolder", "/testfolder/", true, true, true));
            return tn_root;
        }
        protected TreeNode GetTreeNodeWebs(string WebName, string[][] WebAdresse)
        {
            int Index = 0;
            TreeNode tn_root = GetTreeNode(WebName, "0", Index++, "~/Layouts.aspx");
            TreeNode tn_sub;
            List<string> FileList = new List<string>();
            for (int i = 0; i < WebAdresse.Length; i++)
            {
                tn_sub = GetTreeNode(WebAdresse[i][0], "0", Index, WebAdresse[i][1] + WebAdresse[i][2]);
                tn_sub.ChildNodes.Add(GetTreeNode("Source", "0", Index, "~/Mod.aspx?mod=directory&pat=" + WebAdresse[i][1] + "&showfile=code&recursive=1&link=inline&src=1"));
                tn_sub.ChildNodes.Add(GetTreeNode("Image", "0", Index, "~/Mod.aspx?mod=directory&pat=" + WebAdresse[i][1] + "&showfile=image&recursive=1&link=inline"));
                tn_sub.ChildNodes.Add(GetTreeNode("Link", "0", Index, "~/Mod.aspx?mod=directory&pat=" + WebAdresse[i][1] + "&showfile=web&recursive=1&link=frame"));
                string DownloadDirectory = WebAdresse[i][1];
                if (DownloadDirectory.EndsWith("/")) DownloadDirectory = DownloadDirectory.Substring(0, DownloadDirectory.Length - 1);
                DownloadDirectory = DownloadDirectory.Substring(0, DownloadDirectory.LastIndexOf("/"));
                tn_sub.ChildNodes.Add(GetTreeNode("Download", "0", Index, "~/Mod.aspx?mod=download&fil=" + WebAdresse[i][0] + ".zip&pat=" + DownloadDirectory + "&name=Ordner und Webpaket&description=&caption=" + WebAdresse[i][0]));
                tn_sub.ChildNodes.Add(new TreeNode("NewWin", "", "", WebAdresse[i][1] + WebAdresse[i][2],"demo"));
                tn_root.ChildNodes.Add(tn_sub);
            }
            return tn_root;
        }
        protected TreeNode GetTreeNodeModules()
        {
            int Index = 0;
            TreeNode tn_Module = GetTreeNode("Module", "0", Index, "~/mod.aspx?show=all");
            tn_Module.ChildNodes.Add(GetTreeNodeModule("--common--"));
            for (int i = 0; i < Mod_Par.Modules.Length; i++)
                tn_Module.ChildNodes.Add(GetTreeNodeModule(Mod_Par.Modules[i]));
            return tn_Module;
        }
        protected TreeNode GetTreeNodeModule(string ModuleToShow)
        {
            if (ModuleToShow == "--common--")
            {
                int Index = 0;
                string ModuleToShowEntry = ModuleToShow;
                TreeNode tn_root = GetTreeNode(ModuleToShow, "", Index, "/Mod.aspx?ix=" + Index + "&mod=common&show=doc");
                // Collect all Source-Code-Files to show
                List<string> SourceCodeToShow = Mod.GetFiles(this.Page, Mod.RelPathToMod, "Mod.*", false);
                SourceCodeToShow.Add("Mod_Tools.cs");

                // Dokumentation
                // tn_root.ChildNodes.Add(GetTreeNode("Dokumentation", "", Index, "/Mod.aspx?ix=" + Index + "&mod=common&show=doc"));
                // Index++;

                // Module-Sources
                TreeNode tn = GetTreeNode("Source", "", Index, "");
                TreeNode tn_sub;
                for (int i = 0; i < SourceCodeToShow.Count; i++)
                {
                    tn_sub = GetTreeNode(SourceCodeToShow[i], "", Index, "/Mod.aspx?ix=" + Index + "&mod=inline&mode=high&src=1&pat=" + "/Mod/&fil=" + SourceCodeToShow[i]);
                    tn.ChildNodes.Add(tn_sub);
                    Index++;
                }
                tn_root.ChildNodes.Add(tn);
                return tn_root;
            }
            else
            {
                int Index = 0;
                string ix = Request.QueryString["ix"];
                if (ix == null) ix = "";
                if (ix == "") ix = "0";
                string ModuleToShowEntry = ModuleToShow.Substring(0, 1).ToUpper() + ModuleToShow.Substring(1);
                TreeNode tn_root = GetTreeNode(ModuleToShow, ix, Index, "/Mod.aspx?ix=" + Index + "&mod=" + ModuleToShow + "&show=doc");
                // Collect all Source-Code-Files to show
                List<string> SourceCodeToShow = Mod.GetFiles(this.Page, Mod.RelPathToMod, "Mod_" + ModuleToShow + "*.*", false);
                List<string> TestSourceCodeToShow = Mod.GetFiles(this.Page, Mod.RelPathToMod_Test, "Mod_" + ModuleToShow + "*.*", false);
                List<string> TestToShow = Mod.GetFiles(this.Page, Mod.RelPathToMod_Test, "Test_" + ModuleToShow + "_*.aspx", false);

                TreeNode tn;
                TreeNode tn_sub;

                // Dokumentation
                // tn = GetTreeNode("Dokumentation", ix, Index, "/Mod.aspx?ix=" + Index + "&mod=" + ModuleToShow + "&show=doc");
                // tn_root.ChildNodes.Add(tn);
                // Index++;

                // Test
                tn = GetTreeNode("Test", ix, Index, "");
                Index++;
                for (int i = 0; i < TestToShow.Count; i++)
                {
                    string Text = TestToShow[i].Substring(ModuleToShow.Length + "Test__".Length).Replace(".aspx", "");
                    tn_sub = GetTreeNode(Text, ix, Index, "/Mod.aspx?fil=" + TestToShow[i] + "&pat=/Mod_Test/&ix=" + Index + "&show=exe" + "&mod=" + ModuleToShow);
                    tn_sub.ChildNodes.Add(GetTreeNode("Source", ix, Index, "/Mod.aspx?ix=" + Index + "&mod=inline&mode=high&pat=" + "/Mod_Test/&fil=" + TestToShow[i]));
                    tn_sub.ChildNodes.Add(GetTreeNode("Download", ix, Index, "/Mod.aspx?ix=" + Index + "&mod=download&pat=" + "/Mod_Test/&fil=" + TestToShow[i]));
                    tn.ChildNodes.Add(tn_sub);
                    Index++;
                }
                tn_root.ChildNodes.Add(tn);

                // Module-Sources
                tn = GetTreeNode("Module-Source", ix, Index, "");
                Index++;
                for (int i = 0; i < SourceCodeToShow.Count; i++)
                {
                    tn_sub = GetTreeNode(SourceCodeToShow[i], ix, Index, "/Mod.aspx?ix=" + Index + "&mod=inline&mode=high&src=1&pat=" + "/Mod/&fil=" + SourceCodeToShow[i]);
                    tn.ChildNodes.Add(tn_sub);
                    Index++;
                }
                for (int i = 0; i < TestSourceCodeToShow.Count; i++)
                {
                    tn_sub = GetTreeNode(TestSourceCodeToShow[i], ix, Index, "/Mod.aspx?ix=" + Index + "&mod=inline&mode=high&src=1&pat=" + "/Mod_Test/&fil=" + TestSourceCodeToShow[i]);
                    tn.ChildNodes.Add(tn_sub);
                    Index++;
                }
                if (ModuleToShow=="inline")
                {
                    tn_sub = GetTreeNode("Test:High", ix, Index, "/Mod.aspx?ix=" + Index + "&mod=iframe&pat=/sh/tests/&fil=syntaxhighlighter_tests.html");
                    tn.ChildNodes.Add(tn_sub);
                    tn_sub = GetTreeNode("Test:High-Themes", ix, Index, "/Mod.aspx?ix=" + Index + "&mod=iframe&pat=/sh/tests/&fil=theme_tests.html");
                    tn.ChildNodes.Add(tn_sub);
                }
                tn_root.ChildNodes.Add(tn);
                return tn_root;
            }
        }
        string[][] WebDemos = new string[][]
        {
            new string[] {"2 Site default-Prinzip", "/Web-Demos/2 Site default-Prinzip/", "default.html"},
            new string[] {"3 Seite Absatzformate", "/Web-Demos/3 Seite Absatzformate/", "1 Strukturabsätze.html"},
            new string[] {"4 Bilder Lightbox", "/Web-Demos/4 Bilder Lightbox/", "LighBoxDemo.html"},
            new string[] {"4 Bilder Lightbox2", "/Web-Demos/4 Bilder Lightbox2/", "default.html"},
            new string[] {"4 Bilder positionieren", "/Web-Demos/4 Bilder positionieren/", "default.html"},
            new string[] {"4 Bilder Tabelle", "/Web-Demos/4 Bilder Tabelle/", "default.html"},
            new string[] {"5 Sichtbarkeit", "/Web-Demos/5 Sichtbarkeit/", ""},
            new string[] {"6 Masterseiten Ausgangspunkt", "/Web-Demos/6 Masterseiten Ausgangspunkt/", "index.html"},
            new string[] {"6 Masterseiten Umgewandelt", "/Web-Demos/6 Masterseiten Umgewandelt/", "index.aspx"},
            new string[] {"6 Masterseiten Umgewandelt Module", "/Web-Demos/6 Masterseiten Umgewandelt Module/", "index.aspx"},
        };
        string[][] WebPakete = new string[][]
        {
            new string[] {"personal1", "/Web-Pakete/personal1/", "default.html"},
            new string[] {"personal2", "/Web-Pakete/personal2/", "default.html"},
            new string[] {"personal3", "/Web-Pakete/personal3/", "default.html"},
            new string[] {"personal4", "/Web-Pakete/personal4/", "default.html"},
            new string[] {"personal5", "/Web-Pakete/personal5/", "default.html"},
            new string[] {"personal6", "/Web-Pakete/personal6/", "default.html"},
            new string[] {"personal7", "/Web-Pakete/personal7/", "default.html"},
            new string[] {"smallbiz1", "/Web-Pakete/smallbiz1/", "default.html"},
            new string[] {"smallbiz2", "/Web-Pakete/smallbiz2/", "default.html"},
            new string[] {"smallbiz3", "/Web-Pakete/smallbiz3/", "default.html"},
            new string[] {"smallbiz4", "/Web-Pakete/smallbiz4/", "default.html"},
            new string[] {"smallbiz5", "/Web-Pakete/smallbiz5/", "default.html"},
            new string[] {"smallbiz6", "/Web-Pakete/smallbiz6/", "default.html"},
            new string[] {"org1", "/Web-Pakete/org1/", "default.html"},
            new string[] {"org2", "/Web-Pakete/org2/", "default.html"},
            new string[] {"org3", "/Web-Pakete/org3/", "default.html"},
            new string[] {"org4", "/Web-Pakete/org4/", "default.html"},
            new string[] {"org5", "/Web-Pakete/org5/", "default.html"},
            new string[] {"org6", "/Web-Pakete/org6/", "default.html"},
            new string[] {"cf1colfixed", "/Web-Pakete/cf1colfixed/", "index.html"},
            new string[] {"cf1colfluid", "/Web-Pakete/cf1colfluid/", "index.html"},
            new string[] {"cf2colleftfixed", "/Web-Pakete/cf2colleftfixed/", "index.html"},
            new string[] {"cf2colleftfluid", "/Web-Pakete/cf2colleftfluid/", "index.html"},
            new string[] {"cf2colrightfixed", "/Web-Pakete/cf2colrightfixed/", "index.html"},
            new string[] {"cf2colrightfluid", "/Web-Pakete/cf2colrightfluid/", "index.html"},
            new string[] {"cf3colfixed", "/Web-Pakete/cf3colfixed/", "index.html"},
            new string[] {"mf1colfixed", "/Web-Pakete/mf1colfixed/", "index.html"},
            new string[] {"mf1colflex", "/Web-Pakete/mf1colflex/", "index.html"},
            new string[] {"mf2colfixedleft", "/Web-Pakete/mf2colfixedleft/", "index.html"},
            new string[] {"mf2colfixedright", "/Web-Pakete/mf2colfixedright/", "index.html"},
            new string[] {"mf2colflexleft", "/Web-Pakete/mf2colflexleft/", "index.html"},
            new string[] {"mf2colflexright", "/Web-Pakete/mf2colflexright/", "index.html"},
            new string[] {"mf3colfixed", "/Web-Pakete/mf3colfixed/", "index.html"},
            new string[] {"mobile", "/Web-Pakete/mobile/", "default.html"},
            new string[] {"1colfixed800", "/Web-Pakete/1colfixed800/", "index.html"},
            new string[] {"1colfixed1024", "/Web-Pakete/1colfixed1024/", "index.html"},
            new string[] {"1colliquid", "/Web-Pakete/1colliquid/", "index.html"},
            new string[] {"2colleftfixed800", "/Web-Pakete/2colleftfixed800/", "index.html"},
            new string[] {"2colleftfixed1024", "/Web-Pakete/2colleftfixed1024/", "index.html"},
            new string[] {"2colleftliquid", "/Web-Pakete/2colleftliquid/", "index.html"},
            new string[] {"2colrightfixed800", "/Web-Pakete/2colrightfixed800/", "index.html"},
            new string[] {"2colrightfixed1024", "/Web-Pakete/2colrightfixed1024/", "index.html"},
            new string[] {"2colrightliquid", "/Web-Pakete/2colrightliquid/", "index.html"},
            new string[] {"2eqcolleft", "/Web-Pakete/2eqcolleft/", "index.html"},
            new string[] {"2eqcollftliq", "/Web-Pakete/2eqcollftliq/", "index.html"},
            new string[] {"2eqcolrgtliq", "/Web-Pakete/2eqcolrgtliq/", "index.html"},
            new string[] {"2eqcolright", "/Web-Pakete/2eqcolright/", "index.html"},
            new string[] {"3colfixed800", "/Web-Pakete/3colfixed800/", "index.html"},
            new string[] {"3colfixed1024", "/Web-Pakete/3colfixed1024/", "index.html"},
            new string[] {"3colliquid", "/Web-Pakete/3colliquid/", "index.html"},
            new string[] {"3equcol", "/Web-Pakete/3equcol/", "index.html"},
            new string[] {"2col-em-ful", "/Web-Pakete/2col-em-ful/", "2col-em-ful.html"},
            new string[] {"2col-right-em", "/Web-Pakete/2col-right-em/", "2colright.html"},
            new string[] {"3-column", "/Web-Pakete/3-column/", "3col.html"},
            new string[] {"brown-teal-template", "/Web-Pakete/brown-teal-template/", "index.html"},
            new string[] {"daffodil-garden", "/Web-Pakete/daffodil-garden/", "index.html"},
            new string[] {"dandelion-meadow", "/Web-Pakete/dandelion-meadow/", "index.html"},
            new string[] {"desert-3equal-columns", "/Web-Pakete/desert-3equal-columns/", "index.html"},
            new string[] {"evening-trees", "/Web-Pakete/evening-trees/", "index.html"},
            new string[] {"floral-inspiration", "/Web-Pakete/floral-inspiration/", "index.html"},
            new string[] {"majestic-mountains", "/Web-Pakete/majestic-mountains/", "index.html"},
            new string[] {"mauve-flowers", "/Web-Pakete/mauve-flowers/", "index.html"},
            new string[] {"mini-country", "/Web-Pakete/mini-country/", "index.html"},
            new string[] {"my-family-tree", "/Web-Pakete/my-family-tree/", "index.html"},
            new string[] {"night-lights", "/Web-Pakete/night-lights/", "index.html"},
            new string[] {"ocean", "/Web-Pakete/ocean/", "index.html"},
            new string[] {"ocean-two-column", "/Web-Pakete/ocean-two-column/", "index.html"},
            new string[] {"red-and-black", "/Web-Pakete/red-and-black/", "index.html"},
            new string[] {"soccer", "/Web-Pakete/soccer/", "default.html"},
            new string[] {"spring-green", "/Web-Pakete/spring-green/", "index.html"},
            new string[] {"springtime", "/Web-Pakete/springtime/", "springtime.html"},
            new string[] {"summer-flowers", "/Web-Pakete/summer-flowers/", "index.html"},
            new string[] {"three-column", "/Web-Pakete/three-column/", "index.html"},
            new string[] {"tor-house2", "/Web-Pakete/tor-house2/", "index.html"},
            new string[] {"triple-layered-background", "/Web-Pakete/triple-layered-background/", "index.html"},
            new string[] {"woodland-stream", "/Web-Pakete/woodland-stream/", "index-2col.html"},
            new string[] {"blades", "/Web-Pakete/blades/", "index.html"},
            new string[] {"boy-scouts", "/Web-Pakete/boy-scouts/", "index.html"},
            new string[] {"camp", "/Web-Pakete/camp/", "index.html"},
            new string[] {"christmas", "/Web-Pakete/christmas/", "index.html"},
            new string[] {"easter", "/Web-Pakete/easter/", "index.html"},
            new string[] {"northern-lights", "/Web-Pakete/northern-lights/", "index.html"},
            new string[] {"obannons", "/Web-Pakete/obannons/", "index.html"},
            new string[] {"paradise-beach", "/Web-Pakete/paradise-beach/", "index.html"},
            new string[] {"reading", "/Web-Pakete/reading/", "index.html"},
        };
    }
}