<%@ Page Language="c#" Debug="true" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Xml" %>
<%@ Import Namespace="System.Web" %>
<%@ Import Namespace="System.Web.UI" %>
<%@ Import Namespace="System.Web.UI.WebControls" %>
<%@ Import Namespace="System.Web.SessionState" %>
<%@ Import Namespace="System.Web.Configuration" %>
<%@ Import Namespace="System.Text" %>
<%@ Import Namespace="System.Text.RegularExpressions" %>
<%@ Import Namespace="System.Security.AccessControl" %>
<%@ Import Namespace="System.Reflection" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<%@ Import Namespace="System.DirectoryServices" %>
<%@ Import Namespace="System.Configuration" %>
<%@ Import Namespace="System.Collections" %>
<%@ Import Namespace="System.Collections.Specialized" %>
<%@ Import Namespace="System.Collections.Generic" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-5" />
    <link href="~/sex.css" rel="stylesheet" type="text/css" />
    <title>SEX Server Explorer</title>
    <script type="text/javascript">
        function NewWindow(Url) {
            window.open(Url, "Sex", "");
        }
        var WidthServer = 250;
        var HeightTitle = 40;
        var HeightDetails = 40;
        var HeightMenu = 25;
        function sizeDivs() {
            var Div_Title = document.getElementById("Div_Title");
            var Div_Details = document.getElementById("Div_Details");
            var Div_Menu = document.getElementById("Div_Menu");
            var Div_MenuServer = document.getElementById("Div_MenuServer");
            var Div_MenuItem = document.getElementById("Div_MenuItem");
            var Div_Content = document.getElementById("Div_Content");
            var Div_Server = document.getElementById("Div_Server");
            var Div_ContentItem = document.getElementById("Div_ContentItem");

            Div_ContentItem.style.height = (window.innerHeight - HeightTitle - HeightDetails - HeightMenu) + "px";
            Div_ContentItem.style.width = (window.innerWidth - WidthServer) + "px";
            Div_Server.style.height = window.innerHeight + "px";
        } 
        var resizeTimerID = null;
        function onResize() {
            if (resizeTimerID == null) {
                resizeTimerID = window.setTimeout(function () {
                    resizeTimerID = null;
                    sizeDivs();
                }, 500);
            }
        }
        onload = sizeDivs; onresize = onResize;
    </script>
    <script language="C#" runat="server">

// Start of default.aspx.cs

        const string ValueDelimiter = ",";
        /*
        const bool UseLogin = true;
        const string Password = "SEXy";
        const bool DynamicLoadTree = false;
        const bool AutocloseTree = true;
        const int ThumbDimension = 200;
        const int ThumbCols = 3;
        const int MaxLineLength = 27; // used for thumb preview of text
        const int MaxLineCount = 10; // used for thumb preview of text
        const string UrlJsHighlight = "http://alexgorbatchev.com/pub/sh/current/";

        string[] IpsAllowed = new string[]
        {
            "127.0.0.1",  // localhost
            "192.168.0.107", // host in private network
            "86.59.41.251" // public host
        };
        */
        State MyState = null;

        protected void HideAllControls()
        {
            // Title
            Label_Server.Visible = false;
            Label_ServerPath.Visible = false;
            Label_TitleItem.Visible = false;
            Label_PathItem.Visible = false;

            HideItemMenus();

            // Tree Menu
            Tree_Content.Visible = false;
            Tree_Controls.Visible = false;

            // Content
            iframe_Content.Visible = false;
            Literal_Content.Visible = false;
        }
        protected void HideItemMenus()
        {
            // Menu
            Table_TreeCommands.Visible = false;
            Menu_Directory.Visible = false;
            Menu_File.Visible = false;
            DropDownList_Template.Visible = false;
            Panel_LoginCommands.Visible = false;
        }
        public static string Untag(string Html)
        {
            return Html.Replace("<", "&lt;").Replace(">", "&gt;");
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (ViewState["OwnFile"] == null) MyState = new State();
            else MyState = new State(ViewState);
            if (MyState.UserAccepted || !MyState.UseLogin || IsIpAllowed())
            {
                if (MyState.CurrentServer == "")
                {
                    HideAllControls(); 
                    MyState.OwnFile = System.IO.Path.GetFileName(Request.ServerVariables["PATH_INFO"]).ToLower();
                    DirectoryInfo RootDir = new DirectoryInfo(Server.MapPath("~/"));
                    string RelativePath = MyState.RelativePath;
                    RelativePath = RelativePath.Replace("/", "\\");
                    if (RelativePath != "")
                    {
                        while (RelativePath.StartsWith("\\")) RelativePath = RelativePath.Substring(1);
                        while (RelativePath.EndsWith("\\")) RelativePath = RelativePath.Substring(0, RelativePath.Length-1);
                    }
                    MyState.RelativePathComponents = RelativePath.Split(new char[] { '\\' });

                    MyState.RootDirFullName += RootDir + RelativePath + "\\";
                    RootDir = new DirectoryInfo(MyState.RootDirFullName);
                    MyState.RootDirFullName = System.IO.Path.GetFullPath(MyState.RootDirFullName);

                    MyState.CurrentServer = Request.Url.Authority;
                    // if (!MyState.CurrentServer.EndsWith("/")) MyState.CurrentServer += "/";

                    // is Sex installend in a Subdirectory or virtualDirectory?
                    MyState.ApplicationPath = Request.ApplicationPath;
                    if (MyState.ApplicationPath == "/") MyState.ApplicationPath = "";

                    MyState.CurrentFile = "";
                    // Directory Tree
                    Tree_Content.Nodes.Clear();
                    TreeNode RootNode;
                    if (MyState.DynamicLoadTree)
                    {
                        RootNode = GetTreeDynamic(RootDir, null, true);
                    }
                    else
                    {
                        RootNode = GetTree(RootDir, null);
                    }
                    RootNode.Expanded = false;
                    Tree_Content.Nodes.Add(RootNode);

                    Tree_Controls.CollapseAll();
                    Tree_Content.CollapseAll();
                    MyState.SaveState(ViewState);
                }
            }
            else
            {
                HideAllControls();
                Login();
                return;
            }
            Label_Server.Visible = true;
            Label_ServerPath.Visible = true;
            Label_Server.Text = MyState.CurrentServer;
            Label_ServerPath.Text = MyState.ApplicationPath;

            Tree_Content.Visible = true;
            Tree_Controls.Visible = true;
            Table_TreeCommands.Visible = true;
        }
        TreeNode GetTree(DirectoryInfo directory, TreeNode parentNode)
        {
            if (directory == null) return null;

            // Directory Tree
            string Text = directory.Name; 
            string Value = "d" + ValueDelimiter + "0" + ValueDelimiter + directory.Name;
            string ToolTip = Value;
            TreeNode DirNode = new TreeNode(Text,Value);
            DirNode.ToolTip = ToolTip;
            DirNode.Expanded = false;

            // Subdirectories recursive
            System.IO.DirectoryInfo[] SubDirectories = directory.GetDirectories();
            for (int DirectoryCount = 0; DirectoryCount < SubDirectories.Length; DirectoryCount++)
            {
                DirNode.ChildNodes.Add(GetTree(SubDirectories[DirectoryCount], DirNode));
            }

            // Files
            System.IO.FileInfo[] Files = directory.GetFiles();
            for (int FileCount = 0; FileCount < Files.Length; FileCount++)
            {
                Text = Files[FileCount].Name;
                Value = "f" + ValueDelimiter + Files[FileCount].Length.ToString() + ValueDelimiter + Text;
                ToolTip = Value;
                TreeNode FileNode = new TreeNode(Text,Value);
                FileNode.ToolTip = ToolTip;
                DirNode.ChildNodes.Add(FileNode); 
            }
            return DirNode;
        }
        TreeNode GetTreeDynamic(DirectoryInfo directory, TreeNode parentNode, bool first)
        {
            if (directory == null) return null;
            TreeNode DirNode = new TreeNode(directory.Name, "d" + ValueDelimiter + "0" + ValueDelimiter + directory.Name);
            DirNode.Expanded = false;
            if (!first) DirNode.PopulateOnDemand = true;
            if (!first) return DirNode;
            System.IO.DirectoryInfo[] SubDirectories = directory.GetDirectories();
            for (int DirectoryCount = 0; DirectoryCount < SubDirectories.Length; DirectoryCount++)
            {
                DirNode.ChildNodes.Add(GetTreeDynamic(SubDirectories[DirectoryCount], DirNode, false));
            }
            System.IO.FileInfo[] Files = directory.GetFiles();

            for (int FileCount = 0; FileCount < Files.Length; FileCount++)
            {
                string FileName = Files[FileCount].Name;
                DirNode.ChildNodes.Add(new TreeNode(FileName, "f" + ValueDelimiter + Files[FileCount].Length.ToString() + ValueDelimiter + FileName));
            }
            return DirNode;
        }

        protected void Login()
        {
            Panel_LoginCommands.Visible = true;
            MyState.SaveState(ViewState);
        }
        bool IsIpAllowed()
        {
            string UserIp = Request.UserHostAddress;
            for (int i = 0; i < MyState.IpsAllowed.Length; i++)
            {
                if (UserIp == MyState.IpsAllowed[i])
                    return true;
            }
            return false;
        }
        protected bool IsAllowedMenuItem(MenuItem mi, List<string> li)
        {
            foreach (string v in li)
            {
                if (mi.Value == v) return true;
            }
            return false;
        }
        protected string GetRelativePathWithoutItem(string RelPath, string Item)
        {
            if (RelPath.ToLower().EndsWith(Item.ToLower()))
                return RelPath.Substring(0, RelPath.Length - Item.Length);
            else
                return RelPath;
        }
        protected void Menu_MenuItemClick(object sender, MenuEventArgs e)
        {
            Menu m = (Menu)sender;
            string SelectedValue = m.SelectedValue;
            switch (SelectedValue)
            {
                // File Commands
                case "FileInline":
                    MenuFileExecute(E_ObjectCommand.INLINE);
                    break;
                case "FileCode":
                    MenuFileExecute(E_ObjectCommand.CODE);
                    break;
                case "FileFrame":
                    MenuFileExecute(E_ObjectCommand.FRAME);
                    break;
                case "FileNewWin":
                    MenuFileExecute(E_ObjectCommand.NEWWIN);
                    break;
                case "FileEmbed":
                    MenuFileExecute(E_ObjectCommand.EMBED);
                    break;
                case "FileHex":
                    MenuFileExecute(E_ObjectCommand.HEX);
                    break;
                case "FilePermissions":
                    MenuFileExecute(E_ObjectCommand.PERMISSIONS);
                    break;
                case "FileDownload":
                    MenuFileExecute(E_ObjectCommand.DOWNLOAD);
                    break;
                case "FileSpecial":
                    MenuFileExecute(E_ObjectCommand.SPECIAL);
                    break;
                case "FileExif":
                    MenuFileExecute(E_ObjectCommand.EXIF);
                    break;
                // Directory Commands
                case "DirectoryFrame":
                    MenuDirectoryExecute(E_ObjectCommand.FRAME);
                    break;
                case "DirectoryList":
                    MenuDirectoryExecute(E_ObjectCommand.DIRECTORY);
                    break;
                case "DirectoryPermissions":
                    MenuDirectoryExecute(E_ObjectCommand.PERMISSIONS);
                    break;
                case "DirectoryThumbs":
                    MenuDirectoryExecute(E_ObjectCommand.THUMBS);
                    break;
                // Tree Commands
                case "0":
                case "1":
                case "2":
                case "3":
                case "9":
                    int Level = int.Parse(SelectedValue);
                    if (Tree_Content.Nodes.Count > 0)
                        Tree.Expand(Tree_Content.Nodes[0], Level);
                    break;
            }
            MyState.SaveState(ViewState);
        }
        protected void LinkButton_Server_Command(object sender, CommandEventArgs e)
        {
            switch (e.CommandName)
            {
                case "Login":
                    if (TextBox_Login.Text == MyState.Password)
                    {
                        MyState.UserAccepted = true;
                        MyState.SaveState(ViewState);
                        Page_Load(null, null);
                    }
                    break;
                case "Search":
                    if (TextBox_Search.Text == "")
                    {
                        Tree_Content.ShowCheckBoxes = TreeNodeTypes.None;
                    }
                    else
                    {
                        Tree_Content.ShowCheckBoxes = TreeNodeTypes.All;
                        Tree.Expand(Tree_Content.Nodes[0], 0);
                        if (!Tree.Search(Tree_Content.Nodes[0], TextBox_Search.Text))
                            Tree_Content.ShowCheckBoxes = TreeNodeTypes.None;
                    }
                    break;
            }
            MyState.SaveState(ViewState);
        }
        protected void DropDownList_Template_SelectedIndexChanged(object sender, EventArgs e)
        {
            MenuFileExecute(E_ObjectCommand.EMBED);
        }
        protected void Tree_Content_TreeNodePopulate(object sender, TreeNodeEventArgs e)
        {
            if (MyState.DynamicLoadTree) 
            {
                MyState = new State(ViewState);
                ItemInfo ii = new ItemInfo(e.Node.Value);
                string Path = Tree.Path(e.Node);
                DirectoryInfo di = new DirectoryInfo(MyState.RootDirFullName + Path);
                System.IO.DirectoryInfo[] SubDirectories = di.GetDirectories();
                for (int DirectoryCount = 0; DirectoryCount < SubDirectories.Length; DirectoryCount++)
                {
                    TreeNode tn = new TreeNode(SubDirectories[DirectoryCount].Name, "d" + ValueDelimiter + "0" + ValueDelimiter + SubDirectories[DirectoryCount].Name);
                    tn.PopulateOnDemand = true;
                    e.Node.ChildNodes.Add(tn);
                }
                System.IO.FileInfo[] Files = di.GetFiles();
                for (int FileCount = 0; FileCount < Files.Length; FileCount++)
                {
                    string FileName = Files[FileCount].Name;
                    e.Node.ChildNodes.Add(new TreeNode(FileName, "f" + ValueDelimiter + Files[FileCount].Length.ToString() + ValueDelimiter + FileName));
                }
                // MyState.SaveState(ViewState);
            }
        }
        protected void Tree_Content_TreeNodeExpanded(object sender, TreeNodeEventArgs e)
        {
            // e.Node.Selected = true;
        }
        protected void Tree_Content_SelectedNodeChanged(object sender, EventArgs e)
        {
            // Unselect the menu tree
            if (Tree_Controls.SelectedNode != null) Tree_Controls.SelectedNode.Selected = false;
            HideItemMenus();
            Table_TreeCommands.Visible = true;
            TreeNode tn = Tree_Content.SelectedNode;
            if (MyState.AutocloseTree)
            {
                Tree_Controls.CollapseAll();
                Tree_Content.CollapseAll();
                Tree.ExpandPath(tn);
            }
            // CurrentPathRel
            MyState.CurrentPathRel = Tree.Path(tn);
            if (MyState.CurrentPathRel == "") MyState.CurrentPathRel = "/";
            else if (!MyState.CurrentPathRel.StartsWith("/")) MyState.CurrentPathRel = "/" + MyState.CurrentPathRel;
            
            //  CurrentPathAbs
            MyState.CurrentPathAbs = MyState.CurrentPathRel.Replace("/","\\");
            if (MyState.CurrentPathAbs.StartsWith("\\")) MyState.CurrentPathAbs = MyState.CurrentPathAbs.Substring(1);
            MyState.CurrentPathAbs = MyState.RootDirFullName + MyState.CurrentPathAbs;

            string Extension = Path.GetExtension(MyState.CurrentPathRel).ToLower();

            Label_TitleItem.Visible = true;
            Label_PathItem.Visible = true;

            ItemInfo ii = new ItemInfo(tn.Value);
            switch (ii.type)
            {
                case E_ObjectType.DIRECTORY:
                default:

                    Menu_Directory.Visible = true;
                    MyState.CurrentFile = new DirectoryInfo(MyState.CurrentPathAbs).Name;
                    Label_PathItem.Text = GetRelativePathWithoutItem(MyState.CurrentPathRel, MyState.CurrentFile);
                    if (!Label_PathItem.Text.EndsWith("/")) Label_PathItem.Text += "/";
                    Label_PathItem.ToolTip = Label_PathItem.Text;
                    Label_TitleItem.Text = tn.Parent==null ? "" : MyState.CurrentFile;
                    MenuDirectoryExecute(E_ObjectCommand.DIRECTORY);
                    break;

                case E_ObjectType.FILE:

                    // q & d reaading word file "Access denied" on C:\Program Files (x86)\Microsoft Visual Studio 9.0\Visual Studio Tools for Office\PIA\Office11\Microsoft.Office.Interop.Word.dll
                    // if (Extension==".doc") 
                    // {
                    //     iframe_Content.Visible = false;
                    //     iframe_Content.Attributes["src"] = "";
                    //     Literal_Content.Visible = true;
                    //     Literal_Content.Text = "";
                    //     Literal_Content.Text = readFileContent(MyState.RootDirFullName + MyState.CurrentPathRel);
                    //     Response.End();
                    // }
                    // send word file to client
                    // if (Extension == ".doc")
                    // {
                    //     FileInfo file = new FileInfo(MyState.RootDirFullName + MyState.CurrentPathRel);
                    //     Response.ClearContent();
                    //     Response.AddHeader("Content-Disposition", "inline;filename=" + file.Name);
                    //     Response.AddHeader("Content-Length", file.Length.ToString());
                    //     Response.ContentType = "application/msword";
                    //     Response.TransmitFile(file.FullName);
                    //     Response.End();
                    // }
                    MyState.CurrentFile = new FileInfo(MyState.CurrentPathAbs).Name.ToLower();
                    FileTypeInfo fti = FileTypes.Get(Extension.ToLower());
                    if (fti != null)
                    {
                        MyState.CurrentIcon = fti.Icon;
                        MyState.CurrentBrush = fti.brush;
                        MyState.CurrentType = fti.Type;
                        MyState.CurrentTemplate = fti.MediaTemplateId;
                    }
                    List<string> m_list = new List<string>();
                    FileGroup ea = null;
                    if (fti == null)
                    {
                        m_list.Add("FilePermissions");
                        m_list.Add("FileHex");
                        m_list.Add("FileDownload");
                    }
                    else
                    {
                        ea = FileGroups.Get(FileTypes.Get(Extension).Type);
                        if (ea.ShowCode) m_list.Add("FileCode");
                        if (ea.ShowFrame && !(MyState.CurrentFile == MyState.OwnFile)) m_list.Add("FileFrame");
                        if (ea.ShowFrame) m_list.Add("FileNewWin");
                        if (ea.ShowDownload) m_list.Add("FileDownload");
                        if (ea.ShowEmbedded) m_list.Add("FileEmbed");
                        if (ea.ShowHex) m_list.Add("FileHex");
                        if (ea.ShowInline) m_list.Add("FileInline");
                        if (ea.ShowPermissions) m_list.Add("FilePermissions");
                        if (ea.ShowSpecial) m_list.Add("FileSpecial");
                        if (ea.ShowExif) m_list.Add("FileExif");
                    }
                    Menu_File.Visible = true;
                    Menu_File.Items.Clear();
                    for (int i = 0; i < Menu_File_Template.Items.Count; i++)
                    {
                        MenuItem mi_template = Menu_File_Template.Items[i];
                        MenuItem mi = new MenuItem(mi_template.Text, mi_template.Value);
                        mi.ToolTip = mi_template.ToolTip;
                        if (IsAllowedMenuItem(mi, m_list))
                            Menu_File.Items.Add(mi);
                    }
                    if (ea != null)
                        if (ea.ShowEmbedded)
                        {
                            DropDownList_Template.Visible = true;
                            DropDownList_Template.Items.Clear();
                            MediaTemplates.list.Sort(MediaTemplate.CompareTemplates);
                            for (int i = 0; i < MediaTemplates.list.Count; i++)
                            {
                                int MediaTemplateId = MediaTemplates.list[i].Id;
                                if
                                    (
                                        ((MyState.CurrentType == FileGroup.Type.AUDIO || MyState.CurrentType == FileGroup.Type.AUDVID) && MediaTemplates.list[i].UseWithAudio)
                                        ||
                                        ((MyState.CurrentType == FileGroup.Type.VIDEO || MyState.CurrentType == FileGroup.Type.AUDVID) && MediaTemplates.list[i].UseWithVideo)
                                        ||
                                        ((MyState.CurrentType == FileGroup.Type.IMAGE || MyState.CurrentType == FileGroup.Type.EXIF) && MediaTemplates.list[i].UseWithImage)
                                    )
                                {
                                    ListItem li = new ListItem(MediaTemplates.list[i].Name, MediaTemplateId.ToString());
                                    if (MediaTemplateId == MyState.CurrentTemplate) li.Selected = true;
                                    DropDownList_Template.Items.Add(li);
                                }
                            }
                        }
                    Label_PathItem.Text = GetRelativePathWithoutItem(MyState.CurrentPathRel, MyState.CurrentFile);
                    if (!Label_PathItem.Text.EndsWith("/")) Label_PathItem.Text += "/";
                    Label_PathItem.ToolTip = Label_PathItem.Text;
                    Label_TitleItem.Text = MyState.CurrentFile;
                    Label_TitleItem.ToolTip = Label_TitleItem.Text;
                    string MimeType = Mime.GetMimeType(Extension); if (string.IsNullOrEmpty(MimeType)) MimeType = "";
                    MimeType = MimeType == "" ? " (-)" : " (" + MimeType + ")";
                    MenuFileExecute(ea == null ? E_ObjectCommand.HEX : ea.ShowFirst);
                    break;
            }
            Page_Load(null, null);
        }
        protected void Tree_Controls_SelectedNodeChanged(object sender, EventArgs e)
        {
            TreeView m = (TreeView)sender;
            TreeNode tn = m.SelectedNode;
            if (MyState.AutocloseTree)
            {
                Tree_Controls.CollapseAll();
                Tree_Content.CollapseAll();
                Tree.ExpandPath(tn);
            }
            if (Tree_Content.SelectedNode != null) Tree_Content.SelectedNode.Selected = false;
            string SelectedValue = m.SelectedValue;
            iframe_Content.Attributes["src"] = "";
            iframe_Content.Visible = false;
            Literal_Content.Visible = false;
            Menu_File.Visible = false;
            Menu_Directory.Visible = false;
            Panel_LoginCommands.Visible = false;
            DropDownList_Template.Visible = false;
            switch (SelectedValue)
            {
                // Server Commands
                case "Server.Variables":
                    // string HelpText = "<span class='HexCaption'>VALUE = Request.ServerVariables[\"PARAMETER\"];</span>\r\n"
                    //     + "<span class='HexTitle'>string PathInfo = Request.ServerVariables[\"PATH_INFO\"];</span>";
                    // Div_ContentItem.Controls.Add(new LiteralControl("<pre>" + HelpText + "</pre>"));
                    Div_ContentItem.Controls.Add((new ListServerVariables(MyState)).GetData());
                    break;
                case "Server.Request":
                    Div_ContentItem.Controls.Add((new ListRequest(MyState)).GetData());
                    break;
                case "Server.Response":
                    Div_ContentItem.Controls.Add((new ListResponse(MyState)).GetData());
                    break;
                case "Server.Server":
                    Div_ContentItem.Controls.Add((new ListServer(MyState)).GetData());
                    break;
                case "Server.Application":
                    Div_ContentItem.Controls.Add((new ListApplication(MyState)).GetData());
                    break;
                case "Server.Session":
                    Div_ContentItem.Controls.Add((new ListSession(MyState)).GetData());
                    break;
                case "Server.MimeExtensions":
                    Div_ContentItem.Controls.Add((new ListMimeByExtension(MyState)).GetData());
                    break;
                case "Server.MimeTypes":
                    Div_ContentItem.Controls.Add((new ListMimeByType(MyState)).GetData());
                    break;
                case "Server.Browser":
                    Div_ContentItem.Controls.Add((new ListBrowser(MyState)).GetData());
                    break;
                case "Server.Mobile":
                    Div_ContentItem.Controls.Add((new ListMobile(MyState)).GetData());
                    break;
                case "Server.Cookies":
                    Div_ContentItem.Controls.Add((new ListCookies(MyState)).GetData());
                    break;
                case "Server.Modules":
                    Div_ContentItem.Controls.Add((new ListModules(MyState)).GetData());
                    break;
                case "Server.Context":
                    Div_ContentItem.Controls.Add((new ListContext(MyState)).GetData());
                    break;
                case "Server.ViewState":
                    Div_ContentItem.Controls.Add((new ListViewState(MyState, ViewState)).GetDataSorted());
                    break;
                case "Server.Environment":
                    Div_ContentItem.Controls.Add((new ListEnvironment(MyState)).GetData());
                    break;
                case "Server.Configuration":
                    Div_ContentItem.Controls.Add((new ListConfiguration(MyState)).GetData());
                    break;
                // Explorer
                case "Explorer.Exif":
                    Div_ContentItem.Controls.Add((new ListExifAll(MyState)).GetData());
                    break;
                case "Explorer.ImageFlags":
                    Div_ContentItem.Controls.Add((new ListImage(MyState)).GetData());
                    break;
                case "Explorer.FileGroups":
                    Div_ContentItem.Controls.Add((new ListFileGroups(MyState)).GetDataSorted());
                    break;
                case "Explorer.Extensions":
                    Div_ContentItem.Controls.Add((new ListExtensions(MyState)).GetDataSorted());
                    break;
                case "Explorer.Templates":
                    Div_ContentItem.Controls.Add((new ListTemplates(MyState)).GetData());
                    break;
                case "Explorer.Attributes":
                    Div_ContentItem.Controls.Add((new ListAttributes(MyState)).GetData());
                    break;
                case "About":
                    Div_ContentItem.Controls.Add((new ListAbout(MyState)).GetData());
                    break;
            }
            MyState.SaveState(ViewState);
        }

// Start of ExeDirectoryListThumbs.cs

        public class ListThumbs : MyList
        {
            public ListThumbs(State MyState, string CurrentPathRel) : base(MyState)
            {
                DirectoryInfo di = new DirectoryInfo(MyState.CurrentPathAbs);
                FileInfo[] fi = di.GetFiles();
                /*
                if ((MyState.CurrentPathRel == "") || (MyState.CurrentPathRel == "/"))
                {
                }
                else
                {
                    if (!MyState.CurrentPathRel.EndsWith("/")) MyState.CurrentPathRel += "/";
                }
                */
                if (!CurrentPathRel.EndsWith("/")) CurrentPathRel += "/";
                for (int i = 0; i < fi.Length; i++)
                {
                    string Extension = Path.GetExtension(fi[i].Extension);
                    string Name = fi[i].Name;
                    string FullName = fi[i].FullName;
                    E_ObjectCommand ft = FileTypes.GetFileTypeInThumb(Extension);
                    FileGroup.Type fg = FileTypes.GetFileType(Extension);
                    Add(FullName, new string[] { CurrentPathRel + Name, ((int)ft).ToString(), ((int)fg).ToString() });
                }
            }
        }

// Start of ExeFileDirectory.cs

        protected void MenuFileExecute(E_ObjectCommand sf)
        {
            Div_Details.Controls.Add(new ListFileDirectory(MyState).GetData());
            Img img = null;
            Menu_File.Visible = true;
            SetSelectedValue(Menu_File, sf);
            switch (sf)
            {
                case E_ObjectCommand.FRAME:
                    iframe_Content.Visible = true;
                    Literal_Content.Visible = false;
                    Literal_Content.Text = "";
                    break;
                case E_ObjectCommand.NEWWIN:
                    iframe_Content.Visible = false;
                    Literal_Content.Visible = true;
                    Literal_Content.Text = "";
                    break;
                default:
                case E_ObjectCommand.INLINE:
                case E_ObjectCommand.EMBED:
                case E_ObjectCommand.CODE:
                case E_ObjectCommand.HEX:
                    iframe_Content.Visible = false;
                    iframe_Content.Attributes["src"] = "";
                    Literal_Content.Visible = true;
                    Literal_Content.Text = "";
                    break;
                case E_ObjectCommand.SPECIAL:
                case E_ObjectCommand.EXIF:
                case E_ObjectCommand.PERMISSIONS:
                    iframe_Content.Visible = false;
                    iframe_Content.Attributes["src"] = "";
                    Literal_Content.Visible = false;
                    Literal_Content.Text = "";
                    break;
                case E_ObjectCommand.DOWNLOAD:
                    // do no change current display
                    break;
            }
            switch (sf)
            {
                case E_ObjectCommand.FRAME:
                    iframe_Content.Attributes["src"] = Tree.GetUrl(Tree_Content.SelectedNode, MyState.RelativePathComponents, MyState.ApplicationPath);
                    // iframe_Content.Attributes["src"] = "ExeGetFileDirectory.aspx" + "?p=" + Server.UrlEncode(MyState.CurrentPathAbs); // MyState.CurrentPathRel;
                    break;
                case E_ObjectCommand.NEWWIN:
                    Literal_Content.Text = MediaTemplates.Get(14).InstantiateTemplate("", "", Tree.GetUrl(Tree_Content.SelectedNode, MyState.RelativePathComponents, MyState.ApplicationPath)); 
                    break;
                case E_ObjectCommand.INLINE:
                    Literal_Content.Text = File.ReadAllText(MyState.RootDirFullName + MyState.CurrentPathRel);
                    break;
                case E_ObjectCommand.EMBED:
                    int my_x = 0;
                    int my_y = 0;
                    switch (MyState.CurrentType)
                    {
                        case FileGroup.Type.EXIF:
                        case FileGroup.Type.IMAGE:
                            img = new Img(MyState.CurrentPathAbs);
                            int x = img.x;
                            int y = img.y;
                            // Scale Picture to an area 200x200 px retaining aspect ratio
                            int MaxDim = 320;
                            if (x > y) // width>height
                            {
                                my_x = MaxDim;
                                my_y = (int)(MaxDim * ((y * 1.0) / x));
                            }
                            else
                            {
                                my_y = MaxDim;
                                my_x = (int)(MaxDim * ((x * 1.0) / y));
                            }
                            break;
                        case FileGroup.Type.AUDIO:
                        case FileGroup.Type.VIDEO:
                        case FileGroup.Type.AUDVID:
                            my_x = 320;
                            my_y = 200;
                            break;
                        default:
                        case FileGroup.Type.APPLI:
                        case FileGroup.Type.CODEEXE:
                        case FileGroup.Type.BINARY:
                        case FileGroup.Type.APPLIEXE:
                        case FileGroup.Type.OTHER:
                        case FileGroup.Type.NOTYPE:
                            // Literal_Content.Text =
                            //     "<table width='100%' height='100%'><tr><td align='center' valign='middle'>"
                            //     + Literal_Content.Text
                            //     + "</td></tr></table>";
                            break;
                    }
                    MediaTemplate mt = MediaTemplates.Get(int.Parse(DropDownList_Template.SelectedValue));
                    string Template = mt.InstantiateTemplate(my_x.ToString(), my_y.ToString(), Tree.GetPathReduced(Tree_Content.SelectedNode, MyState.RelativePathComponents, MyState.ApplicationPath)); // MyState.CurrentPathRel
                    Literal_Content.Visible = true;
                    Literal_Content.Text = GetHighlightCodeAndInsertScript(MyState, Template, "xml") + Template;
                    break;
                case E_ObjectCommand.CODE:
                    Literal_Content.Text = Untag(File.ReadAllText(MyState.RootDirFullName + MyState.CurrentPathRel));
                    string Brush = MyState.CurrentBrush;
                    if (Brush == "") Brush = "plain";
                    Literal_Content.Text = GetHighlightCodeAndInsertScript(MyState, Literal_Content.Text, Brush);
                    break;
                case E_ObjectCommand.HEX:
                default:
                    Literal_Content.Text = "<pre>" + Hex.Dump(MyState.RootDirFullName + MyState.CurrentPathRel) + "</pre>";
                    break;
                case E_ObjectCommand.PERMISSIONS:
                    Div_ContentItem.Controls.Add(new ListPermissions(MyState).GetData());
                    break;
                case E_ObjectCommand.DOWNLOAD:
                    MenuDownload(MyState.CurrentPathAbs);
                    break;
                case E_ObjectCommand.SPECIAL:
                    switch (MyState.CurrentType)
                    {
                        case FileGroup.Type.EXIF:
                        case FileGroup.Type.IMAGE:
                            if (img == null) img = new Img(MyState.CurrentPathAbs);
                            if (img != null) Div_ContentItem.Controls.Add((new ListImage(MyState, img)).GetData());
                            break;
                    }
                    break;
                case E_ObjectCommand.EXIF:
                    Div_ContentItem.Controls.Add((new ListExif(MyState)).GetData());
                    break;
            }
            MyState.SaveState(ViewState);
        }
        protected void MenuDirectoryExecute(E_ObjectCommand sf)
        {
            Div_Details.Controls.Add(new ListFileDirectory(MyState, Tree.Size(Tree_Content.SelectedNode)).GetData());
            Menu_Directory.Visible = true;
            SetSelectedValue(Menu_Directory, sf);
            switch (sf)
            {
                case E_ObjectCommand.FRAME:
                    Literal_Content.Visible = false;
                    Literal_Content.Text = "";
                    iframe_Content.Visible = true;
                    iframe_Content.Attributes["src"] = Tree.GetUrl(Tree_Content.SelectedNode, MyState.RelativePathComponents, MyState.ApplicationPath);
                    // iframe_Content.Attributes["src"] = "ExeGetFileDirectory.aspx" + "?p=" + Server.UrlEncode(MyState.CurrentPathAbs); // MyState.CurrentPathRel;
                    break;
                case E_ObjectCommand.DIRECTORY:
                    Literal_Content.Visible = true;
                    iframe_Content.Visible = false;
                    iframe_Content.Attributes["src"] = "";
                    Literal_Content.Text = "";
                    Literal_Content.Visible = false;
                    Div_ContentItem.Controls.Add(new ListFileDirectory(MyState, Tree_Content.SelectedNode).GetData());
                    break;
                case E_ObjectCommand.PERMISSIONS:
                    iframe_Content.Visible = false;
                    iframe_Content.Attributes["src"] = "";
                    Literal_Content.Visible = false;
                    Literal_Content.Text = "";
                    Div_ContentItem.Controls.Add(new ListPermissions(MyState).GetData());
                    break;
                case E_ObjectCommand.THUMBS:
                    iframe_Content.Visible = false;
                    iframe_Content.Attributes["src"] = "";
                    Literal_Content.Visible = false;
                    Literal_Content.Text = "";
                    string CurrentPathRel = Tree.GetPathReduced(Tree_Content.SelectedNode, MyState.RelativePathComponents, MyState.ApplicationPath);
                    Div_ContentItem.Controls.Add(new ListThumbs(MyState, CurrentPathRel).GetThumbs(MyState.ThumbDimension, MyState.ThumbCols));
                    break;
            }
            MyState.SaveState(ViewState);
        }
        protected void SetSelectedValue(Menu m, E_ObjectCommand sf)
        {
            for (int i = 0; i < m.Items.Count; i++)
            {
                switch (sf)
                {
                    case E_ObjectCommand.CODE:
                        if (m.Items[i].Value == "FileCode") { m.Items[i].Selected = true; return; }
                        break;
                    case E_ObjectCommand.DIRECTORY:
                        if (m.Items[i].Value == "DirectoryDetails") { m.Items[i].Selected = true; return; }
                        break;
                    case E_ObjectCommand.DOWNLOAD:
                        if (m.Items[i].Value == "FileDownload") { m.Items[i].Selected = true; return; }
                        break;
                    case E_ObjectCommand.SPECIAL:
                        if (m.Items[i].Value == "FileSpecial") { m.Items[i].Selected = true; return; }
                        break;
                    case E_ObjectCommand.EMBED:
                        if (m.Items[i].Value == "FileEmbed") { m.Items[i].Selected = true; return; }
                        break;
                    case E_ObjectCommand.FRAME:
                        if (m.Items[i].Value == "DirectoryFrame") { m.Items[i].Selected = true; return; }
                        if (m.Items[i].Value == "FileFrame") { m.Items[i].Selected = true; return; }
                        break;
                    case E_ObjectCommand.HEX:
                        if (m.Items[i].Value == "FileHex") { m.Items[i].Selected = true; return; }
                        break;
                    case E_ObjectCommand.INLINE:
                        if (m.Items[i].Value == "FileInline") { m.Items[i].Selected = true; return; }
                        break;
                    case E_ObjectCommand.PERMISSIONS:
                        if (m.Items[i].Value == "DirectoryPermissions") { m.Items[i].Selected = true; return; }
                        if (m.Items[i].Value == "FilePermissions") { m.Items[i].Selected = true; return; }
                        break;
                }
            }
        }

// Start of ExeFileDownload.cs

        protected void MenuDownload(string path)
        {
            FileInfo downloadFile = new FileInfo(path);
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.AddHeader("Content-Disposition", string.Format("attachment; filename=\"{0}\"", downloadFile.Name));
            HttpContext.Current.Response.AddHeader("Content-Length", downloadFile.Length.ToString());
            HttpContext.Current.Response.ContentType = "application/octet-stream";
            HttpContext.Current.Response.WriteFile(downloadFile.FullName);
            HttpContext.Current.Response.End();
        }
        protected void DownloadFileAsZip(string path)
        {
            /* the following Code uses DotNetZip library
            Response.Clear();
            // no buffering - allows large zip files to download as they are zipped
            Response.BufferOutput = false;
            String ReadmeText = "Dynamic content for a readme file...\n" +
                               DateTime.Now.ToString("G");
            string archiveName = String.Format("archive-{0}.zip",
                                              DateTime.Now.ToString("yyyy-MMM-dd-HHmmss"));
            Response.ContentType = "application/zip";
            Response.AddHeader("content-disposition", "attachment; filename=" + archiveName);
            using (ZipFile zip = new ZipFile())
            {
                // add a file entry into the zip, using content from a string
                zip.AddFileFromString("Readme.txt", "", ReadmeText);
                // add the set of files to the zip
                zip.AddFiles(filesToInclude, "files");
                // compress and write the output to OutputStream
                zip.Save(Response.OutputStream);
            }
            Response.Close();
             */
        }

// Start of ExeImage.cs

        public class Img
        {
            System.Drawing.Image imgFile = null;
            string _Path;
            public string Path
            {
                get
                {
                    return _Path;
                }
            }
            float _x;
            public int x
            {
                get
                {
                    return (int)_x;
                }
            }
            float _y;
            public int y
            {
                get
                {
                    return (int)_y;
                }
            }
            float _dx;
            public int dx
            {
                get
                {
                    return (int)_dx;
                }
            }
            float _dy;
            public int dy
            {
                get
                {
                    return (int)_dy;
                }
            }
            PixelFormat _pf;
            public PixelFormat pf
            {
                get
                {
                    return _pf;
                }
            }
            int _Flags;
            public int Flags
            {
                get
                {
                    return _Flags;
                }
            }
            object _Tag;
            public object Tag
            {
                get
                {
                    return _Tag;
                }
            }
            ImageFormat _Format;
            public ImageFormat Format
            {
                get
                {
                    return _Format;
                }
            }
            Guid[] _FrameDimensionsList;
            public Guid[] FrameDimensionsList
            {
                get
                {
                    return _FrameDimensionsList;
                }
            }
            int[] _PropertyIdList;
            public int[] PropertyIdList
            {
                get
                {
                    return _PropertyIdList;
                }
            }
            public Img(string Path)
            {
                imgFile = System.Drawing.Image.FromFile(Path);
                _Path = Path;
                _x = imgFile.PhysicalDimension.Width;
                _y = imgFile.PhysicalDimension.Height;
                _dx = imgFile.HorizontalResolution;
                _dy = imgFile.VerticalResolution;
                _pf = imgFile.PixelFormat;
                _Flags = imgFile.Flags;
                _Tag = imgFile.Tag;
                _Format = imgFile.RawFormat;
                _FrameDimensionsList = imgFile.FrameDimensionsList;
                _PropertyIdList = imgFile.PropertyIdList;
                imgFile.Dispose();
            }
        }

// Start of ExeListExif.cs

        public class ListExif : MyList
        {
            public ListExif(State MyState) : base (MyState, "Exif Data", "ExifName", new string[] { "Value", "Id-Dec", "Id-Hex", "Type", "TypeS", "Len" })
            {
                System.Drawing.Image imgFile = System.Drawing.Image.FromFile(MyState.CurrentPathAbs);
                System.Drawing.Imaging.PropertyItem[] Image_pi = imgFile.PropertyItems;
                imgFile.Dispose();
                for (int i = 0; i < Image_pi.Length; i++)
                {
                    string Value = "";
                    switch (Image_pi[i].Type)
                    {
                        case 1:
                            break;
                        case 2:
                            Value = Encoding.ASCII.GetString(Image_pi[i].Value, 0, Image_pi[i].Len - 1);
                            Value = Value.Trim();
                            // Value = Value.Replace(" ", "_");
                            // Value = XmlConvert.EncodeName(Value);
                            break;
                        case 3:
                            Value = ((int)(Image_pi[i].Value[0]) + (int)(Image_pi[i].Value[1] * 256)).ToString();
                            break;
                        case 4:
                            Value = ((int)(Image_pi[i].Value[0]) + (int)(Image_pi[i].Value[1] * 256) + (int)(Image_pi[i].Value[2] * 65536) + (int)(Image_pi[i].Value[3] * 65536 * 256)).ToString();
                            break;
                        case 5:
                        case 10:
                            Value = ((int)(Image_pi[i].Value[0]) + (int)(Image_pi[i].Value[1] * 256) + (int)(Image_pi[i].Value[2] * 65536) + (int)(Image_pi[i].Value[3] * 65536 * 256)).ToString() +
                                "/" +
                                ((int)(Image_pi[i].Value[4]) + (int)(Image_pi[i].Value[5] * 256) + (int)(Image_pi[i].Value[6] * 65536) + (int)(Image_pi[i].Value[7] * 65536 * 256)).ToString();
                            break;
                        case 6:
                            break;
                        case 7:
                            // liefert nur BinärDaten
                            // Value = Encoding.ASCII.GetString(Image_pi[i].Value);
                            // Value = XmlConvert.EncodeName(Value);
                            Value = "binary data";
                            break;
                        default:
                            break;
                    }
                    string s = "";
                    switch (Image_pi[i].Type)
                    {
                        case 1:
                            s = "byte[]";
                            break;
                        case 2:
                            s = "string";
                            break;
                        case 3:
                            s = "int16";
                            break;
                        case 4:
                            s = "int32";
                            break;
                        case 5:
                            s = "ulong[,]";
                            break;
                        case 6:
                            s = "bytex[]";
                            break;
                        case 7:
                            s = "int32[]";
                            break;
                        case 10:
                            s = "long[,]";
                            break;
                        default:
                            s = "undefined";
                            break;
                    }
                    if (Value != "")
                    {
                        Add(Exif.GetName(Image_pi[i].Id), new string[]
                    { 
                        Value, 
                        Image_pi[i].Id.ToString(), 
                        Hex.ToHex(Image_pi[i].Id), 
                        Image_pi[i].Type.ToString(), 
                        s, 
                        Image_pi[i].Len.ToString() 
                    });
                    }
                }
            }
        }

// Start of ExeListFileDirectory.cs

        public class ListFileDirectory : MyList
        {
            private static string GetDateTime(DateTime d)
            {
                return d.Year.ToString().PadLeft(4, '0') + "&middot;" + d.Month.ToString().PadLeft(2, '0') + "&middot;" + d.Day.ToString().PadLeft(2, '0') + "&nbsp;" + d.TimeOfDay.Hours.ToString().PadLeft(2, '0') + ":" + d.TimeOfDay.Minutes.ToString().PadLeft(2, '0');
            }
            private static string GetAttributeWithCaption(string Attribute, string Caption)
            {
                return "<span title='" + Caption + "'>" + Attribute + "</span>";
            }
            private static string GetAttributesWithCaption()
            {
                string s = "";
                s += GetAttributeWithCaption("A", "Archive");
                s += GetAttributeWithCaption("C", "Compressed");
                s += GetAttributeWithCaption("D", "Directory");
                s += GetAttributeWithCaption("E", "Encrypted");
                s += GetAttributeWithCaption("H", "Hidden");
                s += GetAttributeWithCaption("I", "Indexed");
                s += GetAttributeWithCaption("N", "Normal");
                s += GetAttributeWithCaption("O", "Offline");
                s += GetAttributeWithCaption("P", "Reparse Point");
                s += GetAttributeWithCaption("R", "Read Only");
                s += GetAttributeWithCaption("S", "Sparse File");
                s += GetAttributeWithCaption("T", "Temporary");
                s += GetAttributeWithCaption("X", "Device");
                s += GetAttributeWithCaption("Y", "System");
                return s;
            }
            private static string GetCaption(string Class)
            {
                return "<span class='" + Class + "'>" + "Created".PadRight(17) + "Accessed".PadRight(17) + "Changed".PadRight(17) + (GetAttributesWithCaption()).PadRight(15) + "Length".PadLeft(11) + " Name</span>\r\n";
            }
            private string[] GetItemProperties(FileSystemInfo di, long len)
            {
                string Extension = di.Extension.ToLower();
                string[] s = new string[7];
                if (len == -1) len = ((FileInfo)di).Length;
                s[0] = len.ToString().PadLeft(12);
                s[1] = GetDateTime(di.CreationTime).PadRight(17); // File_DateCreated 
                s[2] = GetDateTime(di.LastAccessTime).PadRight(17); // File_DateAccessed
                s[3] = GetDateTime(di.LastWriteTime).PadRight(17); // File_DateChanged
                string a = "";
                FileAttributes fa = di.Attributes;
                a += (fa == FileAttributes.Archive ? "A" : ".");
                a += (fa == FileAttributes.Compressed ? "C" : ".");
                a += (fa == FileAttributes.Directory ? "D" : ".");
                a += (fa == FileAttributes.Encrypted ? "E" : ".");
                a += (fa == FileAttributes.Hidden ? "H" : ".");
                a += (fa == FileAttributes.NotContentIndexed ? "." : "I");
                a += (fa == FileAttributes.Normal ? "N" : ".");
                a += (fa == FileAttributes.Offline ? "O" : ".");
                a += (fa == FileAttributes.ReparsePoint ? "P" : ".");
                a += (fa == FileAttributes.ReadOnly ? "R" : ".");
                a += (fa == FileAttributes.SparseFile ? "S" : ".");
                a += (fa == FileAttributes.Temporary ? "T" : ".");
                a += (fa == FileAttributes.Device ? "X" : ".");
                a += (fa == FileAttributes.System ? "Y" : ".");
                s[4] = a;
                string Type = "";
                string MimeType = "";
                if (fa == FileAttributes.Directory)
                {
                    Type = "Directory";
                }
                else
                {
                    FileTypeInfo fti = FileTypes.Get(Extension);
                    if (fti != null)
                    {
                        FileGroup ea = FileGroups.Get(FileTypes.Get(Extension).Type);
                        Type = ea.Description;
                        MimeType = Mime.GetMimeType(Extension); if (string.IsNullOrEmpty(MimeType)) MimeType = "";
                    }
                }
                s[5] = Type;
                s[6] = MimeType;
                return s;
            }
            private static string[] GetTitleString()
            {
                return new string[] { "Length", "Created", "LastAccess", "Changed", GetAttributesWithCaption(), "FileGroup", "MimeType" };
            }
            // Directory Properties
            public ListFileDirectory(State MyState)
                : base(MyState, "", "Name", GetTitleString())
            {
                FileInfo fi = new FileInfo(MyState.CurrentPathAbs);
                Add(fi.Name.Replace(" ", "&nbsp;"), GetItemProperties(fi, -1));
            }
            // File Properties
            public ListFileDirectory(State MyState, long Length)
                : base(MyState, "", "Name", GetTitleString())
            {
                DirectoryInfo fi = new DirectoryInfo(MyState.CurrentPathAbs);
                Add(fi.Name.Replace(" ", "&nbsp;"), GetItemProperties(fi, Length));
            }
            // Directory Content
            public ListFileDirectory(State MyState, TreeNode tn)
                : base(MyState, "Directory: " + new ItemInfo(tn.Value).name, "Name", GetTitleString())
            {
                for (int i = 0; i < tn.ChildNodes.Count; i++)
                {
                    string val = tn.ChildNodes[i].Value;
                    ItemInfo ii = new ItemInfo(val);
                    string Name = ii.name;
                    Name = Name.Replace(" ", "&nbsp;");
                    switch (ii.type)
                    {
                        case E_ObjectType.DIRECTORY:
                            Add(ii.name, GetItemProperties(new DirectoryInfo(MyState.CurrentPathAbs + "/" + ii.name), Tree.Size(tn.ChildNodes[i])));
                            break;
                        case E_ObjectType.FILE:
                            Add(ii.name, GetItemProperties(new FileInfo(MyState.CurrentPathAbs + "/" + ii.name), -1));
                            break;
                    }
                }
            }
        }

// Start of ExeListImage.cs

        public class ImageFlag
        {
            public ImageFlags Type;
            public string Name;
            public string Text;
            public ImageFlag(ImageFlags Type, string Name, string Text)
            {
                this.Type = Type;
                this.Name = Name;
                this.Text = Text;
            }
        }
        public class ListImage : MyList
        {
            string GetImageFlags(int Flags)
            {
                string s = "";
                for (int i = 0; i < imgF.Length; i++)
                {
                    if ((Flags & (int)(imgF[i])) > 0)
                        s += (s == "" ? "" : "<br/>") + FormatMyKey(imgF[i].ToString()) + "(" + (int)imgF[i] + ")";
                }
                return s;
            }
            string GetFrameDimensionsList(Guid[] FrameDimensionsList)
            {
                string s = "";
                for (int i = 0; i < FrameDimensionsList.Length; i++)
                {
                    s += (s == "" ? "" : "<br/>") + FrameDimensionsList[i] ;
                }
                return s;
            }
            string GetPropertyIdList(int[] PropertyIdList)
            {
                string s = "";
                for (int i = 0; i < PropertyIdList.Length; i++)
                {
                    s += (s == "" ? "" : "<br/>") + PropertyIdList[i];
                }
                return s;
            }
            public ListImage(State MyState, Img img)
                : base(MyState)
            {
                Add("Path", img.Path);
                Add("Flags", GetImageFlags(img.Flags));
                Add("FrameDimensionsList", GetFrameDimensionsList(img.FrameDimensionsList));
                Add("HorizontalResolution", img.dx.ToString());
                Add("PhysicalDimension.Height", img.y.ToString());
                Add("PhysicalDimension.Width", img.x.ToString());
                Add("PixelFormat", img.pf.ToString());
                Add("PropertyIdList", GetPropertyIdList(img.PropertyIdList));
                Add("RawFormat", img.Format.ToString());
                Add("Tag", (img.Tag==null ? "" : img.Tag.ToString()));
                Add("VerticalResolution", img.dy.ToString());
            }
            public ListImage(State MyState)
                : base(MyState, "Image Flags")
            {
                Add("Caching",          new string[] {ImageFlags.Caching.ToString(),          ((int)ImageFlags.Caching).ToString()});          
                Add("ColorSpaceCmyk",   new string[] {ImageFlags.ColorSpaceCmyk.ToString(),   ((int)ImageFlags.ColorSpaceCmyk).ToString()});   
                Add("ColorSpaceRgb",    new string[] {ImageFlags.ColorSpaceRgb.ToString(),    ((int)ImageFlags.ColorSpaceRgb).ToString()});     
                Add("ColorSpaceGray",   new string[] {ImageFlags.ColorSpaceGray.ToString(),   ((int)ImageFlags.ColorSpaceGray).ToString()});    
                Add("ColorSpaceYcbcr",  new string[] {ImageFlags.ColorSpaceYcbcr.ToString(),  ((int)ImageFlags.ColorSpaceYcbcr).ToString()});   
                Add("ColorSpaceYcck",   new string[] {ImageFlags.ColorSpaceYcck.ToString(),   ((int)ImageFlags.ColorSpaceYcck).ToString()});    
                Add("HasAlpha",         new string[] {ImageFlags.HasAlpha.ToString(),         ((int)ImageFlags.HasAlpha).ToString()});          
                Add("HasTranslucent",   new string[] {ImageFlags.HasTranslucent.ToString(),   ((int)ImageFlags.HasTranslucent).ToString()});    
                Add("HasRealDpi",       new string[] {ImageFlags.HasRealDpi.ToString(),       ((int)ImageFlags.HasRealDpi).ToString()});        
                Add("HasRealPixelSize", new string[] {ImageFlags.HasRealPixelSize.ToString(), ((int)ImageFlags.HasRealPixelSize).ToString()});  
                Add("None",             new string[] {ImageFlags.None.ToString(),             ((int)ImageFlags.None).ToString()});              
                Add("PartiallyScalable",new string[] {ImageFlags.PartiallyScalable.ToString(),((int)ImageFlags.PartiallyScalable).ToString()}); 
                Add("ReadOnly",         new string[] {ImageFlags.ReadOnly.ToString(),         ((int)ImageFlags.ReadOnly).ToString()}); 
                Add("Scalable",         new string[] {ImageFlags.Scalable.ToString(),         ((int)ImageFlags.Scalable).ToString()}); 
            }
            ImageFlags[] imgF = new ImageFlags[] 
            {
                ImageFlags.Caching,          
                ImageFlags.ColorSpaceCmyk,   
                ImageFlags.ColorSpaceRgb,    
                ImageFlags.ColorSpaceGray,   
                ImageFlags.ColorSpaceYcbcr,  
                ImageFlags.ColorSpaceYcck,   
                ImageFlags.HasAlpha,         
                ImageFlags.HasTranslucent,   
                ImageFlags.HasRealDpi,       
                ImageFlags.HasRealPixelSize, 
                ImageFlags.None,             
                ImageFlags.PartiallyScalable,
                ImageFlags.ReadOnly,         
                ImageFlags.Scalable
            };
        }

// Start of ExeListPermissions.cs

        public class ListPermissions : MyList
        {
            public ListPermissions(State MyState)
                : base(MyState, "Permissions")
            {
                DirectorySecurity Rights = Directory.GetAccessControl(MyState.CurrentPathAbs);
                int i = 0;
                foreach (FileSystemAccessRule fileSystemAccessRule in Rights.GetAccessRules(true, true, typeof(System.Security.Principal.NTAccount)))
                {
                    string Key = fileSystemAccessRule.IdentityReference.Value.ToString();
                    string Value = fileSystemAccessRule.FileSystemRights.ToString();
                    if (!ContainsKey(Key)) // avoid duplicate keys
                    {
                        Add(i.ToString().PadLeft(2, '0').PadRight(3) + Key, Value);
                        i++;
                    }
                }
            }
        }

// Start of ExeState.cs

        public class State
        {
            public bool UseLogin = true;
            public string Password = "SEXy";
            public bool DynamicLoadTree = false;
            public bool AutocloseTree = true;
            public int ThumbDimension = 200;
            public int ThumbCols = 3;
            public int MaxLineLength = 27;
            public int MaxLineCount = 10;
            public string RelativePath = "../";
            public string UrlJsHighlight = "http://alexgorbatchev.com/pub/sh/current/";
            public string[] IpsAllowed = new string[]
            {
                "127.0.0.1",  // localhost
                "192.168.0.107", // host in private network
                "86.59.41.251" // public host
            };

            public string OwnFile = "";
            public string RootDirFullName = "";
            public string CurrentPathRel = "";
            public string CurrentPathAbs = "";
            public E_ObjectType CurrentItemType = E_ObjectType.DIRECTORY;
            public string CurrentIcon = "";
            public string CurrentBrush = "";
            public FileGroup.Type CurrentType = FileGroup.Type.OTHER;
            public string CurrentFile = "";
            public string CurrentServer = "";
            public bool UserAccepted = false;
            public int CurrentTemplate = -1;
            public string[] RelativePathComponents = new string[] { };
            public string ApplicationPath = "/";

            public State()
            {
                // from web.config
                NameValueCollection nvc = WebConfigurationManager.AppSettings;
                UseLogin = bool.Parse(nvc["UseLogin"]);
                Password = nvc["Password"];
                DynamicLoadTree = bool.Parse(nvc["DynamicLoadTree"]);
                AutocloseTree = bool.Parse(nvc["AutocloseTree"]);
                ThumbDimension = int.Parse(nvc["ThumbDimension"]);
                ThumbCols = int.Parse(nvc["ThumbCols"]);
                MaxLineLength = int.Parse(nvc["MaxLineLength"]);
                MaxLineCount = int.Parse(nvc["MaxLineCount"]);
                RelativePath = nvc["RelativePath"];
                UrlJsHighlight = nvc["UrlJsHighlight"];
                IpsAllowed = nvc["IpsAllowed"].Split(new char[] { ',' });
            }
 
            public State(System.Web.UI.StateBag v)
            {
                UseLogin = (bool)v["UseLogin"];
                Password = (string)v["Password"];
                DynamicLoadTree = (bool)v["DynamicLoadTree"];
                AutocloseTree = (bool)v["AutocloseTree"];
                ThumbDimension = (int)v["ThumbDimension"];
                ThumbCols = (int)v["ThumbCols"];
                MaxLineLength = (int)v["MaxLineLength"];
                MaxLineCount = (int)v["MaxLineCount"];
                RelativePath = (string)v["RelativePath"];
                UrlJsHighlight = (string)v["UrlJsHighlight"];
                IpsAllowed = (string[])v["IpsAllowed"];
                // 
                OwnFile = (string)v["OwnFile"];
                RootDirFullName = (string)v["RootDirFullName"];
                CurrentPathRel = (string)v["CurrentPathRel"];
                CurrentPathAbs = (string)v["CurrentPathAbs"];
                CurrentItemType = (E_ObjectType)v["CurrentItemType"];
                CurrentIcon = (string)v["CurrentIcon"];
                CurrentBrush = (string)v["CurrentBrush"];
                CurrentType = (FileGroup.Type)v["CurrentType"];
                CurrentFile = (string)v["CurrentFile"];
                CurrentServer = (string)v["CurrentServer"];
                UserAccepted = (bool)v["UserAccepted"];
                CurrentTemplate = (int)v["CurrentTemplate"];
                RelativePathComponents = (string[])v["RelativePathComponents"];
                ApplicationPath = (string)v["ApplicationPath"];
            }
            public void SaveState(System.Web.UI.StateBag v)
            {
                v.Add("UseLogin", UseLogin);
                v.Add("Password", Password);
                v.Add("DynamicLoadTree", DynamicLoadTree);
                v.Add("AutocloseTree", AutocloseTree);
                v.Add("ThumbDimension", ThumbDimension);
                v.Add("ThumbCols", ThumbCols);
                v.Add("MaxLineLength", MaxLineLength);
                v.Add("MaxLineCount", MaxLineCount);
                v.Add("UrlJsHighlight", UrlJsHighlight);
                v.Add("RelativePath", RelativePath);
                v.Add("IpsAllowed", IpsAllowed);

                v.Add("OwnFile", OwnFile);
                v.Add("RootDirFullName", RootDirFullName);
                v.Add("CurrentPathRel", CurrentPathRel);
                v.Add("CurrentPathAbs", CurrentPathAbs);
                v.Add("CurrentItemType", CurrentItemType);
                v.Add("CurrentIcon", CurrentIcon);
                v.Add("CurrentBrush", CurrentBrush);
                v.Add("CurrentType", CurrentType);
                v.Add("CurrentFile", CurrentFile);
                v.Add("CurrentServer", CurrentServer);
                v.Add("UserAccepted", UserAccepted);
                v.Add("CurrentTemplate", CurrentTemplate);
                v.Add("RelativePathComponents", RelativePathComponents);
                v.Add("ApplicationPath", ApplicationPath);
            }
        }

// Start of ExeTreeValue.cs

        public enum E_ObjectType { DIRECTORY, FILE };
        public class ItemInfo
        {
            public E_ObjectType type;
            public long size;
            public string name;
            public ItemInfo(E_ObjectType type, long size, string name)
            {
                this.type = type;
                this.size = size;
                this.name = name;
            }
            public ItemInfo(string serial)
            {
                string[] components = serial.Split(new char[] { ValueDelimiter[0] });
                this.type = components[0] == "d" ? E_ObjectType.DIRECTORY : E_ObjectType.FILE;
                this.size = long.Parse(components[1]);
                this.name = components[2];
            }
        }

// Start of List.cs

        public class MyList : Dictionary<string, string[]>
        {
            const string PrefixForHeaderRow = "#!#";
            const string PrefixForColspan = "#>#";
            const string strStringDelimiter = ", ";
            const bool DisplayBoolAsBullet = false;
            const bool ThumbsImageNoScaleWhenSmaller = true;

            // inserted tex in lists
            protected const string strExtraMenuPoint = "--see extra menu point--";
            protected const string strComplexType = "--complex type--";
            protected const string strNotAvailable = "--not available--";
            protected const string strSeeObject = "--see detailed Object--";
            protected const string strNoData = "--no data--";
            protected const string strRequiresPipelineMode = "--requires internal pipeline mode--";
            protected const string strRequiresFramework4 = "--requires framework 4.0--";
            protected const string strDemoEntry = "--demo entry--";
            protected const string strDemoVariableName = "Demo-Variable";

            Control ThumbTemplate(string ObjectCode, string Title, bool ShowCentered, int ThumbDimension)
            {
                Table t = new Table();
                // Object
                TableRow tr = new TableRow();
                TableCell tc = new TableCell();
                tc.VerticalAlign = VerticalAlign.Top;
                tc.HorizontalAlign = HorizontalAlign.Left;
                tc.Controls.Add(new LiteralControl(ObjectCode));
                tc.Width = ThumbDimension;
                tc.Height = ThumbDimension;
                tc.BorderWidth = 1;
                tc.BorderColor = System.Drawing.Color.Gray;
                if (ShowCentered) tc.VerticalAlign = VerticalAlign.Middle;
                if (ShowCentered) tc.HorizontalAlign = HorizontalAlign.Center;
                tr.Cells.Add(tc);
                t.Rows.Add(tr);
                // Title
                tr = new TableRow();
                tc = new TableCell();
                tc.Controls.Add(new LiteralControl(Title));
                tc.BorderWidth = 1;
                tc.BorderColor = System.Drawing.Color.Gray;
                tc.VerticalAlign = VerticalAlign.Middle;
                tc.HorizontalAlign = HorizontalAlign.Center;
                tr.Cells.Add(tc);
                t.Rows.Add(tr);
                return t;
            }
            string[] MyValues = new string[] { strDemoVariableName, strExtraMenuPoint, strComplexType, strNotAvailable, strSeeObject, strNoData, strRequiresPipelineMode, strRequiresFramework4, strDemoEntry };
            string Title;
            string TitleFirstColumn;
            string[] TitleOtherColumns;
            State MyState;

            public MyList(State MyState, string Title)
            {
                this.MyState = MyState;
                this.Title = Title;
                this.TitleFirstColumn = null;
                this.TitleOtherColumns = null;
            }
            public MyList(State MyState, string Title, string TitleFirstColumn, string[] TitleOtherColumns)
            {
                this.MyState = MyState;
                this.Title = Title;
                this.TitleFirstColumn = TitleFirstColumn;
                this.TitleOtherColumns = TitleOtherColumns;
            }
            public MyList(State MyState)
            {
                this.MyState = MyState;
                this.Title = null;
            }
            public void Add(string Key, string[] Values)
            {
                base.Add(PrefixForHeaderRow + Key, Values);
            }
            public void Add(string Key, string Value)
            {
                Add(Key, new string[] { Value });
            }
            public void AddTitle(string Title, int Colspan)
            {
                string[] Values = new string[Colspan];
                for (int i = 0; i < Values.Length; i++)
                {
                    Values[i] = PrefixForColspan;
                }
                Add(Title, PrefixForColspan+Colspan);
            }
            private Control GetDataSorted(bool Sort)
            {
                Panel p = new Panel();
                if (!string.IsNullOrEmpty(Title))
                {
                    LiteralControl l = new LiteralControl("<h3>" + Title + "</h3>\r\n");
                    p.Controls.Add(l);
                }
                Table t = new Table();
                if (TitleFirstColumn != null)
                {
                    for (int i = 0; i < TitleOtherColumns.Length; i++)
                    {
                        TitleOtherColumns[i] = PrefixForHeaderRow + TitleOtherColumns[i];
                    }
                    t.Rows.Add(GetRow(TitleFirstColumn, TitleOtherColumns));
                }
                switch (Sort)
                {
                    case true:
                        SortedList<string, string[]> sl = new SortedList<string, string[]>(this);
                        foreach (KeyValuePair<string, string[]> kvp in sl)
                        {
                            t.Rows.Add(GetRow(kvp.Key, kvp.Value));
                        }
                        break;
                    case false:
                        foreach (KeyValuePair<string, string[]> kvp in this)
                        {
                            t.Rows.Add(GetRow(kvp.Key, kvp.Value));
                        }
                        break;
                }
                p.Controls.Add(t);
                return p;
            }
            public Control GetDataSorted()
            {
                return GetDataSorted(true);
            }
            public Control GetData()
            {
                return GetDataSorted(false);
            }
            /*
                Panel p = new Panel();
                if (!string.IsNullOrEmpty(Title))
                {
                    LiteralControl l = new LiteralControl("<h3>" + Title + "</h3>\r\n");
                    p.Controls.Add(l);
                }
                Table t = new Table();
                if (TitleFirstColumn != null)
                {
                    for (int i = 0; i < TitleOtherColumns.Length; i++)
                    {
                        TitleOtherColumns[i] = PrefixForHeaderRow + TitleOtherColumns[i];
                    }
                    t.Rows.Add(GetRow(TitleFirstColumn, TitleOtherColumns));
                }
                foreach (KeyValuePair<string, string[]> kvp in this)
                {
                    t.Rows.Add(GetRow(kvp.Key, kvp.Value));
                }
                p.Controls.Add(t);
                return p;
            */
            public Control GetThumbs(int ThumbDimension, int ThumbCols)
            {
                Panel p = new Panel();
                if (!string.IsNullOrEmpty(Title))
                {
                    LiteralControl l = new LiteralControl("<h3>" + Title + "</h3>\r\n");
                    p.Controls.Add(l);
                }
                Table t = new Table();
                int Index = 0;
                TableRow tr = new TableRow();
                foreach (KeyValuePair<string, string[]> kvp in this)
                {
                    string PathAbs = kvp.Key.Substring(3);
                    string PathRel = kvp.Value[0];
                    string Mode = kvp.Value[1];
                    E_ObjectCommand ModeToStart = (E_ObjectCommand)int.Parse(Mode);
                    string Type = kvp.Value[2];
                    FileGroup.Type FileType = (FileGroup.Type)int.Parse(Type);
                    string TitleObject = Path.GetFileName(PathRel);
                    string Template = "";

                    TableCell tc = new TableCell();
                    bool ShowObject = true;
                    bool ShowCentered = true;
                    switch (ModeToStart)
                    {
                        default:
                        case E_ObjectCommand.CODE:
                        case E_ObjectCommand.DIRECTORY:
                        case E_ObjectCommand.DOWNLOAD:
                        case E_ObjectCommand.EXIF:
                        case E_ObjectCommand.NONE:
                        case E_ObjectCommand.PERMISSIONS:
                        case E_ObjectCommand.SPECIAL:
                        case E_ObjectCommand.HEX:
                        case E_ObjectCommand.THUMBS:
                            ShowObject = false;
                            break;
                        case E_ObjectCommand.EMBED:
                            Img img = new Img(PathAbs);
                            const bool ThumbsImageNoScaleWhenSmaller = true;
                            int x = img.x;
                            int y = img.y;
                            int px;
                            int py;
                            // scaling
                            if ((x < ThumbDimension) && (y < ThumbDimension) && ThumbsImageNoScaleWhenSmaller)
                            {
                                px = x;
                                py = y;
                            }
                            else
                            {
                                if (x == y) { px = ThumbDimension; py = ThumbDimension; }
                                else if (x > y) { px = ThumbDimension; py = (int)((1.0 * ThumbDimension / x) * y); }
                                else { py = ThumbDimension; px = (int)((1.0 * ThumbDimension / y) * x); }
                            }
                            Template = MediaTemplates.InstantiateTemplate(0, px.ToString(), py.ToString(), PathRel);
                            break;
                        case E_ObjectCommand.FRAME:
                            Template = MediaTemplates.InstantiateTemplate(11, ThumbDimension.ToString(), ThumbDimension.ToString(), PathRel);
                            break;
                        // case E_ObjectCommand.NEWWIN:
                            //     Template = MediaTemplates.InstantiateTemplate(11, ThumbDimension.ToString(), ThumbDimension.ToString(), PathRel);
                        // break;
                        case E_ObjectCommand.LINK:
                            switch (FileType)
                            {
                                case FileGroup.Type.AUDIO:
                                case FileGroup.Type.AUDVID:
                                case FileGroup.Type.VIDEO:
                                    Template = "<div style='font-size:32pt;color:gray;'>&#x266b;</div>" + MediaTemplates.InstantiateTemplate(12, ThumbDimension.ToString(), ThumbDimension.ToString(), PathRel);
                                    break;
                                default:
                                case FileGroup.Type.APPLI:
                                case FileGroup.Type.APPLIEXE:
                                case FileGroup.Type.BINARY:
                                case FileGroup.Type.CODE:
                                case FileGroup.Type.CODEEXE:
                                case FileGroup.Type.EXIF:
                                case FileGroup.Type.IMAGE:
                                case FileGroup.Type.INLINE:
                                case FileGroup.Type.NOTYPE:
                                case FileGroup.Type.OTHER:
                                    ShowObject = false;
                                    break;
                            }
                            break;
                        case E_ObjectCommand.TEXT:
                            Template = Untag(SplitLongLines(File.ReadAllText(PathAbs)));
                            ShowCentered = false;
                            break;
                        case E_ObjectCommand.INLINE:
                            Template = File.ReadAllText(PathAbs);
                            break;
                    }
                    if (ShowObject)
                    {
                        tc.Controls.Add(ThumbTemplate(Template, TitleObject, ShowCentered, ThumbDimension));
                        tr.Cells.Add(tc);
                        Index++;
                        if (Index % ThumbCols == 0)
                        {
                            t.Rows.Add(tr);
                            tr = new TableRow();
                        }
                    }
                }
                if (tr.Cells.Count > 0)
                    t.Rows.Add(tr);
                p.Controls.Add(t);
                return p;
            }
            private string MarkMyValues(string Text)
            {
                if (string.IsNullOrEmpty(Text)) return "";
                for (int i = 0; i < MyValues.Length; i++)
                {
                    if (Text.Contains(MyValues[i]))
                    {
                        Text = Text.Replace(MyValues[i], "<span class='MyValue'>" + MyValues[i] + "</span>");
                    }
                }
                return Text;
            }
            private TableCell GetCell(string Content)
            {
                TableCell tc = new TableCell();
                Label lb = new Label();
                string c = Content == null ? "" : Content.ToString();
                bool isHeader = false;
                if (c.StartsWith(PrefixForHeaderRow))
                {
                    isHeader = true;
                    c = c.Substring(PrefixForHeaderRow.Length);
                }
                if (c.ToLower() == "false") c = "<span class='LB'>" + (DisplayBoolAsBullet ? "&#x25cb;" : "-") + "</span>";
                if (c.ToLower() == "true") c = "<span class='LB'>" + (DisplayBoolAsBullet ? "&#x25cf;" : "+") + "</span>";
                lb.Text = c;
                tc.Controls.Add(lb);
                tc.VerticalAlign = VerticalAlign.Top;
                tc.CssClass = isHeader ? "LH" : "";
                return tc;
            }
            private TableRow GetRow(string Left, string Right)
            {
                return GetRow(Left, new string[] { Right });
            }
            private TableRow GetRow(string Left, string[] Right)
            {
                TableRow tr = new TableRow();
                TableCell tc = GetCell(Left);
                if (Right!=null)
                    if (Right[0]!=null)
                        if (Right[0].StartsWith(PrefixForColspan))
                        {
                            tc.ColumnSpan = int.Parse(Right[0].Remove(0, PrefixForColspan.Length));
                            tr.Cells.Add(tc);
                            return tr;
                        }
                tr.Cells.Add(tc);
                for (int i = 0; i < Right.Length; i++)
                {
                    tr.Cells.Add(GetCell(MarkMyValues(Right[i])));
                }
                return tr;
            }
            protected string FormatMyText(string Text)
            {
                return "<span class='MyValue'>" + Text + "</span>";
            }
            protected string FormatMyKey(string Text)
            {
                return "<span class='LH'>" + Text + "</span>";
            }
            protected string GetDictionary(System.Collections.IDictionary id)
            {
                string dictionary = "";
                foreach (System.Collections.DictionaryEntry Entry in id)
                {
                    dictionary += FormatMyKey(Entry.Key.ToString()) + FormatMyText("=") + Entry.Value + "<br/>";
                }
                return dictionary;
            }
            protected string GetNameValueCollection(System.Collections.Specialized.NameValueCollection nvc)
            {
                string result = "";
                for (int i = 0; i < nvc.Count; i++)
                {
                    result += FormatMyKey(nvc.Keys[i]) + FormatMyText("=") + Untag(nvc[i]) + "<br/>";
                }
                return result;
            }
            protected string GetStringArray(string[] StringArray)
            {
                string s = "";
                if (StringArray == null) return "";
                if (StringArray.Length == 0) return "";
                for (int i = 0; i < StringArray.Length; i++)
                {
                    if (StringArray[i] == "") continue;
                    s += (s == "" ? "" : strStringDelimiter) + StringArray[i];
                }
                return Untag(s);
            }
            protected string GetArrayList(ArrayList al)
            {
                string strAl = "";
                if (al == null) return strNoData;
                for (int i = 0; i < al.Count; i++)
                {
                    strAl += al[i] + "<br/>";
                }
                return strAl;
            }
            protected string SplitLongLine(string Text)
            {
                int Length = Text.Length;
                if (Length <= MyState.MaxLineLength) return Text;
                string NewText = "";
                int Parts = Text.Length / MyState.MaxLineLength;
                for (int i = 0; i <= Parts; i++)
                {
                    int Start = i * MyState.MaxLineLength; if (Start > Length) break;
                    int LengthOfPart = MyState.MaxLineLength;
                    if ((Start + LengthOfPart) > Length) LengthOfPart = Length - Start;
                    NewText += Text.Substring(i * MyState.MaxLineLength, LengthOfPart) + " ";
                }
                return NewText;
            }
            protected string SplitLongLines(string Text)
            {
                Text = Regex.Replace(Text, "  ", " ");
                string[] Lines = Text.Split(new char[] { ' ' });
                Text = "";
                for (int i = 0; i < Lines.Length; i++)
                {
                    Text += SplitLongLine(Lines[i]) + " ";
                    if (i >= MyState.MaxLineCount)
                    {
                        Text += "...";
                        break;
                    }
                }
                return Text;
            }
        }

// Start of ListExplorerAbout.cs

        public class ListAbout : MyList
        {
            public ListAbout(State MyState) : base(MyState, "About this program")
            {
                Add("Title", "SEX Server EXplorer");
                Add("Uses", "SyntaxHighlighter from Alex Gorbatchev");
                Add("Requires", "ASP.NET 2.0 (Compiled Version), ASP.Net 4.0 (Single File Version)");
                Add("ProjectHome", "http://sex.codeplex.com/");
                Add("Documentation", "<a href='http://pcnews.at/?id=pcn127' target='_blank'>PCNEWS-127</a>");
                Add("Author", "Franz Fiala, Siccardsburggasse 4/1/22, 1100 Wien, Austria, franz {at} fiala.cc");
            }
        }

// Start of ListExplorerAttributes.cs

        public class ListAttributes : MyList
        {
            public ListAttributes(State MyState)
                : base(MyState, "List of file or directory attributes")
            {
                Add("A", "Archive");
                Add("C", "Compressed");
                Add("D", "Directory");
                Add("E", "Encrypted");
                Add("H", "Hidden");
                Add("I", "Indexed");
                Add("N", "Normal");
                Add("O", "Offline");
                Add("P", "Reparse Point");
                Add("R", "Read Only");
                Add("S", "Sparse File");
                Add("T", "Temporary");
                Add("X", "Device");
                Add("Y", "System");                
            }
        }

// Start of ListExplorerExif.cs

        public class ListExifAll : MyList
        {
            public ListExifAll(State MyState) : base(MyState, "Exif Data", "Id-Dec", new string[] { "Id-Hex", "ShortName" })
            {
                for (int i = 0; i < Exif.Entries.Length; i++)
                {
                    Add(Exif.Entries[i].Id.ToString().PadLeft(5, '0'), new string[] 
                    { 
                        Hex.ToHex(Exif.Entries[i].Id),
                        Exif.Entries[i].Name
                    });
                }
            }
        }

// Start of ListExplorerExtensions.cs

        public class ListExtensions : MyList
        {
            public ListExtensions(State MyState)
                : base(MyState, "File Extensions", "Extension", new string[] { "FileType", "Brush", "Template", "Mime-Type" })
            {
                for (int i = 0; i < FileTypes.list.Count; i++)
                {
                    string TemplateId = FileTypes.list[i].MediaTemplateId.ToString();
                    string Extension = FileTypes.list[i].Extension;
                    if (TemplateId == "-1") TemplateId = "";
                    Add(Extension, new string[] { FileTypes.list[i].Type.ToString(), FileTypes.list[i].brush, TemplateId, Mime.GetMimeType(Extension) });
                }
            }
        }

// Start of ListExplorerFileGroups.cs

        public class ListFileGroups : MyList
        {
            public ListFileGroups(State MyState)
                : base(MyState, "File Groups", "File Group", new string[] { "Extension", "Start mode", "Show CODE", "Show DOWNLOAD", "Show EMBED", "Show EXIF", "Show FRAME", "Show HEX", "Show INLINE", "Show PERMISSIONS", "Show SPECIAL" })
            {
                for (int i = 0; i < FileGroups.list.Count; i++)
                {
                    string Extensions = "";
                    for (int j = 0; j < FileTypes.list.Count; j++)
                    {
                        if (FileTypes.list[j].Type == FileGroups.list[i].FileType)
                            Extensions += (Extensions == "" ? "" : ", ") + FileTypes.list[j].Extension;
                    }
                    Add(FileGroups.list[i].FileType.ToString(), new string[] 
                    { 
                        // FileGroups.list[i].Description,
                        Extensions,
                        FileGroups.list[i].ShowFirst.ToString(), 
                        FileGroups.list[i].ShowCode.ToString(),
                        FileGroups.list[i].ShowDownload.ToString(),
                        FileGroups.list[i].ShowEmbedded.ToString(),
                        FileGroups.list[i].ShowExif.ToString(),
                        FileGroups.list[i].ShowFrame.ToString(),
                        FileGroups.list[i].ShowHex.ToString(),
                        FileGroups.list[i].ShowInline.ToString(),
                        FileGroups.list[i].ShowPermissions.ToString(),
                        FileGroups.list[i].ShowSpecial.ToString()
                    });
                }
            }
        }

// Start of ListExplorerMimeTypes.cs

        public class ListMimeByExtension : MyList
        {
            public ListMimeByExtension(State MyState)
                : base(MyState, "Mime Types")
            {
                if (Mime.mimemap.Count == 0) Mime.BuildMimeMap();
                foreach (string key in Mime.mimemap)
                {
                    Add(key, Mime.mimemap[key]);
                }
            }
        }
        public class ListMimeByType : MyList
        {
            public ListMimeByType(State MyState)
                : base(MyState, "Mime Types")
            {
                if (Mime.mimemap.Count == 0) Mime.BuildMimeMap();
                List<string> Types = new List<string>();
                for (int i = 0; i < Mime.mimemap.Count; i++)
                {
                    if (!Types.Contains(Mime.mimemap[i]))
                        Types.Add(Mime.mimemap[i]);
                }
                Types.Sort();
                foreach (string Type in Types)
                {
                    string s = "";
                    for (int i = 0; i < Mime.mimemap.Count; i++)
                    {
                        if (Mime.mimemap[i] == Type)
                            s += (s == "" ? "" : ", ") + Mime.mimemap.Keys[i];
                    }
                    Add(Type, s);
                }
            }
        }

// Start of ListExplorerTemplates.cs

        public class ListTemplates : MyList
        {
            public ListTemplates(State MyState)
                : base(MyState, "Media Templates" + GetHtmlJsHighlightReduced(MyState, "xml"), "Id", new string[] { "Name", "IMAGE", "AUDIO", "VIDEO", "TEMPLATE" })
            {
                for (int i = 0; i < MediaTemplates.list.Count; i++)
                {
                    Add(MediaTemplates.list[i].Id.ToString().PadLeft(2,'0'), new string[] 
                    { 
                        MediaTemplates.list[i].Name,
                        MediaTemplates.list[i].UseWithImage.ToString(),
                        MediaTemplates.list[i].UseWithAudio.ToString(),
                        MediaTemplates.list[i].UseWithVideo.ToString(),
                        GetHighlightCode(MediaTemplates.list[i].InstantiateTemplate("320", "200", "file.ext"), "xml")
                    });
                }
            }
        }

// Start of ListExplorerViewState.cs

        public class ListViewState : MyList
        {
            string GetError(System.Exception e)
            {
                if (e == null) return strNoData;
                string s = "";
                s += FormatMyKey("Data") + FormatMyText("=") + GetDictionary(e.Data) + "<br/>";
                s += FormatMyKey("HelpLink") + FormatMyText("=") + e.HelpLink + "<br/>";
                s += FormatMyKey("InnerException") + FormatMyText("=") + e.InnerException.ToString() + "<br/>";
                s += FormatMyKey("Message") + FormatMyText("=") + e.Message + "<br/>";
                s += FormatMyKey("Source") + FormatMyText("=") + e.Source + "<br/>";
                s += FormatMyKey("StackTrace") + FormatMyText("=") + e.StackTrace + "<br/>";
                s += FormatMyKey("TargetSite.Name") + FormatMyText("=") + e.TargetSite.Name;
                return s;
            }
            string GetErrors(System.Exception[] e)
            {
                string s = "";
                for (int i = 0; i < s.Length; i++)
                    s += FormatMyKey("Error " + i.ToString().PadLeft(2, '0')) + "<br/>" + GetError(e[i]);
                return s;
            }
            public ListViewState(State MyState, System.Web.UI.StateBag v)
                : base(MyState, "ViewState Objects")
            {
                if (v == null) Add("ListView", strNoData);
                if (v.Count == 0) Add("ListView", strNoData);
                IDictionaryEnumerator myDictionaryEnumerator = v.GetEnumerator();
                ICollection keys = v.Keys;
                foreach(string k in keys)
                {
                    switch (v[k].GetType().ToString())
                    {
                        default:
                        case "System.String":
                            Add(k, (v[k]).ToString());
                            break;
                        case "System.String[]":
                            string ss = "";
                            string[] s = ((string[])v[k]);
                            for (int i = 0; i < s.Length; i++)
                                ss += (ss == "" ? "" : ", ") + s[i];
                            Add(k, ss);
                            break;
                    }
                }
            }
        }

// Start of ListServer.cs

        public class ListServer : MyList
        {
            public ListServer(State MyState)
                : base(MyState, "Server Object")
            {
                HttpContext myHttpContext = HttpContext.Current;
                Add("Server.MachineName", myHttpContext.Server.MachineName);
                Add("Server.ScriptTimeout (s)", myHttpContext.Server.ScriptTimeout.ToString());
            }
        }

// Start of ListServerApplication.cs

        public class ListApplication : MyList
        {
            HttpApplicationState a;
            string GetKeyList(string[] Keys)
            {
                string KeyList = "";
                foreach (string Key in Keys)
                {
                    KeyList += Key + " ";
                }
                return KeyList;
            }
            string GetStaticObjects()
            {
                string StaticObjects = "";
                HttpStaticObjectsCollection hsoc = a.StaticObjects;
                foreach (string Key in hsoc)
                {
                    StaticObjects += hsoc[StaticObjects] + " ";
                }
                return StaticObjects;
            }
            public ListApplication(State MyState)
                : base(MyState, "Application Object")
            {
                HttpContext myHttpContext = HttpContext.Current;
                a = myHttpContext.Application;
                a.Add(strDemoVariableName, strDemoEntry);
                string s = (string)a["Demo"];
                Add("Application.AllKeys", GetKeyList(a.AllKeys));
                foreach (string Key in a.AllKeys)
                {
                    string Value = (string)a.Get(Key);
                    s += FormatMyKey(Key) + FormatMyText("=") + Value + "<br/>";
                }
                Add("Application.AllKeys & Values", s);
                Add("Application.Count", a.Count.ToString());
                Add("Application.StaticObjects", GetStaticObjects());

                a = myHttpContext.Application;
            }
        }

// Start of ListServerBrowser.cs

        // http://msdn.microsoft.com/en-us/library/3yekbd5b.aspx
        // http://msdn.microsoft.com/en-us/library/ms228122.aspx (Browser Definition File Schema)
        public class ListBrowser : MyList
        {
            HttpBrowserCapabilities bc;

            public ListBrowser(State MyState)
                : base(MyState, "Browser Object")
            {
                HttpContext myHttpContext = HttpContext.Current;
                bc = myHttpContext.Request.Browser;

                Add("Browser.ActiveXControls", bc.ActiveXControls.ToString());
                Add("Browser.Adapters", GetDictionary(bc.Adapters));
                Add("Browser.AOL", bc.AOL.ToString());
                Add("Browser.BackgroundSounds", bc.BackgroundSounds.ToString());
                Add("Browser.Beta", bc.Beta.ToString());
                Add("Browser.Browser", bc.Browser);
                Add("Browser.Browsers.Count", bc.Browsers.Count.ToString());
                Add("Browser.Browsers", GetArrayList(bc.Browsers));
                Add("Browser.CanCombineFormsInDeck", bc.CanCombineFormsInDeck.ToString());
                Add("Browser.CanInitiateVoiceCall", bc.CanInitiateVoiceCall.ToString());
                Add("Browser.CanRenderAfterInputOrSelectElement", bc.CanRenderAfterInputOrSelectElement.ToString());
                Add("Browser.CanRenderEmptySelects", bc.CanRenderEmptySelects.ToString());
                Add("Browser.CanRenderInputAndSelectElementsTogether", bc.CanRenderInputAndSelectElementsTogether.ToString());
                Add("Browser.CanRenderMixedSelects", bc.CanRenderMixedSelects.ToString());
                Add("Browser.CanRenderOneventAndPrevElementsTogether", bc.CanRenderOneventAndPrevElementsTogether.ToString());
                Add("Browser.CanRenderPostBackCards", bc.CanRenderPostBackCards.ToString());
                Add("Browser.CanRenderSetvarZeroWithMultiSelectionList", bc.CanRenderSetvarZeroWithMultiSelectionList.ToString());
                Add("Browser.CanSendMail", bc.CanSendMail.ToString());
                Add("Browser.Capabilities[\"\"]", bc.Capabilities[""].ToString());
                Add("Browser.Capabilities", GetDictionary(bc.Capabilities)); 
                Add("Browser.CDF", bc.CDF.ToString());
                Add("Browser.ClrVersion", bc.ClrVersion.ToString());
                Add("Browser.Cookies", bc.Cookies.ToString());
                Add("Browser.Crawler", bc.Crawler.ToString());
                Add("Browser.DefaultSubmitButtonLimit", bc.DefaultSubmitButtonLimit.ToString());
                Add("Browser.EcmaScriptVersion", bc.EcmaScriptVersion.ToString());
                Add("Browser.Frames", bc.Frames.ToString());
                Add("Browser.GatewayMajorVersion", bc.GatewayMajorVersion.ToString());
                Add("Browser.GatewayMinorVersion", bc.GatewayMinorVersion.ToString());
                Add("Browser.GatewayVersion", bc.GatewayVersion.ToString());
                Add("Browser.HasBackButton", bc.HasBackButton.ToString());
                Add("Browser.HidesRightAlignedMultiselectScrollbars", bc.HidesRightAlignedMultiselectScrollbars.ToString());
                Add("Browser.HtmlTextWriter", bc.HtmlTextWriter);
                Add("Browser.Id", bc.Id.ToString());
                Add("Browser.InputType", bc.InputType.ToString());
                Add("Browser.IsColor", bc.IsColor.ToString());
                Add("Browser.IsMobileDevice", bc.IsMobileDevice.ToString());
                Add("Browser.JavaApplets", bc.JavaApplets.ToString());
                Add("Browser.JavaScript (use ECMASCRIPT)", bc.JavaScript.ToString());
                Add("Browser.JScriptVersion (use ECMASCRIPT)", bc.JScriptVersion.ToString());
                Add("Browser.MajorVersion", bc.MajorVersion.ToString());
                Add("Browser.MaximumHrefLength", bc.MaximumHrefLength.ToString());
                Add("Browser.MaximumRenderedPageSize", bc.MaximumRenderedPageSize.ToString());
                Add("Browser.MaximumSoftkeyLabelLength", bc.MaximumSoftkeyLabelLength.ToString());
                Add("Browser.MinorVersion", bc.MinorVersion.ToString());
                Add("Browser.MinorVersionString", bc.MinorVersionString.ToString());
                Add("Browser.MobileDeviceManufacturer", bc.MobileDeviceManufacturer.ToString());
                Add("Browser.MobileDeviceModel", bc.MobileDeviceModel.ToString());
                Add("Browser.MSDomVersion", bc.MSDomVersion.ToString());
                Add("Browser.NumberOfSoftkeys", bc.NumberOfSoftkeys.ToString());
                Add("Browser.Platform", bc.Platform.ToString());
                Add("Browser.PreferredImageMime", bc.PreferredImageMime.ToString());
                Add("Browser.PreferredRenderingMime", bc.PreferredRenderingMime.ToString());
                Add("Browser.PreferredRenderingType", bc.PreferredRenderingType.ToString());
                Add("Browser.PreferredRequestEncoding", bc.PreferredRequestEncoding);
                Add("Browser.PreferredResponseEncoding", bc.PreferredResponseEncoding);
                Add("Browser.RendersBreakBeforeWmlSelectAndInput", bc.RendersBreakBeforeWmlSelectAndInput.ToString());
                Add("Browser.RendersBreaksAfterHtmlLists", bc.RendersBreaksAfterHtmlLists.ToString());
                Add("Browser.RendersBreaksAfterWmlAnchor", bc.RendersBreaksAfterWmlAnchor.ToString());
                Add("Browser.RendersBreaksAfterWmlInput", bc.RendersBreaksAfterWmlInput.ToString());
                Add("Browser.RendersWmlDoAcceptsInline", bc.RendersWmlDoAcceptsInline.ToString());
                Add("Browser.RendersWmlSelectsAsMenuCards", bc.RendersWmlSelectsAsMenuCards.ToString());
                Add("Browser.RequiredMetaTagNameValue", bc.RequiredMetaTagNameValue);
                Add("Browser.RequiresAttributeColonSubstitution", bc.RequiresAttributeColonSubstitution.ToString());
                Add("Browser.RequiresContentTypeMetaTag", bc.RequiresContentTypeMetaTag.ToString());
                Add("Browser.RequiresControlStateInSession", bc.RequiresControlStateInSession.ToString());
                Add("Browser.RequiresDBCSCharacter", bc.RequiresDBCSCharacter.ToString());
                Add("Browser.RequiresHtmlAdaptiveErrorReporting", bc.RequiresHtmlAdaptiveErrorReporting.ToString());
                Add("Browser.RequiresLeadingPageBreak", bc.RequiresLeadingPageBreak.ToString());
                Add("Browser.RequiresNoBreakInFormatting", bc.RequiresNoBreakInFormatting.ToString());
                Add("Browser.RequiresOutputOptimization", bc.RequiresOutputOptimization.ToString());
                Add("Browser.RequiresPhoneNumbersAsPlainText", bc.RequiresPhoneNumbersAsPlainText.ToString());
                Add("Browser.RequiresSpecialViewStateEncoding", bc.RequiresSpecialViewStateEncoding.ToString());
                Add("Browser.RequiresUniqueFilePathSuffix", bc.RequiresUniqueFilePathSuffix.ToString());
                Add("Browser.RequiresUniqueHtmlCheckboxNames", bc.RequiresUniqueHtmlCheckboxNames.ToString());
                Add("Browser.RequiresUniqueHtmlInputNames", bc.RequiresUniqueHtmlInputNames.ToString());
                Add("Browser.RequiresUrlEncodedPostfieldValues", bc.RequiresUrlEncodedPostfieldValues.ToString());
                Add("Browser.ScreenBitDepth", bc.ScreenBitDepth.ToString());
                Add("Browser.ScreenCharactersHeight", bc.ScreenCharactersHeight.ToString());
                Add("Browser.ScreenCharactersWidth", bc.ScreenCharactersWidth.ToString());
                Add("Browser.ScreenPixelsHeight", bc.ScreenPixelsHeight.ToString());
                Add("Browser.ScreenPixelsWidth", bc.ScreenPixelsWidth.ToString());
                Add("Browser.SupportsAccesskeyAttribute", bc.SupportsAccesskeyAttribute.ToString());
                Add("Browser.SupportsBodyColor", bc.SupportsBodyColor.ToString());
                Add("Browser.SupportsBold", bc.SupportsBold.ToString());
                Add("Browser.SupportsCacheControlMetaTag", bc.SupportsCacheControlMetaTag.ToString());
                Add("Browser.SupportsCallback", bc.SupportsCallback.ToString());
                Add("Browser.SupportsCss", bc.SupportsCss.ToString());
                Add("Browser.SupportsDivAlign", bc.SupportsDivAlign.ToString());
                Add("Browser.SupportsDivNoWrap", bc.SupportsDivNoWrap.ToString());
                Add("Browser.SupportsEmptyStringInCookieValue", bc.SupportsEmptyStringInCookieValue.ToString());
                Add("Browser.SupportsFontColor", bc.SupportsFontColor.ToString());
                Add("Browser.SupportsFontName", bc.SupportsFontName.ToString());
                Add("Browser.SupportsFontSize", bc.SupportsFontSize.ToString());
                Add("Browser.SupportsImageSubmit", bc.SupportsImageSubmit.ToString());
                Add("Browser.SupportsIModeSymbols", bc.SupportsIModeSymbols.ToString());
                Add("Browser.SupportsInputIStyle", bc.SupportsInputIStyle.ToString());
                Add("Browser.SupportsInputMode", bc.SupportsInputMode.ToString());
                Add("Browser.SupportsItalic", bc.SupportsItalic.ToString());
                Add("Browser.SupportsJPhoneMultiMediaAttributes", bc.SupportsJPhoneMultiMediaAttributes.ToString());
                Add("Browser.SupportsJPhoneSymbols", bc.SupportsJPhoneSymbols.ToString());
                Add("Browser.SupportsQueryStringInFormAction", bc.SupportsQueryStringInFormAction.ToString());
                Add("Browser.SupportsRedirectWithCookie", bc.SupportsRedirectWithCookie.ToString());
                Add("Browser.SupportsSelectMultiple", bc.SupportsSelectMultiple.ToString());
                Add("Browser.SupportsUncheck", bc.SupportsUncheck.ToString());
                Add("Browser.SupportsXmlHttp", bc.SupportsXmlHttp.ToString());
                Add("Browser.Tables", bc.Tables.ToString());
                // Add("Browser.TagWriter", bc.TagWriter.ToString());
                Add("Browser.Type", bc.Type.ToString());
                Add("Browser.UseOptimizedCacheKey", bc.UseOptimizedCacheKey.ToString());
                Add("Browser.VBScript", bc.VBScript.ToString());
                Add("Browser.Version", bc.Version.ToString());
                Add("Browser.W3CDomVersion", bc.W3CDomVersion.ToString());
                Add("Browser.Win16", bc.Win16.ToString());
                Add("Browser.Win32", bc.Win32.ToString());
            }
        }

// Start of ListServerContext.cs

        public class ListContext : MyList
        {
            string GetError(System.Exception e)
            {
                if (e == null) return strNoData;
                string s = "";
                s += FormatMyKey("Data") + FormatMyText("=") + GetDictionary(e.Data) + "<br/>";
                s += FormatMyKey("HelpLink") + FormatMyText("=") + e.HelpLink + "<br/>";
                s += FormatMyKey("InnerException") + FormatMyText("=") + e.InnerException.ToString() + "<br/>";
                s += FormatMyKey("Message") + FormatMyText("=") + e.Message + "<br/>";
                s += FormatMyKey("Source") + FormatMyText("=") + e.Source + "<br/>";
                s += FormatMyKey("StackTrace") + FormatMyText("=") + e.StackTrace + "<br/>";
                s += FormatMyKey("TargetSite.Name") + FormatMyText("=") + e.TargetSite.Name;
                return s;
            }
            string GetErrors(System.Exception[] e)
            {
                string s = "";
                for (int i = 0; i < s.Length; i++)
                    s += FormatMyKey("Error " + i.ToString().PadLeft(2, '0')) + "<br/>" + GetError(e[i]);
                return s;
            }
            public ListContext(State MyState)
                : base(MyState, "Context Object")
            {
                HttpContext c = HttpContext.Current;
                c.Items.Add(strDemoVariableName, strDemoEntry);

                Add("AllErrors", c.AllErrors==null ? "null" : c.AllErrors.Length.ToString());
                Add("Application", strSeeObject);
                Add("CurrentHandler", c.CurrentHandler.ToString());
                try
                {
                    Add("CurrentNotification", c.CurrentNotification.ToString());
                }
                catch
                {
                    Add("CurrentNotification", strRequiresPipelineMode);
                }
                Add("GetError", GetError(c.Error));
                Add("Handler", c.Handler.ToString());
                Add("IsCustomErrorEnabled", c.IsCustomErrorEnabled.ToString());
                Add("IsDebuggingEnabled", c.IsDebuggingEnabled.ToString());
                try
                {
                    Add("IsPostNotification", c.IsPostNotification.ToString());
                }
                catch
                {
                    Add("IsPostNotification", strRequiresPipelineMode);
                }
                Add("Items", GetDictionary(c.Items));
                Add("PreviousHandler", c.PreviousHandler == null ? strNoData : c.PreviousHandler.ToString());
                Add("Profile.UserName", c.Profile.UserName);
                Add("Request", strSeeObject);
                Add("Response", strSeeObject);
                Add("Server", strSeeObject);
                Add("Session", strSeeObject);
                Add("SkipAuthorization", c.SkipAuthorization.ToString());
                Add("Timestamp", c.Timestamp.ToString());
                Add("Trace.IsEnabled", c.Trace.IsEnabled.ToString());
                Add("Trace.TraceMode", c.Trace.TraceMode.ToString());
                Add("User.Identity.Name", c.User.Identity.Name);
            }
        }

// Start of ListServerCookies.cs

        class ListCookies : MyList
        {
            string GetCookieProperties(System.Web.HttpCookie c)
            {
                string result = "";
                result += FormatMyKey("Domain") + FormatMyText("=") + c.Domain + "<br/>";
                result += FormatMyKey("Expires") + FormatMyText("=") + c.Expires + "<br/>";
                result += FormatMyKey("HttpOnly") + FormatMyText("=") + c.HttpOnly + "<br/>";
                result += FormatMyKey("HasKeys") + FormatMyText("=") + c.HasKeys + "<br/>";
                result += FormatMyKey("Name") + FormatMyText("=") + c.Name + "<br/>";
                result += FormatMyKey("Path") + FormatMyText("=") + c.Path + "<br/>";
                result += FormatMyKey("Secure") + FormatMyText("=") + c.Secure + "<br/>";
                result += FormatMyKey("Value") + FormatMyText("=") + Untag(c.Value) + "<br/>";
                return result;
            }
            public ListCookies(State MyState)
                : base(MyState, "Cookies Object")
            {
                HttpContext myHttpContext = HttpContext.Current;
                HttpCookie MyCookie = new HttpCookie(strDemoVariableName, strDemoEntry);
                myHttpContext.Response.Cookies.Add(MyCookie);
                int c = 0;
                AddTitle("Request-Cookies", 2);
                for (int i = 0; i < myHttpContext.Request.Cookies.Count; i++)
                {
                    Add("Request" + c.ToString().PadLeft(2,'0') + ":" + myHttpContext.Request.Cookies[i].Name, GetCookieProperties(myHttpContext.Request.Cookies[i]));
                    c++;
                }
                c = 0;
                AddTitle("Response-Cookies", 2);
                for (int i = 0; i < myHttpContext.Response.Cookies.Count; i++)
                {
                    Add("Response" + c.ToString().PadLeft(2, '0') + ":" + myHttpContext.Response.Cookies[i].Name, GetCookieProperties(myHttpContext.Response.Cookies[i]));
                    c++;
                }
            }
        }

// Start of ListServerEnvironment.cs

        class ListEnvironment : MyList
        {
            public ListEnvironment(State MyState)
                : base(MyState, "Environment")
            {
                AddTitle("Framework Version", 2);

                string FrameWorkVersions = "";
                foreach (AssemblyName an in Assembly.GetExecutingAssembly().GetReferencedAssemblies())
                {
                    if (an.Name == "mscorlib")
                        FrameWorkVersions += an.Version.ToString() + "<br/>";
                }
                Add("FrameWorkVersion", FrameWorkVersions);

                string user = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
                Add("User", user);
                // p.Controls.Add(GetData());

                AddTitle("Environment", 2);

                Add("CommandLine", Environment.CommandLine);
                Add("CurrentDirectory", Environment.CurrentDirectory);
                Add("EnvironmentVariables", GetDictionary(Environment.GetEnvironmentVariables()));
                Add("ExitCode", Environment.ExitCode.ToString());
                Add("MachineName", Environment.MachineName);
                Add("NewLine", Hex.ToHex(Environment.NewLine));
                Add("OSVersion", Environment.OSVersion.ToString());
                Add("ProcessorCount", Environment.ProcessorCount.ToString());
                Add("StackTrace", Environment.StackTrace);
                Add("SystemDirectory", Environment.SystemDirectory);
                Add("TickCount", Environment.TickCount.ToString());
                Add("UserDomainName", Environment.UserDomainName);
                Add("UserInteractive", Environment.UserInteractive.ToString());
                Add("UserName", Environment.UserName);
                Add("Version", Environment.Version.ToString());
                Add("WorkingSet", Environment.WorkingSet.ToString());
#if Framework4
                try
                {
                    Add("Is64BitOperatingSystem", Environment.Is64BitOperatingSystem.ToString());
                }
                catch
                {
                    Add("Is64BitOperatingSystem", strRequiresFramework4);
                }
                try
                {
                    Add("Is64BitProcess", Environment.Is64BitProcess.ToString());
                }
                catch
                {
                    Add("Is64BitProcess", strRequiresFramework4);
                }
                try
                {
                    Add("SystemPageSize", Environment.SystemPageSize.ToString());
                }
                catch
                {
                    Add("SystemPageSize", strRequiresFramework4);
                }
#endif
            }
        }

// Start of ListServerMobile.cs

        public class ListMobile : MyList
        {
            // http://www.codeproject.com/Articles/34422/Detecting-a-mobile-browser-in-ASP-NET
            public static string[] mobiles =
                new[]
                    {
                        "midp", "j2me", "avant", "docomo", 
                        "novarra", "palmos", "palmsource", 
                        "240x320", "opwv", "chtml",
                        "pda", "windows ce", "mmp/", 
                        "blackberry", "mib/", "symbian", 
                        "wireless", "nokia", "hand", "mobi",
                        "phone", "cdm", "up.b", "audio", 
                        "SIE-", "SEC-", "samsung", "HTC", 
                        "mot-", "mitsu", "sagem", "sony", "alcatel", "lg", "eric", "vx", 
                        "NEC", "philips", "mmm", "xx", 
                        "panasonic", "sharp", "wap", "sch",
                        "rover", "pocket", "benq", "java", 
                        "pt", "pg", "vox", "amoi", 
                        "bird", "compal", "kg", "voda",
                        "sany", "kdd", "dbt", "sendo", 
                        "sgh", "gradi", "jb", "dddi", 
                        "moto", "iphone"
                    };

            public static bool isMobileBrowser()
            {
                //GETS THE CURRENT USER CONTEXT
                HttpContext context = HttpContext.Current;

                //FIRST TRY BUILT IN ASP.NT CHECK
                if (context.Request.Browser.IsMobileDevice)
                {
                    return true;
                }
                //THEN TRY CHECKING FOR THE HTTP_X_WAP_PROFILE HEADER
                if (context.Request.ServerVariables["HTTP_X_WAP_PROFILE"] != null)
                {
                    return true;
                }
                //THEN TRY CHECKING THAT HTTP_ACCEPT EXISTS AND CONTAINS WAP
                if (context.Request.ServerVariables["HTTP_ACCEPT"] != null &&
                    context.Request.ServerVariables["HTTP_ACCEPT"].ToLower().Contains("wap"))
                {
                    return true;
                }
                //AND FINALLY CHECK THE HTTP_USER_AGENT 
                //HEADER VARIABLE FOR ANY ONE OF THE FOLLOWING
                if (context.Request.ServerVariables["HTTP_USER_AGENT"] != null)
                {
                    //Create a list of all mobile types
                    //Loop through each item in the list created above 
                    //and check if the header contains that text
                    foreach (string s in mobiles)
                    {
                        if (context.Request.ServerVariables["HTTP_USER_AGENT"].ToLower().Contains(s.ToLower()))
                        {
                            return true;
                        }
                    }
                }

                return false;
            }
            public static bool UserAgentContainsMobile()
            {
                HttpContext context = HttpContext.Current;
                if (context.Request.ServerVariables["HTTP_USER_AGENT"] == null) return false;
                foreach (string s in mobiles)
                {
                    if (context.Request.ServerVariables["HTTP_USER_AGENT"].ToLower().Contains(s.ToLower()))
                    {
                        return true;
                    }
                }
                return false;
            }
            public ListMobile(State MyState)
                : base(MyState, "Mobile Detection")
            {
                HttpContext context = HttpContext.Current; 
                Add("Request.Browser.IsMobileDevice", context.Request.Browser.IsMobileDevice.ToString());
                string http_wap_profile = context.Request.ServerVariables["HTTP_X_WAP_PROFILE"];
                Add("Request.ServerVariables<br/>[\"HTTP_X_WAP_PROFILE\"]", http_wap_profile == null ? "null" : http_wap_profile.ToString());
                if (http_wap_profile!=null)
                    Add("Request.ServerVariables<br/>[\"HTTP_X_WAP_PROFILE\"]", "Is mobile device");
                string http_accept = context.Request.ServerVariables["HTTP_ACCEPT"];
                Add("Request.ServerVariables<br/>[\"HTTP_ACCEPT\"]", http_accept == null ? "null" : http_accept.ToString());
                if (http_accept!=null)
                    Add("Request.ServerVariables<br/>[\"HTTP_ACCEPT\"].ToLower().Contains(\"wap\")", context.Request.ServerVariables["HTTP_ACCEPT"].ToLower().Contains("wap").ToString());
                Add("List of Mobile Types", GetStringArray(mobiles));
                string http_useragent = context.Request.ServerVariables["HTTP_USER_AGENT"];
                Add("Request.ServerVariables<br/>[\"HTTP_USER_AGENT\"]", http_useragent == null ? "null" : http_useragent.ToString());
                Add("Request.ServerVariables<br/>[\"HTTP_USER_AGENT\"]<br/>.ToString().ContainsOneOfMobileTypes", UserAgentContainsMobile().ToString());
            }
        }

// Start of ListServerModules.cs

        public class ListModules : MyList
        {
            public ListModules(State MyState)
                : base(MyState, "Modules")
            {
                HttpContext myHttpContext = HttpContext.Current;
                HttpApplication myHttpApplication = myHttpContext.ApplicationInstance;
                HttpModuleCollection myHttpModuleCollection = myHttpApplication.Modules;
                string[] allModules = myHttpModuleCollection.AllKeys;
                System.Array httpModuleArray = Array.CreateInstance(typeof(object), myHttpModuleCollection.AllKeys.Length);
                myHttpModuleCollection.CopyTo(httpModuleArray, 0);
                for (int i = 0; i < allModules.Length; i++)
                    Add(i.ToString().PadLeft(2, '0'), new string[] { allModules[i].ToString(), httpModuleArray.GetValue(i).ToString() });
            }
        }

// Start of ListServerRequest.cs

        public class ListRequest : MyList
        {
            public ListRequest(State MyState) : base(MyState, "Request Object")
            {
                HttpContext myHttpContext = HttpContext.Current;
                HttpRequest r = myHttpContext.Request;
                Add("AcceptTypes", GetStringArray(r.AcceptTypes));
                Add("AnonymousID", r.AnonymousID);
                Add("ApplicationPath", r.ApplicationPath);
                Add("AppRelativeCurrentExecutionFilePath", r.AppRelativeCurrentExecutionFilePath);
                Add("Browser", strExtraMenuPoint);
                Add("ClientCertificate", GetNameValueCollection(r.ClientCertificate));
                Add("ContentEncoding", r.ContentEncoding.ToString());
                Add("ContentLength", r.ContentLength.ToString());
                Add("ContentType", r.ContentType.ToString());
                Add("Cookies", strExtraMenuPoint);
                Add("CurrentExecutionFilePath", r.CurrentExecutionFilePath);
                Add("FilePath", r.FilePath);
                Add("Form", GetNameValueCollection(r.Form));
                Add("Headers", GetNameValueCollection(r.Headers));
                try
                {
                    Add("HttpChannelBinding.Size", r.HttpChannelBinding.Size.ToString());
                }
                catch
                {
                    Add("HttpChannelBinding.Size", strNotAvailable);
                }
                Add("HttpMethod", r.HttpMethod);
                Add("IsAuthenticated", r.IsAuthenticated.ToString());
                Add("IsLocal", r.IsLocal.ToString());
                Add("IsSecureConnection", r.IsSecureConnection.ToString());
                Add("LogonUserIdentity.Name", r.LogonUserIdentity.Name);
                Add("Params", GetNameValueCollection(r.Params));
                Add("Path", r.Path);
                Add("PathInfo", r.PathInfo);
                Add("PhysicalApplicationPath", r.PhysicalApplicationPath);
                Add("PhysicalPath", r.PhysicalPath);
                Add("QueryString", GetNameValueCollection(r.QueryString));
                Add("RawUrl", r.RawUrl);
                Add("RequestContext", strComplexType);
                Add("RequestType", r.RequestType);
                Add("ServerVariables", GetNameValueCollection(r.ServerVariables));
                Add("TotalBytes", r.TotalBytes.ToString());
                Add("Url", r.Url.ToString());
                Add("Url.AbsolutePath", r.Url.AbsolutePath);
                Add("Url.AbsoluteUri", r.Url.AbsoluteUri);
                Add("Url.Authority", r.Url.Authority);
                Add("Url.DnsSafeHost", r.Url.DnsSafeHost);
                Add("Url.Fragment", r.Url.Fragment);
                Add("Url.Host", r.Url.Host);
                Add("Url.HostNameType", r.Url.HostNameType.ToString()+" (possible values: Basic,Dns,IPv4,IPv6,Unknown)");
                Add("Url.IsAbsoluteUri", r.Url.IsAbsoluteUri.ToString());
                Add("Url.IsDefaultPort", r.Url.IsDefaultPort.ToString());
                Add("Url.IsFile", r.Url.IsFile.ToString());
                Add("Url.IsLoopback", r.Url.IsLoopback.ToString());
                Add("Url.IsUnc", r.Url.IsUnc.ToString());
                Add("Url.LocalPath", r.Url.LocalPath);
                Add("Url.OriginalString", r.Url.OriginalString);
                Add("Url.PathAndQuery", r.Url.PathAndQuery);
                Add("Url.Port", r.Url.Port.ToString());
                Add("Url.Query", r.Url.Query);
                Add("Url.Scheme", r.Url.Scheme);
                Add("Url.Segments", GetStringArray(r.Url.Segments));
                Add("Url.UserEscaped", r.Url.UserEscaped.ToString());
                Add("Url.UserInfo", r.Url.UserInfo);
                Add("UrlReferrer", r.UrlReferrer == null ? "" : r.UrlReferrer.ToString());
                Add("UserAgent", r.UserAgent);
                Add("UserHostAddress", r.UserHostAddress);
                Add("UserHostName", r.UserHostName);
                Add("UserLanguages", GetStringArray(r.UserLanguages));
            }
        }

// Start of ListServerResponse.cs

        public class ListResponse : MyList
        {
            HttpResponse r;

            string GetCookies()
            {
                string cookies = "";
                HttpCookieCollection cc = r.Cookies;
                cookies = "Count:" + cc.Count + "<br/>";
                foreach (string c in cc)
                {
                    cookies += FormatMyKey(c) + FormatMyText("=") + cc[c] + "<br/>";
                }
                return cookies;
            }
            public ListResponse(State MyState)
                : base(MyState, "Response Object")
            {
                HttpContext myHttpContext = HttpContext.Current;
                r = myHttpContext.Response;

                Add("Response.Cache", strComplexType);
                Add("Response.CacheControl", r.CacheControl);
                Add("Response.Charset", r.Charset);
                Add("Response.ContentEncoding", r.ContentEncoding.ToString());
                Add("Response.ContentType", r.ContentType);
                Add("Response.Cookies", GetCookies());
                Add("Response.Expires (min)", r.Expires.ToString());
                Add("Response.ExpiresAbsolute", r.ExpiresAbsolute.ToString());
                try
                {
                    Add("Response.Headers", GetNameValueCollection(r.Headers));
                }
                catch
                {
                    Add("Response.Headers", strNotAvailable);
                }
                try
                {
                    Add("Response.HeaderEncoding", r.HeaderEncoding.ToString());
                }
                catch
                {
                    Add("Response.HeaderEncoding", strNotAvailable);
                }
                Add("Response.IsClientConnected", r.IsClientConnected.ToString());
                Add("Response.IsRequestBeingRedirected", r.IsRequestBeingRedirected.ToString());
                Add("Response.RedirectLocation", r.RedirectLocation);
                Add("Response.Status", r.Status);
                try
                {
                    Add("Response.StatusCode", r.StatusCode.ToString());
                }
                catch
                {
                    Add("Response.StatusCode", strNotAvailable);
                }
                Add("Response.StatusDescription", r.StatusDescription);
                try
                {
                    Add("Response.SubStatusCode", r.SubStatusCode.ToString());
                }
                catch
                {
                    Add("Response.SubStatusCode", strNotAvailable);
                }
                Add("Response.SuppressContent", r.SuppressContent.ToString());
                Add("Response.TrySkipIisCustomErrors", r.TrySkipIisCustomErrors.ToString());
            }
        }

// Start of ListServerSession.cs

        class ListSession : MyList
        {
            HttpSessionState s;
            string GetSessionKeys()
            {
                string KeyList = "";
                System.Collections.Specialized.NameObjectCollectionBase.KeysCollection Keys = s.Keys;
                foreach (string Key in Keys)
                {
                    KeyList += Key + " ";
                }
                return KeyList;
            }
            string GetSessionKeyValuePairs()
            {
                string KeyValueList = "";
                System.Collections.Specialized.NameObjectCollectionBase.KeysCollection Keys = s.Keys;
                foreach (string Key in Keys)
                {
                    KeyValueList +=  FormatMyKey(Key) + FormatMyText("=") + s[Key] + "<br/>";
                }
                return KeyValueList;
            }
            string GetSessionStaticObjects()
            {
                string StaticObjects = "";
                HttpStaticObjectsCollection hsoc = s.StaticObjects;
                foreach (string Key in hsoc)
                {
                    StaticObjects += hsoc[StaticObjects] + " ";
                }
                return StaticObjects;
            }
            string GetSessionContents()
            {
                string SessionContent = "";
                foreach (string Key in s.Contents)
                {
                    SessionContent += FormatMyKey(Key) + FormatMyText("=") + s.Contents[Key] + "<br/>";
                }
                return SessionContent;
            }
            public ListSession(State MyState) : base(MyState, "Session Object")
            {
                HttpContext myHttpContext = HttpContext.Current;
                s = myHttpContext.Session; 
                s.Add(strDemoVariableName, strDemoEntry);

                Add("s.CodePage", s.CodePage.ToString());
                Add("s.Contents", GetSessionContents());
                Add("s.CookieMode", s.CookieMode.ToString());
                Add("s.Count", s.Count.ToString());
                Add("s.IsCookieless", s.IsCookieless.ToString());
                Add("s.IsNewSession", s.IsNewSession.ToString());
                Add("s.IsReadOnly", s.IsReadOnly.ToString());
                Add("s.IsSynchronized", s.IsSynchronized.ToString());
                Add("s.Keys", GetSessionKeys());
                Add("s.Keys->Values", GetSessionKeyValuePairs());
                Add("s.LCID", s.LCID.ToString());
                Add("s.Mode", s.Mode.ToString()); 
                Add("s.SessionID", s.SessionID);
                Add("s.StaticObjects", GetSessionStaticObjects());
                Add("s.Timeout", s.Timeout.ToString());
            }
        }

// Start of ListServerVariables.cs

        public class ListServerVariables : MyList
        {
            public ListServerVariables(State MyState)
                : base(MyState, "Server Variables")
            {
                HttpContext myHttpContext = HttpContext.Current;
                NameValueCollection coll;
                coll = myHttpContext.Request.ServerVariables;
                String[] arr1 = coll.AllKeys;

                for (int i = 0; i < coll.Keys.Count; i++)
                {
                    Add(FormatMyKey(coll.Keys[i]), coll[i]);
                }
            }
        }

// Start of ListServerWebSettings.cs

        class ListConfiguration : MyList
        {
            void GetWebSection(Configuration conf, string SectionName)
            {
                AddTitle(SectionName, 2);
                SystemWebSectionGroup systemWeb = conf.GetSectionGroup(SectionName) as SystemWebSectionGroup;
                if (systemWeb != null)
                    for (int i = 0; i < systemWeb.Sections.Count; i++)
                    {
                        Add(systemWeb.Sections[i].SectionInformation.Name, GetSection(systemWeb.Sections[i]));
                    }
            }
            protected string GetSection(ConfigurationSection s)
            {
                if (s == null) return "";
                string KeyValuePairs = "";
                PropertyInformationCollection props = s.ElementInformation.Properties;
                foreach (PropertyInformation prop in props)
                {
                    string Name = prop.Name;
                    string Value = prop.Value as string; if (Value == null) Value = "";
                    KeyValuePairs += FormatMyKey(Name.ToString()) + FormatMyText("=") + Value + "<br/>";
                }
                return KeyValuePairs;
            }
            public ListConfiguration(State MyState)
                : base(MyState, "WebSettings")
            {
                AddTitle("Web Configuration AppSettings", 2);

                NameValueCollection nvc = WebConfigurationManager.AppSettings;
                for (int i = 0; i < nvc.Count; i++)
                {
                    Add(nvc.AllKeys[i], nvc[i]);
                }
                // HostingEnvironmentSection h = new HostingEnvironmentSection();
                // GetWebSection(h.CurrentConfiguration, "AppSettings");

                AddTitle("Web Configuration Connection Strings", 2);
                ConnectionStringSettingsCollection cssc = WebConfigurationManager.ConnectionStrings;
                for (int i = 0; i < cssc.Count; i++)
                {
                    ConnectionStringSettings conn = cssc[i];
                    Add(conn.Name.ToString(), conn.ConnectionString);
                }

                WebConfigurationFileMap wm = new WebConfigurationFileMap();
                Configuration c = WebConfigurationManager.OpenWebConfiguration("/"); //OpenMachineConfiguration(); 
                // GetWebSection(c, "appSettings");
                GetWebSection(c, "configSections");
                // GetWebSection(c, "system.codedom");
                GetWebSection(c, "system.web");
                // GetWebSection(c, "system.webServer");
                // GetWebSection(c, "runtime");

                // c = WebConfigurationManager.OpenMachineConfiguration();
                // GetWebSection(c, "runtime");

                // empty, not used, may be an syntax error
                // GetWebCachingSection(c);

                /*
                m = new MyList("Web Machine Configuration");
                ConfigurationSectionCollection css = c.Sections;
                for (int i = 0; i < css.Count; i++)
                {
                    ConfigurationSection cs = c.GetSection(css.Keys[i]);
                    string ss = "";
                    for (int j = 0; j < cs.ElementInformation.Properties.Count; j++)
                    {
                        string s = "";
                        if (cs.ElementInformation.IsCollection)
                        {
                            SectionInformation si = cs.SectionInformation;
                        }
                        PropertyInformationCollection pic = cs.ElementInformation.Properties;
                        foreach (PropertyInformation pi in pic)
                        {
                            switch (pi.Value.GetType().ToString())
                            {
                                case "SysteConfiguration.KeyValueConfigurationCollection":
                                    KeyValueConfigurationCollection fvsc = (KeyValueConfigurationCollection)pi.Value;
                                    for (int k = 0; k < fvsc.Count; k++)
                                    {
                                        s += fvsc.AllKeys[i] + "=" + fvsc[fvsc.AllKeys[i]].ToString();
                                    }
                                    break;
                                case "SysteConfiguration.ConnectionStringSettingsCollection":
                                    ConnectionStringSettingsCollection cssc1 = (ConnectionStringSettingsCollection)pi.Value;
                                    for (int k = 0; k < cssc1.Count; k++)
                                    {
                                        ConnectionStringSettings conn = cssc1[k];
                                        s += conn.Name + "=" + conn.ConnectionString;
                                    }
                                    break;
                                case "SysteString":
                                    s += pi.Name + "=" + pi.Value +"<br/>";
                                    break; 
                                case "SysteDiagnostics.AssertSection":
                                    // SysteDiagnostics.AssertSection sda_Value = (SysteDiagnostics)pi.Value;
                                    s += pi.Name + "=" + pi.Value +"<br/>";
                                    break;
                                case "SysteDiagnostics.PerfCounterSection":
                                    //SysteDiagnostics.PerfCounterSection sda_Value = (SysteDiagnostics)pi.Value;
                                    s += pi.Name + "=" + pi.Value + "<br/>";
                                    break;
                                case "SysteConfiguration.ProtectedProviderSettings":
                                    ProtectedProviderSettings Value = (ProtectedProviderSettings)pi.Value;
                                    s += pi.Name + "=" + pi.Value + "<br/>";
                                    break;
                                default:
                                    s += pi.Name + "=" + pi.Value + "<br/>";
                                    break;
                            }
                        }
                        ss+=s+" ";
                    }
                    Add(css.Keys[i], ss);
                }
                 */
            }
        }

// Start of StaticExif.cs

        public static class Exif
        {
            public class Entry
            {
                int _Id;
                public int Id
                {
                    get
                    {
                        return _Id;
                    }
                }
                string _Name;
                public string Name
                {
                    get
                    {
                        return _Name;
                    }
                }
                public Entry(int Id, string Name)
                {
                    _Id = Id;
                    _Name = Name;
                }
            }
            // http://www.awaresystems.be/imaging/tiff.html
            public static Entry[] Entries = new Entry[]
                {
                    new Entry(0x0000, "GpsVer"),
                    new Entry(0x0001, "GpsLatitudeRef"),
                    new Entry(0x0002, "GpsLatitude"),
                    new Entry(0x0003, "GpsLongitudeRef"),
                    new Entry(0x0004, "GpsLongitude"),
                    new Entry(0x0005, "GpsAltitudeRef"),
                    new Entry(0x0006, "GpsAltitude"),
                    new Entry(0x0007, "GpsGpsTime"),
                    new Entry(0x0008, "GpsGpsSatellites"),
                    new Entry(0x0009, "GpsGpsStatus"),
                    new Entry(0x000A, "GpsGpsMeasureMode"),
                    new Entry(0x000B, "GpsGpsDop"),
                    new Entry(0x000C, "GpsSpeedRef"),
                    new Entry(0x000D, "GpsSpeed"),
                    new Entry(0x000E, "GpsTrackRef"),
                    new Entry(0x000F, "GpsTrack"),
                    new Entry(0x0010, "GpsImgDirRef"),
                    new Entry(0x0011, "GpsImgDir"),
                    new Entry(0x0012, "GpsMapDatum"),
                    new Entry(0x0013, "GpsDestLatRef"),
                    new Entry(0x0014, "GpsDestLat"),
                    new Entry(0x0015, "GpsDestLongRef"),
                    new Entry(0x0016, "GpsDestLong"),
                    new Entry(0x0017, "GpsDestBearRef"),
                    new Entry(0x0018, "GpsDestBear"),
                    new Entry(0x0019, "GpsDestDistRef"),
                    new Entry(0x001A, "GpsDestDist"),
                    new Entry(0x001B, "GpsProcessingMethod"),
                    new Entry(0x001C, "GpsAreaInformation"),
                    new Entry(0x001D, "GpsDateStamp"),
                    new Entry(0x001E, "GpsDifferential"),
                    new Entry(0x00FE, "NewSubfileType"),
                    new Entry(0x00FF, "SubfileType"),
                    new Entry(0x0100, "ImageWidth"),
                    new Entry(0x0101, "ImageHeight"),
                    new Entry(0x0102, "BitsPerSample"),
                    new Entry(0x0103, "Compression"),
                    new Entry(0x0106, "PhotometricInterp"),
                    new Entry(0x0107, "ThreshHolding"),
                    new Entry(0x0108, "CellWidth"),
                    new Entry(0x0109, "CellHeight"),
                    new Entry(0x010A, "FillOrder"),
                    new Entry(0x010D, "DocumentName"),
                    new Entry(0x010E, "ImageDescription"),
                    new Entry(0x010F, "EquipMake"),
                    new Entry(0x0110, "EquipModel"),
                    new Entry(0x0111, "StripOffsets"),
                    new Entry(0x0112, "Orientation"),
                    new Entry(0x0115, "SamplesPerPixel"),
                    new Entry(0x0116, "RowsPerStrip"),
                    new Entry(0x0117, "StripBytesCount"),
                    new Entry(0x0118, "MinSampleValue"),
                    new Entry(0x0119, "MaxSampleValue"),
                    new Entry(0x011A, "XResolution"),
                    new Entry(0x011B, "YResolution"),
                    new Entry(0x011C, "PlanarConfig"),
                    new Entry(0x011D, "PageName"),
                    new Entry(0x011E, "XPosition"),
                    new Entry(0x011F, "YPosition"),
                    new Entry(0x0120, "FreeOffset"),
                    new Entry(0x0121, "FreeByteCounts"),
                    new Entry(0x0122, "GrayResponseUnit"),
                    new Entry(0x0123, "GrayResponseCurve"),
                    new Entry(0x0124, "T4Option"),
                    new Entry(0x0125, "T6Option"),
                    new Entry(0x0128, "ResolutionUnit"),
                    new Entry(0x0129, "PageNumber"),
                    new Entry(0x012D, "TransferFunction"),
                    new Entry(0x0131, "SoftwareUsed"),
                    new Entry(0x0132, "DateTime"),
                    new Entry(0x013B, "Artist"),
                    new Entry(0x013C, "HostComputer"),
                    new Entry(0x013D, "Predictor"),
                    new Entry(0x013E, "WhitePoint"),
                    new Entry(0x013F, "PrimaryChromaticities"),
                    new Entry(0x0140, "ColorMap"),
                    new Entry(0x0141, "HalftoneHints"),
                    new Entry(0x0142, "TileWidth"),
                    new Entry(0x0143, "TileLength"),
                    new Entry(0x0144, "TileOffset"),
                    new Entry(0x0145, "TileByteCounts"),
                    new Entry(0x0146, "BadFaxLines"),
                    new Entry(0x0147, "CleanFaxData"),
                    new Entry(0x0148, "ConsecutiveBadFaxLines"),
                    new Entry(0x014A, "SubIFDs"),
                    new Entry(0x014C, "InkSet"),
                    new Entry(0x014D, "InkNames"),
                    new Entry(0x014E, "NumberOfInks"),
                    new Entry(0x0150, "DotRange"),
                    new Entry(0x0151, "TargetPrinter"),
                    new Entry(0x0152, "ExtraSamples"),
                    new Entry(0x0153, "SampleFormat"),
                    new Entry(0x0154, "SMinSampleValue"),
                    new Entry(0x0155, "SMaxSampleValue"),
                    new Entry(0x0156, "TransferRange"),
                    new Entry(0x0157, "ClipPath"),
                    new Entry(0x0158, "XClipPathUnits"),
                    new Entry(0x0159, "YClipPathUnits"),
                    new Entry(0x015A, "Indexed"),
                    new Entry(0x015B, "JPEGTables"),
                    new Entry(0x015F, "OPIProxy"),
                    new Entry(0x0190, "GlobalParametersIFD"),
                    new Entry(0x0191, "ProfileType"),
                    new Entry(0x0192, "FaxProfile"),
                    new Entry(0x0193, "CodingMethods"),
                    new Entry(0x0194, "VersionYear"),
                    new Entry(0x0195, "ModeNumber"),
                    new Entry(0x01B1, "Decode"),
                    new Entry(0x01B2, "DefaultImageColor"),
                    new Entry(0x0200, "JPEGProc"),
                    new Entry(0x0201, "JPEGInterFormat"),
                    new Entry(0x0202, "JPEGInterLength"),
                    new Entry(0x0203, "JPEGRestartInterval"),
                    new Entry(0x0205, "JPEGLosslessPredictors"),
                    new Entry(0x0206, "JPEGPointTransforms"),
                    new Entry(0x0207, "JPEGQTables"),
                    new Entry(0x0208, "JPEGDCTables"),
                    new Entry(0x0209, "JPEGACTables"),
                    new Entry(0x0211, "YCbCrCoefficients"),
                    new Entry(0x0212, "YCbCrSubsampling"),
                    new Entry(0x0213, "YCbCrPositioning"),
                    new Entry(0x0214, "REFBlackWhite"),
                    new Entry(0x022F, "StripRowCounts"),
                    new Entry(0x02BC, "XMP"),
                    new Entry(0x0301, "Gamma"),
                    new Entry(0x0302, "ICCProfileDescriptor"),
                    new Entry(0x0303, "SRGBRenderingIntent"),
                    new Entry(0x0320, "ImageTitle"),
                    new Entry(0x5001, "ResolutionXUnit"),
                    new Entry(0x5002, "ResolutionYUnit"),
                    new Entry(0x5003, "ResolutionXLengthUnit"),
                    new Entry(0x5004, "ResolutionYLengthUnit"),
                    new Entry(0x5005, "PrintFlags"),
                    new Entry(0x5006, "PrintFlagsVersion"),
                    new Entry(0x5007, "PrintFlagsCrop"),
                    new Entry(0x5008, "PrintFlagsBleedWidth"),
                    new Entry(0x5009, "PrintFlagsBleedWidthScale"),
                    new Entry(0x500A, "HalftoneLImage_pi"),
                    new Entry(0x500B, "HalftoneLImage_piUnit"),
                    new Entry(0x500C, "HalftoneDegree"),
                    new Entry(0x500D, "HalftoneShape"),
                    new Entry(0x500E, "HalftoneMisc"),
                    new Entry(0x500F, "HalftoneScreen"),
                    new Entry(0x5010, "JPEGQuality"),
                    new Entry(0x5011, "GridSize"),
                    new Entry(0x5012, "ThumbnailFormat"),
                    new Entry(0x5013, "ThumbnailWidth"),
                    new Entry(0x5014, "ThumbnailHeight"),
                    new Entry(0x5015, "ThumbnailColorDepth"),
                    new Entry(0x5016, "ThumbnailPlanes"),
                    new Entry(0x5017, "ThumbnailRawBytes"),
                    new Entry(0x5018, "ThumbnailSize"),
                    new Entry(0x5019, "ThumbnailCompressedSize"),
                    new Entry(0x501A, "ColorTransferFunction"),
                    new Entry(0x501B, "ThumbnailData"),
                    new Entry(0x5020, "ThumbnailImageWidth"),
                    new Entry(0x5021, "ThumbnailImageHeight"),
                    new Entry(0x5022, "ThumbnailBitsPerSample"),
                    new Entry(0x5023, "ThumbnailCompression"),
                    new Entry(0x5024, "ThumbnailPhotometricInterp"),
                    new Entry(0x5025, "ThumbnailImageDescription"),
                    new Entry(0x5026, "ThumbnailEquipMake"),
                    new Entry(0x5027, "ThumbnailEquipModel"),
                    new Entry(0x5028, "ThumbnailStripOffsets"),
                    new Entry(0x5029, "ThumbnailOrientation"),
                    new Entry(0x502A, "ThumbnailSamplesPerPixel"),
                    new Entry(0x502B, "ThumbnailRowsPerStrip"),
                    new Entry(0x502C, "ThumbnailStripBytesCount"),
                    new Entry(0x502D, "ThumbnailResolutionX"),
                    new Entry(0x502E, "ThumbnailResolutionY"),
                    new Entry(0x502F, "ThumbnailPlanarConfig"),
                    new Entry(0x5030, "ThumbnailResolutionUnit"),
                    new Entry(0x5031, "ThumbnailTransferFunction"),
                    new Entry(0x5032, "ThumbnailSoftwareUsed"),
                    new Entry(0x5033, "ThumbnailDateTime"),
                    new Entry(0x5034, "ThumbnailArtist"),
                    new Entry(0x5035, "ThumbnailWhitePoint"),
                    new Entry(0x5036, "ThumbnailPrimaryChromaticities"),
                    new Entry(0x5037, "ThumbnailYCbCrCoefficients"),
                    new Entry(0x5038, "ThumbnailYCbCrSubsampling"),
                    new Entry(0x5039, "ThumbnailYCbCrPositioning"),
                    new Entry(0x503A, "ThumbnailRefBlackWhite"),
                    new Entry(0x503B, "ThumbnailCopyRight"),
                    new Entry(0x5090, "LuminanceTable"),
                    new Entry(0x5091, "ChrominanceTable"),
                    new Entry(0x5100, "FrameDelay"),
                    new Entry(0x5101, "LoopCount"),
                    new Entry(0x5102, "GlobalPalette"),
                    new Entry(0x5103, "IndexBackground"),
                    new Entry(0x5104, "IndexTransparent"),
                    new Entry(0x5110, "PixelUnit"),
                    new Entry(0x5111, "PixelPerUnitX"),
                    new Entry(0x5112, "PixelPerUnitY"),
                    new Entry(0x5113, "PaletteHistogram"),
                    new Entry(0x800D, "ImageID"),
                    new Entry(0x80A4, "Wang Annotation"),
                    new Entry(0x8298, "Copyright"),
                    new Entry(0x829A, "ExifExposureTime"),
                    new Entry(0x829D, "ExifFNumber"),
                    new Entry(0x82A5, "MD FileTag"),
                    new Entry(0x82A6, "MD ScalePixel"),
                    new Entry(0x82A7, "MD ColorTable"),
                    new Entry(0x82A8, "MD LabName"),
                    new Entry(0x82A9, "MD SampleInfo"),
                    new Entry(0x82AA, "MD PrepDate"),
                    new Entry(0x82AB, "MD PrepTime"),
                    new Entry(0x82AC, "MD FileUnits"),
                    new Entry(0x830E, "ModelPixelScaleTag"),
                    new Entry(0x83BB, "IPTC"),
                    new Entry(0x847E, "INGR Packet Data Tag"),
                    new Entry(0x847F, "INGR Flag Registers"),
                    new Entry(0x8480, "IrasB Transformation Matrix"),
                    new Entry(0x8482, "ModelTiepointTag"),
                    new Entry(0x85D8, "ModelTransformationTag"),
                    new Entry(0x8649, "Photoshop"),
                    new Entry(0x8769, "ExifIFD"),
                    new Entry(0x8773, "ICCProfile"),
                    new Entry(0x87AC, "ImageLayer"),
                    new Entry(0x87AF, "GeoKeyDirectoryTag"),
                    new Entry(0x87B0, "GeoDoubleParamsTag"),
                    new Entry(0x87B1, "GeoAsciiParamsTag"),
                    new Entry(0x8822, "ExifExposureProg"),
                    new Entry(0x8824, "ExifSpectralSense"),
                    new Entry(0x8825, "GpsIFD"),
                    new Entry(0x8827, "ExifISOSpeed"),
                    new Entry(0x8828, "ExifOECF"),
                    new Entry(0x885C, "HylaFAX FaxRecvParams"),
                    new Entry(0x885D, "HylaFAX FaxSubAddress"),
                    new Entry(0x885E, "HylaFAX FaxRecvTime"),
                    new Entry(0x9000, "ExifVer"),
                    new Entry(0x9003, "ExifDTOrig"),
                    new Entry(0x9004, "ExifDTDigitized"),
                    new Entry(0x9101, "ExifCompConfig"),
                    new Entry(0x9102, "ExifCompBPP"),
                    new Entry(0x9201, "ExifShutterSpeed"),
                    new Entry(0x9202, "ExifAperture"),
                    new Entry(0x9203, "ExifBrightness"),
                    new Entry(0x9204, "ExifExposureBias"),
                    new Entry(0x9205, "ExifMaxAperture"),
                    new Entry(0x9206, "ExifSubjectDist"),
                    new Entry(0x9207, "ExifMeteringMode"),
                    new Entry(0x9208, "ExifLightSource"),
                    new Entry(0x9209, "ExifFlash"),
                    new Entry(0x920A, "ExifFocalLength"),
                    new Entry(0x927C, "ExifMakerNote"),
                    new Entry(0x9286, "ExifUserComment"),
                    new Entry(0x9290, "ExifDTSubsec"),
                    new Entry(0x9291, "ExifDTOrigSS"),
                    new Entry(0x9292, "ExifDTDigSS"),
                    new Entry(0x935C, "ImageSourceData"),
                    new Entry(0xA000, "ExifFPXVer"),
                    new Entry(0xA001, "ExifColorSpace"),
                    new Entry(0xA002, "ExifpixXDim"),
                    new Entry(0xA003, "ExifpixYDim"),
                    new Entry(0xA004, "ExifRelatedWav"),
                    new Entry(0xA005, "ExifInterop"),
                    new Entry(0xA20B, "ExifFlashEnergy"),
                    new Entry(0xA20C, "ExifSpatialFR"),
                    new Entry(0xA20E, "ExifFocalXRes"),
                    new Entry(0xA20F, "ExifFocalYRes"),
                    new Entry(0xA210, "ExifFocalResUnit"),
                    new Entry(0xA214, "ExifSubjectLoc"),
                    new Entry(0xA215, "ExifExposureIndex"),
                    new Entry(0xA217, "ExifSensingMethod"),
                    new Entry(0xA300, "ExifFileSource"),
                    new Entry(0xA301, "ExifSceneType"),
                    new Entry(0xA302, "ExifCfaPattern"),
                    new Entry(0xA401, "CustomRendered"),
                    new Entry(0xA402, "ExposureMode"),
                    new Entry(0xA403, "WhiteBalance"),
                    new Entry(0xA404, "DigitalZoomRatio"),
                    new Entry(0xA405, "FocalLengthIn35mmFilm"),
                    new Entry(0xA406, "SceneCaptureType"),
                    new Entry(0xA407, "GainControl"),
                    new Entry(0xA408, "Contrast"),
                    new Entry(0xA409, "Saturation"),
                    new Entry(0xA40A, "Sharpness"),
                    new Entry(0xA40B, "DeviceSettingDescription"),
                    new Entry(0xA40C, "SubjectDistanceRange"),
                    new Entry(0xA420, "ImageUniqueID"),
                    new Entry(0xA480, "GDAL_METADATA"),
                    new Entry(0xA481, "GDAL_NODATA"),
                    new Entry(0xC427, "Oce Scanjob Description"),
                    new Entry(0xC428, "Oce Application Selector"),
                    new Entry(0xC429, "Oce Identification Number"),
                    new Entry(0xC42A, "Oce ImageLogic Characteristics"),
                    new Entry(0xC612, "DNGVersion"),
                    new Entry(0xC613, "DNGBackwardVersion"),
                    new Entry(0xC614, "UniqueCameraModel"),
                    new Entry(0xC615, "LocalizedCameraModel"),
                    new Entry(0xC616, "CFAPlaneColor"),
                    new Entry(0xC617, "CFALayout"),
                    new Entry(0xC618, "LinearizationTable"),
                    new Entry(0xC619, "BlackLevelRepeatDim"),
                    new Entry(0xC61A, "BlackLevel"),
                    new Entry(0xC61B, "BlackLevelDeltaH"),
                    new Entry(0xC61C, "BlackLevelDeltaV"),
                    new Entry(0xC61D, "WhiteLevel"),
                    new Entry(0xC61E, "DefaultScale"),
                    new Entry(0xC61F, "DefaultCropOrigin"),
                    new Entry(0xC620, "DefaultCropSize"),
                    new Entry(0xC621, "ColorMatrix1"),
                    new Entry(0xC622, "ColorMatrix2"),
                    new Entry(0xC623, "CameraCalibration1"),
                    new Entry(0xC624, "CameraCalibration2"),
                    new Entry(0xC625, "ReductionMatrix1"),
                    new Entry(0xC626, "ReductionMatrix2"),
                    new Entry(0xC627, "AnalogBalance"),
                    new Entry(0xC628, "AsShotNeutral"),
                    new Entry(0xC629, "AsShotWhiteXY"),
                    new Entry(0xC62A, "BaselineExposure"),
                    new Entry(0xC62B, "BaselineNoise"),
                    new Entry(0xC62C, "BaselineSharpness"),
                    new Entry(0xC62D, "BayerGreenSplit"),
                    new Entry(0xC62E, "LinearResponseLimit"),
                    new Entry(0xC62F, "CameraSerialNumber"),
                    new Entry(0xC630, "LensInfo"),
                    new Entry(0xC631, "ChromaBlurRadius"),
                    new Entry(0xC632, "AntiAliasStrength"),
                    new Entry(0xC634, "DNGPrivateData"),
                    new Entry(0xC635, "MakerNoteSafety"),
                    new Entry(0xC65A, "CalibrationIlluminant1"),
                    new Entry(0xC65B, "CalibrationIlluminant2"),
                    new Entry(0xC65C, "BestQualityScale"),
                    new Entry(0xC660, "Alias Layer Metadata"),
            };
            public static string GetName(int ExifIdToFind)
            {
                for (int i = 0; i < Entries.Length; i++)
                {
                    if (ExifIdToFind == Entries[i].Id)
                        return Entries[i].Name;
                }
                return "Id" + ExifIdToFind.ToString();
            }
        }

// Start of StaticFileGroups.cs

        public enum E_ObjectCommand { CODE, DIRECTORY, DOWNLOAD, EMBED, EXIF, FRAME, HEX, INLINE, LINK, NEWWIN, NONE, PERMISSIONS, SPECIAL, TEXT, THUMBS };

        public class FileGroup
        {
            public enum Type { AUDIO, AUDVID, APPLI, APPLIEXE, BINARY, CODE, CODEEXE, EXIF, IMAGE, INLINE, NOTYPE, OTHER, VIDEO };

            public static int CompareExtensionsAction(FileGroup x, FileGroup y)
            {
                return x.FileType.ToString().CompareTo(y.FileType.ToString());
            }
            public Type FileType;
            public string Description;
            public string Icon;
            public bool ShowCode;
            public bool ShowFrame;
            public bool ShowInline;
            public bool ShowDownload;
            public bool ShowHex;
            public bool ShowPermissions;
            public bool ShowEmbedded;
            public bool ShowSpecial;
            public bool ShowExif;
            public E_ObjectCommand ShowFirst;
            public E_ObjectCommand ShowInThumb;
            public FileGroup(Type FileType, string Description, string Icon, bool ShowCode, bool ShowFrame, bool ShowInline, bool ShowDownload, bool ShowHex, bool ShowPermissions, bool ShowEmbedded, bool ShowSpecial, bool ShowExif, E_ObjectCommand ShowFirst, E_ObjectCommand ShowInThumb)
            {
                this.FileType = FileType;
                this.Description = Description;
                this.Icon = Icon;
                this.ShowCode = ShowCode;
                this.ShowFrame = ShowFrame;
                this.ShowInline = ShowInline;
                this.ShowDownload = ShowDownload;
                this.ShowHex = ShowHex;
                this.ShowPermissions = ShowPermissions;
                this.ShowEmbedded = ShowEmbedded;
                this.ShowSpecial = ShowSpecial;
                this.ShowExif = ShowExif;
                this.ShowFirst = ShowFirst;
                this.ShowInThumb = ShowInThumb;
            }
        }
        public static class FileGroups
        {
            public static bool IsSorted = false;
            public static void Sort()
            {
                if (!IsSorted)
                {
                    list.Sort(FileGroup.CompareExtensionsAction);
                    IsSorted = true;
                }
            }
            public static FileGroup.Type ExtensionTypeToFind = FileGroup.Type.NOTYPE;

            public static E_ObjectCommand GetThumbCommand(FileGroup.Type etf)
            {
                FileGroup fg = Get(etf);
                return fg.ShowInThumb;
            }
            public static FileGroup Get(FileGroup.Type etf)
            {
                ExtensionTypeToFind = etf;
                return list.Find(
                    delegate(FileGroup eaf)
                    {
                        return (ExtensionTypeToFind == eaf.FileType);
                });
            }
            // the following construct does not work with framework 2.0 when running in single file mode
            public static List<FileGroup> list = new List<FileGroup>() 
            {
                new FileGroup(FileGroup.Type.OTHER, "Binary", "", false, false, false, true, true, true, false, false, false, E_ObjectCommand.HEX, E_ObjectCommand.NONE),
            
                new FileGroup(FileGroup.Type.APPLIEXE, "Display", "", false, true, false, true, true, true, false, false, false, E_ObjectCommand.FRAME, E_ObjectCommand.FRAME),

                new FileGroup(FileGroup.Type.CODE, "Code", "", true, false, false, true, true, true, false, false, false, E_ObjectCommand.CODE, E_ObjectCommand.TEXT),

                new FileGroup(FileGroup.Type.CODEEXE, "Code-Display", "", true, true, false, true, true, true, false, false, false, E_ObjectCommand.CODE, E_ObjectCommand.FRAME),

                new FileGroup(FileGroup.Type.IMAGE, "Image", "", false, true, false, true, true, true, true, true, false, E_ObjectCommand.EMBED, E_ObjectCommand.EMBED),

                new FileGroup(FileGroup.Type.EXIF, "Image-Exif", "", false, true, false, true, true, true, true, true, true, E_ObjectCommand.EMBED, E_ObjectCommand.EMBED),

                new FileGroup(FileGroup.Type.AUDVID, "Audio and Video", "", false, true, true, true, true, true, true, false, false, E_ObjectCommand.EMBED, E_ObjectCommand.LINK),
                new FileGroup(FileGroup.Type.AUDIO, "Audio", "", false, true, true, true, true, true, true, false, false, E_ObjectCommand.EMBED, E_ObjectCommand.LINK),
                new FileGroup(FileGroup.Type.VIDEO, "Video", "", false, true, true, true, true, true, true, false, false, E_ObjectCommand.EMBED, E_ObjectCommand.LINK),

                new FileGroup(FileGroup.Type.INLINE, "Inline", "", true, true, true, true, true, true, false, false, false, E_ObjectCommand.INLINE, E_ObjectCommand.FRAME)
            };
        }

// Start of StaticFileTypes.cs

        public class FileTypeInfo
        {
            public static int CompareFileTypeInfo(FileTypeInfo x, FileTypeInfo y)
            {
                return x.Extension.CompareTo(y.Extension);
            }
            public string Extension;
            public string Icon;
            public string brush;
            public int MediaTemplateId;
            public FileGroup.Type Type;
            public FileTypeInfo(string Extension, string Icon, string brush, int MediaTemplateId, FileGroup.Type Type)
            {
                this.Extension = Extension;
                this.Icon = Icon;
                this.brush = brush;
                this.MediaTemplateId = MediaTemplateId;
                this.Type = Type;
            }
        }
        public static class FileTypes
        {
            public static bool IsSorted = false;
            public static string ExtensionToFind = "";

            public static void Sort()
            {
                if (!IsSorted)
                {
                    list.Sort(FileTypeInfo.CompareFileTypeInfo);
                    IsSorted = true;
                }
            }
            public static FileTypeInfo Get(string ext)
            {
                ExtensionToFind = ext;
                return list.Find(
                delegate(FileTypeInfo fti)
                {
                    return (ExtensionToFind == fti.Extension);
                });

            }
            public static bool IsImage(string Extension)
            {
                FileGroup.Type type = GetFileType(Extension.ToLower());
                switch (type)
                {
                    case FileGroup.Type.IMAGE:
                    case FileGroup.Type.EXIF:
                        return true;
                    default:
                        return false;
                }
            }
            public static FileGroup.Type GetFileType(string Extension)
            {
                Extension = Extension.ToLower();
                for (int i=0; i<list.Count; i++)
                {
                    if (list[i].Extension == Extension) return list[i].Type;
                }
                return FileGroup.Type.OTHER;
            }
            public static E_ObjectCommand GetFileTypeInThumb(string Extension)
            {
                Extension = Extension.ToLower();
                FileGroup.Type etf = FileGroup.Type.OTHER;
                for (int i = 0; i < list.Count; i++) 
                {
                    if (list[i].Extension == Extension)
                    {
                        etf = list[i].Type;
                        break;
                    }
                }
                return FileGroups.GetThumbCommand(etf);
            }
            // the following construct does not work with framework 2.0 when running in single file mode
            public static List<FileTypeInfo> list = new List<FileTypeInfo>() 
            {
                // exif
                new FileTypeInfo(".jpg", "paint.gif", "", 0, FileGroup.Type.EXIF),
                new FileTypeInfo(".jpeg", "paint.gif", "", 0, FileGroup.Type.EXIF),
                new FileTypeInfo(".jpe", "paint.gif", "", 0, FileGroup.Type.EXIF),
                new FileTypeInfo(".tif", "paint.gif", "", 0, FileGroup.Type.EXIF),
                new FileTypeInfo(".tiff", "paint.gif", "", 0, FileGroup.Type.EXIF),

                // image
                new FileTypeInfo(".bmp", "paint.gif", "", 0, FileGroup.Type.IMAGE),
                new FileTypeInfo(".gif", "paint.gif", "", 0, FileGroup.Type.IMAGE),
                new FileTypeInfo(".png", "paint.gif", "", 0, FileGroup.Type.IMAGE),

                // drwawing
                new FileTypeInfo(".svg", "css.gif", "xml", -1, FileGroup.Type.INLINE),

                // code executable
                new FileTypeInfo(".asp", "asp.gif", "vb", -1, FileGroup.Type.CODEEXE),
                new FileTypeInfo(".aspx", "aspx.gif", "xml", -1, FileGroup.Type.CODEEXE),
                new FileTypeInfo(".css", "css.gif", "css", -1, FileGroup.Type.CODEEXE),
                new FileTypeInfo(".htm", "seite.gif", "xml", -1, FileGroup.Type.CODEEXE),
                new FileTypeInfo(".html", "seite.gif", "xml", -1, FileGroup.Type.CODEEXE),
                new FileTypeInfo(".ini", "notepad.gif", "text", -1, FileGroup.Type.CODEEXE),
                new FileTypeInfo(".php", "php.gif", "php", -1, FileGroup.Type.CODEEXE),
                new FileTypeInfo(".php3", "php.gif", "php", -1, FileGroup.Type.CODEEXE),
                new FileTypeInfo(".scss", "css.gif", "css", -1, FileGroup.Type.CODEEXE),
                new FileTypeInfo(".shtm", "seite.gif", "xml", -1, FileGroup.Type.CODEEXE),
                new FileTypeInfo(".shtml", "seite.gif", "xml", -1, FileGroup.Type.CODEEXE),
                new FileTypeInfo(".txt", "notepad.gif", "text", -1, FileGroup.Type.CODEEXE),

                // code 
                new FileTypeInfo(".asa", "seiteA.gif", "", -1, FileGroup.Type.CODE),
                new FileTypeInfo(".ascx", "ascx.gif", "xml", -1, FileGroup.Type.CODE),
                new FileTypeInfo(".bat", "vb\\ico4511.gif", "shell", -1, FileGroup.Type.CODE),
                new FileTypeInfo(".c", "cs\\ico4516.gif", "c", -1, FileGroup.Type.CODE),
                new FileTypeInfo(".config", "cs\\ico4545.gif", "xml", -1, FileGroup.Type.CODE),
                new FileTypeInfo(".cpp", "cs\\ico4516.gif", "cpp", -1, FileGroup.Type.CODE),
                new FileTypeInfo(".cs", "cs\\ico4516.gif", "c-sharp", -1, FileGroup.Type.CODE),
                new FileTypeInfo(".csproj", "cs\\ico4545.gif", "xml", -1, FileGroup.Type.CODE),
                new FileTypeInfo(".csv", "cs\\ico4545.gif", "xml", -1, FileGroup.Type.CODE),
                new FileTypeInfo(".js", "seite.gif", "js", -1, FileGroup.Type.CODE),
                new FileTypeInfo(".log", "notepad.gif", "text", -1, FileGroup.Type.CODE),
                new FileTypeInfo(".master", "notepad.gif", "xml", -1, FileGroup.Type.CODE),
                new FileTypeInfo(".sh", "vb\\ico4511.gif", "shell", -1, FileGroup.Type.CODE),
                new FileTypeInfo(".user", "cs\\ico4545.gif", "xml", -1, FileGroup.Type.CODE),
                new FileTypeInfo(".vb", "vb\\ico4511.gif", "vb", -1, FileGroup.Type.CODE),
                new FileTypeInfo(".vbs", "vb\\ico4511.gif", "vb", -1, FileGroup.Type.CODE),
                new FileTypeInfo(".xls", "excel2.gif", "xml", -1, FileGroup.Type.CODE),
                new FileTypeInfo(".xml", "seitex.gif", "xml", -1, FileGroup.Type.CODE),
                new FileTypeInfo(".xss", "seitexs.gif", "css", -1, FileGroup.Type.CODE),
                new FileTypeInfo(".sln", "seitexs.gif", "xml", -1, FileGroup.Type.CODE),

                // audio
                new FileTypeInfo(".mid", "mov.gif", "", 1, FileGroup.Type.AUDIO),
                new FileTypeInfo(".midi", "mov.gif", "", 1, FileGroup.Type.AUDIO),
                new FileTypeInfo(".mp3", "mov.gif", "", 1, FileGroup.Type.AUDIO),
                new FileTypeInfo(".ogg", "mov.gif", "", 1, FileGroup.Type.AUDIO),
                new FileTypeInfo(".mpga", "mov.gif", "", 1, FileGroup.Type.AUDIO),
                new FileTypeInfo(".wav", "mov.gif", "", 1, FileGroup.Type.AUDIO),
                new FileTypeInfo(".wma", "mov.gif", "", 1, FileGroup.Type.AUDIO),

                // video
                new FileTypeInfo(".avi", "mov.gif", "", 15, FileGroup.Type.VIDEO),
                new FileTypeInfo(".wmv", "mov.gif", "", 15, FileGroup.Type.VIDEO),
                new FileTypeInfo(".webm", "mov.gif", "", 15, FileGroup.Type.VIDEO),
                new FileTypeInfo(".mpg", "mov.gif", "", 15, FileGroup.Type.VIDEO),
                new FileTypeInfo(".mpeg", "mov.gif", "", 15, FileGroup.Type.VIDEO),
                new FileTypeInfo(".mov", "mov.gif", "", 15, FileGroup.Type.VIDEO),
                new FileTypeInfo(".swf", "mov.gif", "", 15, FileGroup.Type.VIDEO),
                new FileTypeInfo(".slv", "mov.gif", "", 15, FileGroup.Type.VIDEO),
                new FileTypeInfo(".mp4", "mov.gif", "", 15, FileGroup.Type.VIDEO),
                new FileTypeInfo(".flv", "mov.gif", "", 15, FileGroup.Type.VIDEO),

                // audio+video
                new FileTypeInfo(".rm", "mov.gif", "", 8, FileGroup.Type.AUDVID),
                new FileTypeInfo(".ram", "mov.gif", "", 8, FileGroup.Type.AUDVID),

                // application
                new FileTypeInfo(".pdf", "pdf.gif", "", -1, FileGroup.Type.APPLIEXE),

                // application
                new FileTypeInfo(".pps", "powerpoint2.gif", "", -1, FileGroup.Type.OTHER),
                new FileTypeInfo(".ppt", "powerpoint2.gif", "", -1, FileGroup.Type.OTHER),
                new FileTypeInfo(".doc", "winword2.gif", "", -1, FileGroup.Type.OTHER),

                // binary
                new FileTypeInfo(".dll", "fenster.gif", "", -1, FileGroup.Type.OTHER),
                new FileTypeInfo(".exe", "fenster.gif", "", -1, FileGroup.Type.OTHER),
                new FileTypeInfo(".jar", "zip.gif", "", -1, FileGroup.Type.OTHER),
                new FileTypeInfo(".mdb", "key.gif", "", -1, FileGroup.Type.OTHER),
                new FileTypeInfo(".tar", "zip.gif", "", -1, FileGroup.Type.OTHER),
                new FileTypeInfo(".ttf", "truetype.gif", "", -1, FileGroup.Type.OTHER),
                new FileTypeInfo(".zip", "zip.gif", "", -1, FileGroup.Type.OTHER),

                // special
                new FileTypeInfo(".cfg", "text.gif", "", -1, FileGroup.Type.OTHER),
                new FileTypeInfo(".ebook", "buch.gif", "", -1, FileGroup.Type.OTHER),
                new FileTypeInfo(".ebooks", "buecher1.gif", "", -1, FileGroup.Type.OTHER),
                new FileTypeInfo(".images", "bild.gif", "", -1, FileGroup.Type.OTHER),
                new FileTypeInfo(".pictures", "bild.gif", "", -1, FileGroup.Type.OTHER),
                new FileTypeInfo(".programm", "diskette2.gif", "", -1, FileGroup.Type.OTHER),
                new FileTypeInfo(".sources", "dienste.gif", "", -1, FileGroup.Type.OTHER),
                new FileTypeInfo(".link", "globusli.gif", "", -1, FileGroup.Type.OTHER)
            };
        }

// Start of StaticHex.cs

        public static class Hex
        {
            const bool Show16BitChars = false;
            const bool Show8BitChars = true;
            const bool ShowIBMchars = false;

            public static string ToHex1(int b)
            {
                string HexChars = "0123456789abcdef";
                return HexChars[b].ToString();
            }
            public static string ToHex(byte b)
            {
                return Hex.ToHex1(b / 16) + Hex.ToHex1(b % 16);
            }
            public static string ToHex(int b)
            {
                return Hex.ToHex((byte)(b / 256)) + Hex.ToHex((byte)(b % 256));
            }
            public static string ToHex(string s)
            {
                string HexChars = "";
                for (int i = 0; i < s.Length; i++)
                {
                    HexChars += "0x" + Hex.ToHex((byte)s[i]) + " ";
                }
                return HexChars;
            }
            private static byte[] GetBuffer(string s)
            {
                byte[] buffer = new byte[s.Length * 2];
                for (int i = 0; i < s.Length; i++)
                {
                    int b;
                    try
                    {
                        b = char.ConvertToUtf32(s, i);
                    }
                    catch
                    {
                        b = 65635;
                    }
                    buffer[2 * i] = (byte)(b / 256);
                    buffer[2 * i + 1] = (byte)(b % 256);
                }
                return buffer;
            }
            public static string ToChar(int b)
            {
                if (b < 32) return (ShowIBMchars ? "&#x25a" + Hex.ToHex1(b) + ";" : "&#x00b7;");
                else return ((char)b).ToString();
            }
            public static string ToUtf8(byte[] b)
            {
                if (((int)b[0] * 256 + (int)b[1]) < 32) return (ShowIBMchars ? "&#x25a" + Hex.ToHex1((char)b[1]) + ";" : "&#x00b7;");
                else return (new UTF8Encoding()).GetString(b);
            }
            public static string Dump(string FilePathAbsolute)
            {
                FileInfo fi = new FileInfo(FilePathAbsolute);
                int FileLength = (int)(fi.Length % 65536);
                BinaryReader binReader = new BinaryReader(File.Open(FilePathAbsolute, FileMode.Open, FileAccess.Read));
                byte[] buffer = new byte[FileLength];
                int ReadBytes = binReader.Read(buffer, 0, FileLength);
                binReader.Close();
                return Hex.Dump(buffer);
            }
            public static string Highlight(string Text, bool HighlightControls, bool HighlightForeign)
            {
                if (HighlightControls) return "<span class='HexCtrl'>" + Text + "</span>";
                else if (HighlightForeign) return "<span class='Hex8'>" + Text + "</span>";
                else return Text;
            }
            public static string Highlight(string Text, byte ToDisplay)
            {
                bool HighlightControls = false;
                bool HighlightForeign = false;
                if (ToDisplay < 32) HighlightControls = true;
                if (ToDisplay > 127) HighlightForeign = true;
                return Highlight(Text, HighlightControls, HighlightForeign);
            }
            public static string Dump(byte[] b)
            {
                string s = "";
                int PageCount = b.Length / 256; if (b.Length % 256 != 0) PageCount++;
                if (PageCount > 16) PageCount = 16;
                for (int p = 0; p < PageCount; p++)
                {
                    s += "<span class='HexContent'>" + Hex.ToHex((byte)p) + "</span><span class='HexCaption'> 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f" + (Show8BitChars ? "  0123456789abcdef" : "") + (Show16BitChars ? "  01234567" : "") + "</span>\r\n";
                    for (int r = 0; r < 16; r++)
                    {
                        string prefix = "<span class='HexCaption'>" + Hex.ToHex1(r) + "0</span> ";
                        string line_hex = "";
                        string line_char = "";
                        string line_char2 = "";
                        byte[] line_char20 = { 0, 0 };
                        for (int c = 0; c < 16; c++)
                        {
                            int index = p * 256 + r * 16 + c;
                            if (index == b.Length)
                            {
                                line_hex = line_hex.PadRight(16 * 3, ' ');
                                line_char = line_char + "".PadRight(16 - c, ' ');
                                s += prefix + line_hex + (Show8BitChars ? " " + Untag(line_char) : "") + (Show16BitChars ? "  " + Untag(line_char2) : "") + "\r\n";
                                goto for_end;
                            }
                            byte ToDisplay = b[index];
                            string strHex = ToHex(ToDisplay);
                            string strChar = ToChar(ToDisplay);
                            line_hex += Highlight(strHex,ToDisplay) + " ";
                            line_char += Highlight(Untag(strChar), ToDisplay);
                            line_char20[index % 2] = ToDisplay;
                            if (index % 2 == 1)
                            {
                                line_char2 += Untag(ToUtf8(line_char20));
                            }
                        }
                        s += prefix + line_hex + (Show8BitChars ? " " + line_char : "") + (Show16BitChars ? "  " + line_char2 : "") + "\r\n";
                    }
                    s += "\r\n";
                }
            for_end:
                return s;
            }
        }

// Start of StaticMime.cs

        public static class Mime
        {
            static public NameValueCollection mimemap = new NameValueCollection();
            public static string GetMimeType(string Extension)
            {
                if (mimemap.Count == 0) BuildMimeMap();
                return mimemap[Extension];
            }
            public static void BuildMimeMap()
            {
                using (DirectoryEntry entry = new DirectoryEntry("IIS://localhost/MimeMap"))
                {
                    PropertyValueCollection properties;
                    try
                    {
                        properties = entry.Properties["MimeMap"];
                    }
                    catch
                    {
                        mimemap.Add("Error", "Mime Types cannot be loaded");
                        return;
                    }
                    Type type = properties[0].GetType();

                    foreach (object property in properties)
                    {
                        BindingFlags f = BindingFlags.GetProperty;
                        string ext = type.InvokeMember("Extension", f, null, property, null) as String;
                        string mime = type.InvokeMember("MimeType", f, null, property, null) as String;
                        mimemap.Add(ext, mime);
                    }
                }
            }
        }

// Start of StaticSyntaxHighlighting.cs

        static string GetHtmlJsHighlightReduced(State MyState, string brush)
        {
            string s =
            "<link href='" + MyState.UrlJsHighlight + "styles/shCoreDefault.css' rel='stylesheet' type='text/css' />"
            + "\r\n<link href='" + MyState.UrlJsHighlight + "styles/shThemeDefault.css\" rel='stylesheet' type='text/css' />"
            + "\r\n<script src='" + MyState.UrlJsHighlight + "scripts/shCore.js' type='text/javascript'></" + "script>";
            s += "\r\n<script src='" + MyState.UrlJsHighlight + "scripts/";
            switch (brush)
            {
                case "c":
                    break;
                case "cpp":
                    s += "shBrushCpp";
                    break;
                case "csharp":
                case "c-sharp":
                    s += "shBrushCsharp";
                    break;
                case "css":
                    s += "shBrushCss";
                    break;
                case "java":
                    s += "shBrushJava";
                    break;
                case "javaFX":
                    s += "shBrushJavaFX";
                    break;
                case "js":
                case "jscript":
                case "javascript":
                    s += "shBrushJScript";
                    break;
                case "perl":
                case "pl":
                    s += "shBrushPerl";
                    break;
                case "php":
                    s += "shBrushPhp";
                    break;
                case "ps":
                    s += "shBrushPowerShell";
                    break;
                case "py":
                    s += "shBrushPython";
                    break;
                case "sql":
                    s += "shBrushSql";
                    break;
                case "text":
                    s += "shBrushPlain";
                    break;
                case "vb":
                    s += "shBrushVb";
                    break;
                case "xml":
                    s += "shBrushXml";
                    break;
            }
            s += ".js' type=\"text/javascript\"></" + "script>";
            return s;
        }
        static string GetHighlightCode(string Html, string brush)
        {
            return "\r\n<pre " + "class='brush: " + brush + "'>\r\n" + Untag(Html) + "</pre>\r\n";
        }
        static string GetHighlightCodeAndInsertScript(State MyState, string Html, string brush)
        {
            return GetHtmlJsHighlightReduced(MyState, brush) 
                + "\r\n<pre " + "class='brush: " + brush + "'>\r\n" 
                + Untag(Html) 
                + "</pre>\r\n"
                + "\r\n<script type='text/javascript'>"
                + "SyntaxHighlighter.all();" 
                + "</" + "script>";
        }

// Start of StaticTemplates.cs

        public class MediaTemplate
        {
            public static int CompareTemplates(MediaTemplate x, MediaTemplate y)
            {
                return x.Name.CompareTo(y.Name);
            }
            public int Id;
            public bool UseWithImage;
            public bool UseWithAudio;
            public bool UseWithVideo;
            public string Name;
            public string Template;
            public MediaTemplate(int Id, bool UseWithImage, bool UseWithAudio, bool UseWithVideo, string Name, string Template)
            {
                this.Id = Id;
                this.UseWithImage = UseWithImage;
                this.UseWithAudio = UseWithAudio;
                this.UseWithVideo = UseWithVideo;
                this.Name = Name;
                this.Template = Template;
            }
            public string InstantiateTemplate(string Width, string Height, string Name)
            {
                return Template.Replace("#Width#", Width).Replace("#Height#", Height).Replace("#Name#", Name).Replace("&lt;script", "<" + "script").Replace("&lt;/script&gt;", "<" + "/script" + ">");
            }
        }
        public static class MediaTemplates
        {
            public static string InstantiateTemplate(int id, string Width, string Height, string Name)
            {
                return list[id].Template.Replace("#Width#", Width).Replace("#Height#", Height).Replace("#Name#", Name);
            }
            public static bool IsSorted = false;
            public static void Sort()
            {
                if (!IsSorted)
                {
                    list.Sort(MediaTemplate.CompareTemplates);
                    IsSorted = true;
                }
            }

            public static int IdToFind = -1;
            public static MediaTemplate Get(int id)
            {
                IdToFind = id;
                return list.Find(
                delegate(MediaTemplate mt)
                {
                    return (IdToFind == mt.Id);
                });

            }
            // the following construct does not work with framework 2.0 when running in single file mode
            public static List<MediaTemplate> list = new List<MediaTemplate>() 
            {
                new MediaTemplate
                (
                    0,
                    true,
                    false,
                    false,
                    "Image-Tag",
                    "<img \r\n"
                    + "  src='#Name#'\r\n"
                    + "  width='#Width#'\r\n"
                    + "  height='#Height#'\r\n"
                    + "/>\r\n"
                ),
                // http://webplayer.yahoo.com/docs/how-to-set-up/
                // http://webplayer.yahoo.com/docs/how-to-use/
                new MediaTemplate
                (
                    1,
                    false,
                    true,
                    true,
                    "Yahoo Player",
                    "<a href='#Name#'>Play Song</a><br/>"
                    + "&lt;script type='text/javascript' src='http://mediaplayer.yahoo.com/js'>\r\n"
                    + "&lt;/script&gt;\r\n"
                ),
                new MediaTemplate
                (
                    2,
                    false,
                    true,
                    true,
                    "Google Player",
                    "<embed \r\n"
                    + "  type='application/x-shockwave-flash' \r\n"
                    + "  wmode='transparent' \r\n"
                    + "  src='http://www.google.com/reader/ui/3523697345-audio-player.swf?audioUrl=#Name#' \r\n"
                    + "  height='#Height#' \r\n"
                    + "  width='#Width#' \r\n"
                    + "></embed>\r\n"
                ),
                new MediaTemplate
                (
                    3,
                    false,
                    true,
                    false,
                    "Quicktime",
                    "<object \r\n"
                    + "  height='#Height#' \r\n"
                    + "  width='#Width#' \r\n"
                    + "  classid='clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B' \r\n" 
                    + "  codebase='http://www.apple.com/qtactivex/qtplugin.cab'"
                    +"> \r\n"
                    + "  <param name='src' \r\n"
                    + "    value='#Name#' \r\n"
                    + "  />\r\n"
                    + "  <param \r\n"
                    + "    name='controller' \r\n"
                    + "    value='true' \r\n"
                    + "  />\r\n"
                    + "</object>\r\n"
                ),
                new MediaTemplate
                (
                    4,
                    false,
                    true,
                    false,
                    "Flash",
                    "<object \r\n"
                    + "  height='#Height#' \r\n"
                    + "  width='#Width#' \r\n"
                    + "  classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' \r\n"
                    + "  codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0'\r\n"
                    + ">\r\n" 
                    + "  <param \r\n"
                    + "    name='src' \r\n"
                    + "    value='#Name#'\r\n"
                    + "  >\r\n"
                    + "  <embed \r\n"
                    + "    src='#Name#' \r\n"
                    + "    height='#Height#' \r\n"
                    + "    width='#Width#' \r\n"
                    + "    type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer'\r\n"
                    + "  ></embed>\r\n"
                    + "</object>\r\n"
                ),
                new MediaTemplate
                (
                    5,
                    false,
                    true,
                    false,
                    "Media Player",
                    "<object \r\n"
                    + "  height='#Height#' \r\n"
                    + "  width='#Width#' \r\n"
                    + "  type='video/x-ms-asf' url='#Name#' data='#Name#' \r\n"
                    + "  classid='CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6'> \r\n"
                    + "  <param name='url' value='#Name#'> \r\n"
                    + "  <param name='filename' value='#Name#'> \r\n"
                    + "  <param name='autostart' value='1'> \r\n"
                    + "  <param name='uiMode' value='full' /> \r\n"
                    + "  <param name='autosize' value='1'> \r\n"
                    + "  <param name='playcount' value='1'> \r\n" 
                    + "  <embed \r\n"
                    + "    type='application/x-mplayer2' \r\n"
                    + "    src='#Name#' \r\n"
                    + "    width='#Width#' \r\n"
                    + "    height='#Height#' \r\n"
                    + "    autostart='true' \r\n"
                    + "    showcontrols='true' \r\n"
                    + "    pluginspage='http://www.microsoft.com/Windows/MediaPlayer/'>\r\n"
                    + "  </embed>\r\n"
                    + "</object>\r\n"
                ),
                new MediaTemplate
                (
                    6,
                    false,
                    true,
                    false,
                    "Media Player-2",
                    "<OBJECT ID='MediaPlayer' \r\n"
                    + "  height='#Height#' \r\n"
                    + "  width='#Width#' \r\n"
                    + "  CLASSID='CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95'\r\n"
                    + "  STANDBY='Loading Windows Media Player components...' \r\n"
                    + "  TYPE='application/x-oleobject'>\r\n"
                    + "  <PARAM NAME='FileName' \r\n"
                    + "    VALUE='#Name#'\r\n"
                    + "  >\r\n"
                    + "  <EMBED TYPE='application/x-mplayer2' \r\n"
                    + "    height='#Height#' \r\n"
                    + "    width='#Width#' \r\n"
                    + "    src='#Name#'\r\n"
                    + "    name='MediaPlayer'>\r\n"
                    + "</EMBED>\r\n"
                    + "</object>\r\n"
                ),  
                new MediaTemplate
                (
                    7,
                    false,
                    false,
                    true,
                    "Object-Tag",
                    "<object \r\n"
                    + "  data='#Name#' \r\n"
                    + "  height='#Height#' \r\n"
                    + "  width='#Width#' \r\n"
                    + "/>\r\n"
                ),
                new MediaTemplate
                (
                    8,
                    false,
                    false,
                    true,
                    "Embed-Tag",
                    "<embed \r\n"
                    + "  autostart='true' \r\n"
                    + "  src='#Name#' \r\n"
                    + "  height='#Height#' \r\n"
                    + "  width='#Width#' \r\n"
                    + "/>\r\n"
                ),
                new MediaTemplate
                (
                    9,
                    false,
                    false,
                    true,
                    "Video-Tag",
                    "<video \r\n"
                    + "  height='#Height#' \r\n"
                    + "  width='#Width#' \r\n"
                    + "  controls='controls'\r\n"
                    + ">\r\n"
                    + "  <source src='#Name#' type='video/mp4' />\r\n"
                    + "  Your browser does not support the video tag.\r\n"
                    + "</video>\r\n"
                ),
                new MediaTemplate
                (
                    10,
                    false,
                    false,
                    true,
                    "Using Video-, Embed- and Object-Tag",
                    "<video \r\n"
                    + "  height='#Height#' \r\n"
                    + "  width='#Width#' \r\n"
                    + "  controls='controls'>\r\n"
                    + "  <source \r\n"
                    + "    src='#Name#' \r\n"
                    + "    type='video/mp4' \r\n"
                    + "    />\r\n"
                    + "  <object \r\n"
                    + "    data='#Name#' \r\n"
                    + "    height='#Height#' \r\n"
                    + "    width='#Width#' \r\n"
                    + "  >\r\n"
                    + "    <embed \r\n"
                    + "      src='#Name#' \r\n"
                    + "      height='#Height#' \r\n"
                    + "      width='#Width#' \r\n"
                    + "    >\r\n"
                    + "      Your browser does not support video\r\n"
                    + "    </embed>\r\n"
                    + "  </object>\r\n" 
                    + "</video>\r\n"
                ),
                new MediaTemplate
                (
                    11,
                    true,
                    true,
                    true,
                    "iframe-Tag",
                    "<iframe \r\n"
                    + "  height='#Height#' \r\n"
                    + "  width='#Width#' \r\n"
                    + "  src='#Name#' \r\n"
                    + "  frameborder='0' \r\n"
                    + "  marginwidth='0' \r\n"
                    + "  marginheight='0' \r\n"
                    + "  scrolling='auto' \r\n"
                    + "> \r\n"
                    + "</iframe>\r\n"
                ),
                new MediaTemplate
                (
                    12,
                    true,
                    true,
                    true,
                    "Link",
                    "<a \r\n"
                    + "  href='#Name#' \r\n"
                    + "  target='_blank' \r\n"
                    + ">#Name# \r\n"
                    + "</a>\r\n"
                ),
                new MediaTemplate
                (
                    13,
                    false,
                    true,
                    true,
                    "Yahoo Player-2",
                    "<a href='#Name#'>Play Song</a><br/>"
                    + "&lt;script type='text/javascript' src='http://webplayer.yahooapis.com/player.js'>\r\n"
                    + "&lt;/script&gt;\r\n"
                ),
                new MediaTemplate
                (
                    14,
                    true,
                    true,
                    true,
                    "NewWin",
                    "<script  type='text/javascript'>\r\n"
                    + " window.open('#Name#','SexNew')\r\n"
                    + "</" + "script>\r\n"
                ),
                new MediaTemplate
                (
                    15,
                    true,
                    true,
                    true,
                    "ORF-TvThek",
                    "\r\n<object id='WmPlayerObject' type='application/x-ms-wmp' standby='Lade Windows Media Player Komponente...' style='width:27.4em;height:18.9em;'>"
                        + "\r\n<param name='URL' value='#Name#' />"
                        + "\r\n<param name='stretchToFit' value='true' />"
                        + "\r\n<param name='AutoSize' value='1' />"
                        + "\r\n<param name='captioningID' value='subtitles_captioning_id' />"
                        + "\r\n<param name='uimode' value='full' />         "
                        + "\r\n<param name='autoStart' value='false' />"
                        + "\r\n<embed type='application/x-mplayer2' "
                            + "pluginspage='http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/' "
                            + "src='#Name#' "
                            + "id='WmPlayerEmbed' "
                            + "name='WmPlayerObject' "
                            + "uiMode='full' "
                            + "ShowDisplay='0' "
                            + "captioningID='subtitles_captioning_id' "
                            + "ShowStatusBar='1' "
                            + "AutoStart='0' "
                            + "AutoSize='1' "
                            + "stretchToFit='true' "
                            + "scale='ASPECT' "
                            + "style='width:#Width#;height:#Height#;' "
                            + "airplay='allow' "
                        + "\r\n/>"
                        + "\r\n<p class='missing-plugin-hint'>Bitte installieren Sie das <a href='http://www.google.com/search?q=windows+media+player+browser+plugin+download'"
                            + "title='Google Suche nach WMP Plugin'>Windows Media Player Plugin</a>"
                        + "\r\n</p>"
                      + "\r\n</object>"
                )
            };
        }

// Start of StaticTree.cs

        public static class Tree
        {
            public static string GetUrl(TreeNode tn, string[] RelativePathComponents, string ApplicationPath)
            {
                string PathReduced = GetPathReduced(tn, RelativePathComponents, ApplicationPath);
                HttpContext myHttpContext = HttpContext.Current;
                HttpRequest r = myHttpContext.Request;
                return r.Url.Scheme + "://" + r.Url.Authority + "/" + PathReduced;
            }
            public static string GetPathReduced(TreeNode tn, string[] RelativePathComponents, string ApplicationPath)
            {
                // correct Path
                string Path = Tree.Path(tn);
                string[] PathComponents = Path.Split(new char[] { '/' });
                int i = 0;
                string PathReduced = "";
                for (i = 0; i < RelativePathComponents.Length; i++)
                {
                    if (RelativePathComponents[i] != "..")
                    {
                        for (int j=i; j<RelativePathComponents.Length; j++)
                        PathReduced += RelativePathComponents[j] + "/";
                        break;
                    }
                }
                for (int j = i; j < PathComponents.Length; j++)
                {
                    PathReduced += PathComponents[j] + "/";
                }
                ItemInfo ii = new ItemInfo(tn.Value);
                if (ii.type == E_ObjectType.FILE) PathReduced = PathReduced.Substring(0, PathReduced.Length - 1);
                return ApplicationPath + PathReduced;
            }
            public static void UnselectNodes(TreeNode n)
            {
                n.Selected = false;
                for (int i = 0; i < n.ChildNodes.Count; i++)
                    UnselectNodes(n.ChildNodes[i]);
            }
            public static string Path(TreeNode tn)
            {
                string delimiter = "/";
                string path = "";
                do
                {
                    if (tn.Parent == null) // root, do not include in path
                    {
                        break;
                    }
                    path = tn.Text + (path == "" ? "" : delimiter) + path;
                    tn = tn.Parent;
                }
                while (true);
                return path;
            }
            public static string PathWR(TreeNode tn)
            {
                string delimiter = "/";
                string path = "";
                do
                {
                    path = tn.Text + (path == "" ? "" : delimiter) + path;
                    if (tn.Parent == null) 
                    {
                        break;
                    }
                    tn = tn.Parent;
                }
                while (true);
                return path;
            }
            public static void Expand(TreeNode tn, int Level)
            {
                if (Level >= tn.Depth) tn.Expand(); else tn.Collapse();
                for (int i = 0; i < tn.ChildNodes.Count; i++)
                    Expand(tn.ChildNodes[i], Level);
            }
            public static void ExpandPath(TreeNode tn)
            {
                if (tn == null) return;
                do
                {
                    tn.Expand();
                    if (tn.Parent == null) // root, do not include in path
                    {
                        break;
                    }
                    tn = tn.Parent;
                }
                while (true);
            }
            public static bool Search(TreeNode tn, string s)
            {
                bool Found = false;
                if (tn == null) return false;
                if (tn.Text.ToLower().Contains(s.ToLower()))
                {
                    Found = true;
                    tn.Checked = true;
                    ExpandPath(tn);
                }
                for (int i = 0; i < tn.ChildNodes.Count; i++)
                    Found = Found || Search(tn.ChildNodes[i], s);
                return Found;
            }
            public static long Size(TreeNode tn)
            {
                long value_currentdirectory = 0;
                for (int i = 0; i < tn.ChildNodes.Count; i++)
                {
                    if (tn.ChildNodes[i].Value.StartsWith("d"))
                    {
                        value_currentdirectory += Size(tn.ChildNodes[i]);
                    }
                    else
                    {
                        string v = tn.ChildNodes[i].Value;
                        string[] f = v.Split(new char[] { ValueDelimiter[0] });
                        value_currentdirectory += long.Parse(f[1]);
                    }
                }
                return value_currentdirectory;
            }
        }

    </script>
    <style type="text/css">
        #MyBody
{
    margin: 0;
}
#Div_Title
{
    z-index:2;
    overflow:hidden;
    position:fixed;
    height:40pt;
    top: 0px;
    left: 250px;
    width:100%;
    background-color:#88aabb;
}
#Div_Details
{
    z-index:2;
    overflow:hidden;
    position: fixed;
    top:40pt;
    height:40pt;
    left: 250px;
    width:100%;
    background-color:#99bbcc;
}
#Div_Menu
{
    z-index:2;
    overflow:hidden;
    position: fixed;
    left: 250px;
    width:100%;
    background-color:#aaccdd;
    top:80pt;
    height:25pt;
}
#Div_MenuServer
{
    z-index:2;
    overflow:hidden;
    position: fixed;
    left: 0px;
    top:80pt;
    width:250pt;
    height:25pt;
}
#Div_MenuItem
{
    z-index:2;
    overflow:hidden;
    position: fixed;
    top:80pt;
    left:200pt;
    height:25pt;
}
#iframe_Content, pre
{
    font-family:Courier;
    font-size:8pt;
}
#Div_Server
{
    z-index:5;
    overflow:auto;
    position: fixed;
    background-color:#ffffff;
    top:0px;
    left:0px;
    width:250px;
    vertical-align:top;
}
#Div_Content
{
    z-index:5;
    position: fixed;
    top:0px;
    left:250px;
    vertical-align:top;
    overflow:scroll;
    border-left-style:solid;
    border-left-width:1px;
    border-left-color:#444444;
}
#Div_ContentItem
{
    z-index:5;
    position: fixed;
    background-color:#ffffff;
    top:130px;
    left:250px;
    vertical-align:top;
    overflow:scroll;
    border-left-style:solid;
    border-left-width:1px;
    border-left-color:#444444;
    font-family:Courier;
    font-size:8pt;
}
.Title, .ApplicationTitle
{
    font-family:Verdana;
    font-size:8pt;
    color:#ffffff;
}
.ApplicationTitle
{
    font-size:20pt;
    font-weight:bold;
}
th
{
    background-color:#cccccc;
}
.Details
{
    font-size:8pt;
    font-family:Courier;
}
.Menu_Command, .Menu_Command_Active
{
    font-family:Verdana;
    font-size:8pt;
    color:#444444;
    font-weight:bold;
    text-decoration: none;
}
.Menu_Command_Active
{
    font-family:Verdana;
    font-size:8pt;
    color:#444444;
    font-weight:bold;
    text-decoration: none;
}
.HexCaption
{
    font-family:Courier;
    font-size:8pt;
    color:#ffffff;
    font-weight:bold;        
    background-color:#88aabb;
}
.HexTitle
{
    font-family:Courier;
    font-size:8pt;
    color:#ffffff;
    font-weight:bold;
}
.HexContent
{
    font-family:Courier;
    font-size:8pt;
    color:#444444;
}
.LH
{
    background-color:#99bbcc;
    color:#ffffff;
}
.LB
{
    color:#88aabb;
}
.MyValue
{
    color:#88aabb;
}
.HexCtrl
{
    color:#88aabb;
}
.Hex8
{
    background-color:#cceeff;
}
    </style>
</head>
<body id="MyBody">
    <form id="form1" runat="server">
    <div id="Div_Server">
        <asp:TreeView ID="Tree_Controls" runat="server" NodeIndent="10" ShowExpandCollapse="true"
            ImageSet="Arrows" BorderWidth="0" PopulateNodesFromClient="true" OnSelectedNodeChanged="Tree_Controls_SelectedNodeChanged">
            <SelectedNodeStyle Font-Underline="True" ForeColor="#DD5555" Font-Bold="true" HorizontalPadding="0px"
                VerticalPadding="0px" />
            <HoverNodeStyle Font-Underline="True" ForeColor="#5555DD" />
            <NodeStyle Font-Names="Verdana" Font-Size="8pt" ForeColor="#88aabb" HorizontalPadding="0px"
                NodeSpacing="0px" VerticalPadding="0px" />
            <ParentNodeStyle Font-Bold="False" />
            <Nodes>
                <asp:TreeNode Value="" Text="SEX" Expanded="false" ToolTip="Server Explorer">
                    <asp:TreeNode Text="<span style='color:red'>S</span>erver" Expanded="false">
                        <asp:TreeNode Value="Server.Environment" ToolTip="Server Environment" Text="Server-Environment" />
                        <asp:TreeNode Value="Server.Modules" ToolTip="Modules loaded on Server" Text="Server-Modules" />
                        <asp:TreeNode Value="Server.MimeExtensions" ToolTip="MimeTypes from Server" Text="Server-MimeExtensions" />
                        <asp:TreeNode Value="Server.MimeTypes" ToolTip="MimeTypes from Server" Text="Server-MimeTypes" />
                        <asp:TreeNode Value="Server.Configuration" ToolTip="Web Configuration" Text="Server-WebSettings" />
                        <asp:TreeNode Value="Server.Context" ToolTip="Properties of Context Object" Text="Server-Context" />
                        <asp:TreeNode Value="Server.Server" ToolTip="Properties of Server Object" Text="Server-Server" />
                        <asp:TreeNode Value="Server.Application" ToolTip="Properties of Application Object"
                            Text="Server-Application" />
                        <asp:TreeNode Value="Server.Variables" ToolTip="ServerVariables" Text="Server-Variables" />
                        <asp:TreeNode Value="Server.Request" ToolTip="Properties of Request Object" Text="Connection-Request" />
                        <asp:TreeNode Value="Server.Response" ToolTip="Properties of Response Object" Text="Connection-Response" />
                        <asp:TreeNode Value="Server.Session" ToolTip="Properties of Session Object" Text="Connection-Session" />
                        <asp:TreeNode Value="Server.Cookies" ToolTip="Properties of Cookies Object" Text="Client-Cookies" />
                        <asp:TreeNode Value="Server.Browser" ToolTip="Your Browser Capabilities" Text="Client-Browser" />
                        <asp:TreeNode Value="Server.Mobile" ToolTip="Your Mobile Capabilities" Text="Client-Mobile" />
                    </asp:TreeNode>
                    <asp:TreeNode Text="<span style='color:red'>EX</span>plorer" Expanded="false">
                        <asp:TreeNode Value="Explorer.FileGroups" ToolTip="FileGroups" Text="File-Groups" />
                        <asp:TreeNode Value="Explorer.Extensions" ToolTip="Extensions" Text="File-Extensions" />
                        <asp:TreeNode Value="Explorer.ImageFlags" ToolTip="ImageFlags" Text="File-ImageFlags" />
                        <asp:TreeNode Value="Explorer.Exif" ToolTip="List of known Exif-Ids" Text="File-Exif-Data" />
                        <asp:TreeNode Value="Explorer.Templates" ToolTip="Templates used for Media-Files"
                            Text="Media-Templates" />
                        <asp:TreeNode Value="Explorer.Attributes" ToolTip="File or directory attributes"
                            Text="File-Attributes" />
                        <asp:TreeNode Value="Server.ViewState" ToolTip="Properties of ViewState" Text="Page-ViewState" />
                        <asp:TreeNode Value="About" ToolTip="About this Program" Text="Explorer.About" />
                    </asp:TreeNode>
                </asp:TreeNode>
            </Nodes>
        </asp:TreeView>
        <asp:TreeView ID="Tree_Content" runat="server" NodeIndent="10" ShowExpandCollapse="true"
            ImageSet="Arrows" BorderWidth="0" PopulateNodesFromClient="true" EnableClientScript="true"
            OnSelectedNodeChanged="Tree_Content_SelectedNodeChanged" OnTreeNodePopulate="Tree_Content_TreeNodePopulate"
            OnTreeNodeExpanded="Tree_Content_TreeNodeExpanded">
            <SelectedNodeStyle Font-Underline="True" ForeColor="#DD5555" Font-Bold="true" HorizontalPadding="0px"
                VerticalPadding="0px" />
            <HoverNodeStyle Font-Underline="True" ForeColor="#5555DD" />
            <NodeStyle Font-Names="Verdana" Font-Size="8pt" ForeColor="#444444" HorizontalPadding="0px"
                NodeSpacing="0px" VerticalPadding="0px" />
            <ParentNodeStyle Font-Bold="False" />
        </asp:TreeView>
    </div>
    <div id="Div_Content">
        <div id="Div_Title">
            <asp:Label runat="server" ID="Label_Server" CssClass="ApplicationTitle" />
            <asp:Label runat="server" ID="Label_ServerPath" ToolTip="Path" CssClass="ApplicationTitle"
                ForeColor="#888800" />
            <asp:Label runat="server" ID="Label_PathItem" ToolTip="Path" CssClass="ApplicationTitle"
                ForeColor="#bbbb33" />
            <asp:Label runat="server" ID="Label_TitleItem" ToolTip="File or Directory Name" CssClass="ApplicationTitle"
                ForeColor="#bb3333" />
        </div>
        <div id="Div_Details" class="Details" runat="server">
        </div>
        <div id="Div_Menu">
            <div id="Div_MenuServer" runat="server" visible="false">
                <asp:Table runat="server" ID="Table_TreeCommands">
                    <asp:TableRow>
                        <asp:TableCell>
                            <asp:Menu runat="server" ID="Menu_TreeCommands" Orientation="Horizontal" RenderingMode="Table"
                                PathSeparator="." OnMenuItemClick="Menu_MenuItemClick" Visible="false">
                                <StaticMenuItemStyle ForeColor="White" Font-Names="Verdana" Font-Size="12pt" />
                                <StaticSelectedStyle BackColor="#88aabb" />
                                <Items>
                                    <asp:MenuItem Value="0" ToolTip="Show one level" Text="1&nbsp;" />
                                    <asp:MenuItem Value="1" ToolTip="Show two levels" Text="2&nbsp;" />
                                    <asp:MenuItem Value="2" ToolTip="Show three levels" Text="3&nbsp;" />
                                    <asp:MenuItem Value="3" ToolTip="Show four levels" Text="4&nbsp;" />
                                    <asp:MenuItem Value="9" ToolTip="Show all levels" Text="9&nbsp;" />
                                </Items>
                            </asp:Menu>
                        </asp:TableCell>
                        <asp:TableCell>
                            <asp:TextBox runat="server" ID="TextBox_Search" Width="50" Visible="false"></asp:TextBox>
                            <asp:LinkButton runat="server" CssClass="Menu_Command" ID="LinkButton_Search" CommandName="Search"
                                ToolTip="Search" OnCommand="LinkButton_Server_Command" Visible="false">Go</asp:LinkButton>
                        </asp:TableCell>
                    </asp:TableRow>
                </asp:Table>
            </div>
            <div id="Div_MenuItem" runat="server">
                <asp:Panel runat="server" ID="Panel_ItemCommands">
                    <table>
                        <tr>
                            <td>
                                <asp:Menu runat="server" ID="Menu_File" Orientation="Horizontal" RenderingMode="Table"
                                    PathSeparator="." OnMenuItemClick="Menu_MenuItemClick">
                                    <StaticMenuItemStyle ForeColor="White" Font-Names="Verdana" Font-Size="12pt" />
                                    <StaticSelectedStyle BackColor="#88aabb" />
                                </asp:Menu>
                                <asp:Menu runat="server" ID="Menu_File_Template" Visible="false" Orientation="Horizontal"
                                    RenderingMode="Table" PathSeparator="." OnMenuItemClick="Menu_MenuItemClick">
                                    <StaticMenuItemStyle ForeColor="White" Font-Names="Verdana" Font-Size="12pt" />
                                    <StaticSelectedStyle BackColor="#88aabb" />
                                    <Items>
                                        <asp:MenuItem Value="FilePermissions" Text="Permissions" ToolTip="Show Permission" />
                                        <asp:MenuItem Value="FileHex" Text="Hex" ToolTip="Show Hex Representation (max. 65k)" />
                                        <asp:MenuItem Value="FileDownload" Text="Download" ToolTip="Download File" />
                                        <asp:MenuItem Value="FileFrame" Text="Frame" ToolTip="Load File in Frame" />
                                        <asp:MenuItem Value="FileNewWin" Text="NewWin" ToolTip="Load File in new window" />
                                        <asp:MenuItem Value="FileCode" Text="Code" ToolTip="Show Code (using SyntaxHighlighter from Alex Gorbatchev)" />
                                        <asp:MenuItem Value="FileInline" Text="Inline" ToolTip="Insert File Contents Inline" />
                                        <asp:MenuItem Value="FileEmbed" Text="Embed" ToolTip="Embed File Using Media-Template" />
                                        <asp:MenuItem Value="FileSpecial" Text="Special" ToolTip="Special Properties of this file type" />
                                        <asp:MenuItem Value="FileExif" Text="Exif" ToolTip="Exif Date of JPEG-Files" />
                                    </Items>
                                </asp:Menu>
                                <asp:Menu runat="server" ID="Menu_Directory" Orientation="Horizontal" RenderingMode="Table"
                                    PathSeparator="." OnMenuItemClick="Menu_MenuItemClick">
                                    <StaticMenuItemStyle ForeColor="White" Font-Names="Verdana" Font-Size="12pt" />
                                    <StaticSelectedStyle BackColor="#88aabb" />
                                    <Items>
                                        <asp:MenuItem Value="DirectoryPermissions" Text="Permissions" ToolTip="Show Directory Permissions" />
                                        <asp:MenuItem Value="DirectoryFrame" Text="Frame" ToolTip="Show Directory in Frame" />
                                        <asp:MenuItem Value="DirectoryList" Text="List" ToolTip="Show Directory as List" />
                                        <asp:MenuItem Value="DirectoryThumbs" Text="Thumbs" ToolTip="Show Directory using Thumbnails" />
                                    </Items>
                                </asp:Menu>
                                <asp:Panel runat="server" ID="Panel_LoginCommands">
                                    <asp:TextBox runat="server" ID="TextBox_Login" Width="50" Height="10" TextMode="Password"></asp:TextBox>
                                    <asp:LinkButton runat="server" CssClass="Menu_Command" ID="LinkButton_Login" Font-Names="Verdana"
                                        Font-Size="12pt" CommandName="Login" OnCommand="LinkButton_Server_Command">Login</asp:LinkButton>
                                </asp:Panel>
                            </td>
                            <td>
                                <asp:DropDownList runat="server" ID="DropDownList_Template" OnSelectedIndexChanged="DropDownList_Template_SelectedIndexChanged"
                                    AutoPostBack="True">
                                </asp:DropDownList>
                            </td>
                        </tr>
                    </table>
                </asp:Panel>
            </div>
        </div>
        <asp:Panel ID="Div_ContentItem" runat="server">
            <asp:Literal runat="server" ID="Literal_Content"></asp:Literal>
            <iframe runat="server" scrolling="auto" frameborder="0" width="100%" height="100%"
                id="iframe_Content" src=""></iframe>
        </asp:Panel>
    </div>
    </form>
    <%--asp:Literal ID="Literal_JS_Highlight_End" runat="server"></asp:Literal>
    <script type="text/javascript">
        SyntaxHighlighter.all()
    </script --%>
</body>
</html>
