Ejemplo n.º 1
0
        private string GeneratePage(string page)
        {
            string rval = "<html><body>";

            if (!string.IsNullOrEmpty(page))
            {
                rval += "<div style=\"paddding:20px;\"><a href=\"#\" onclick=\"window.external.ShowPage('');\" style=\"color:#0000FF;cursor:pointer;\">Home</a></div>";
                string[]   parts = page.Split(new[] { "." }, StringSplitOptions.RemoveEmptyEntries);
                List <int> inds  = new List <int>(0);
                foreach (string p in parts)
                {
                    try
                    {
                        inds.Add(int.Parse(p));
                    }
                    catch { }
                }
                string tmpinds = "";
                for (int i = 0; i < inds.Count - 1; i++)
                {
                    tmpinds += inds[i] + "";
                    if (i < inds.Count - 2)
                    {
                        tmpinds += ".";
                    }
                }
                rval += "<div style=\"paddding:20px;\"><a href=\"#\" onclick=\"window.external.ShowPage('" + tmpinds + "');\" style=\"color:#0000FF;cursor:pointer;\">Up one level</a></div>";
                MyDictionary tmpd = fileIndex;
                for (int i = 0; i < inds.Count; i++)
                {
                    int ti = inds[i];
                    tmpd = tmpd[ti];
                    if (tmpd.Keys.Length > 0 && tmpd["name"].Value != null)
                    {
                        rval += "<h" + (i + 1) + ">" + tmpd["name"] + "</h" + (i + 1) + ">";
                    }
                }
                try
                {
                    if (tmpd.Keys.Length > 0)
                    {
                        string fcont = Filesystem.FileReadAllText(tmpd["fname"]);
                        rval += "<div>" + EvalLinks(fcont) + "</div>";
                    }
                }
                catch { }
                if (tmpd.IKeys.Length > 0 && tmpd[tmpd.IKeys[0]].Keys.Length > 0 && tmpd[tmpd.IKeys[0]]["sname"] != null)
                {
                    foreach (MyDictionary d in tmpd.Values)
                    {
                        if (d.Keys.Length > 0 && d["sname"].Value != null)
                        {
                            rval += "<div style=\"font-size:larger;font-weight:bold;padding-top:20px;\">" + d["sname"] + "</div>";
                            try
                            {
                                if (d.Keys.Length > 0)
                                {
                                    string fcont = Filesystem.FileReadAllText(d["fname"]);
                                    rval += "<div>" + EvalLinks(fcont) + "</div>";
                                }
                            }
                            catch { }
                        }
                    }
                }
                try
                {
                    rval += GenerateLinks(tmpd, page, "");
                }
                catch { }
            }
            else
            {
                if (fileIndex.Keys.Length > 0 && fileIndex["hname"].Value != null)
                {
                    rval += "<h1>" + fileIndex["hname"] + "</h1>";
                }
                else
                {
                    rval += "<h1>Multibox Help</h1>";
                }
                try
                {
                    if (fileIndex.Keys.Length > 0)
                    {
                        string fcont = Filesystem.FileReadAllText(fileIndex["fname"]);
                        rval += "<div>" + EvalLinks(fcont) + "</div>";
                    }
                }
                catch { }
                try
                {
                    rval += GenerateLinks(fileIndex, "", "");
                }
                catch { }
            }
            rval += "</body></html>";
            return(rval);
        }