Exemplo n.º 1
0
 //----------------------------------------------------------------------------------------------------
 public void AppendSibling(ElementHolder element)
 {
     if (this.Parent != null)
     {
         this.Parent.AppendChild(element);
     }
 }
Exemplo n.º 2
0
 //----------------------------------------------------------------------------------------------------
 public void AppendChild(ElementHolder element)
 {
     if (this.Children == null)
     {
         this.Children = new ElementHolder[0];
     }
     this.Children[this.Children.Length] = element;
     element.Parent = this;
 }
Exemplo n.º 3
0
        //----------------------------------------------------------------------------------------------------
        private string GetHtml_FromTemplate()
        {
            string rtn = "";
            var    arr = st.New(this.GetTemplate()).Split("<html>", true);

            if (arr.Length < 1)
            {
                return("");
            }

            var           lines           = arr[1].Split("\n", false);
            ElementHolder tree            = null;
            ElementHolder previousElement = null;

            for (int i = 0; i < lines.Length; i++)
            {
                var line = lines[i].Trim();
                if (line.StartsWith("-", false))
                {
                    var element = new ElementHolder();
                    element.Parse(line);

                    if (tree == null)
                    {
                        tree               = element;
                        tree.IsRoot        = true;
                        tree.ClassesString = st.New(tree.ClassesString + " jRoot").Trim().TheString;
                    }
                    else if (element.TreeLevel < previousElement.TreeLevel)
                    {
                        int backTrack = previousElement.TreeLevel - element.TreeLevel;
                        var tmpParent = previousElement;
                        if (backTrack <= 50)
                        {
                            for (int b = 0; b < backTrack; b++)
                            {
                                if (tmpParent.Parent != null)
                                {
                                    tmpParent = tmpParent.Parent;
                                }
                            }
                        }
                        if (tmpParent != null)
                        {
                            tmpParent.AppendSibling(element);
                        }
                    }
                    else if (element.TreeLevel == previousElement.TreeLevel)
                    {
                        previousElement.AppendSibling(element);
                    }
                    else if (element.TreeLevel > previousElement.TreeLevel)
                    {
                        previousElement.AppendChild(element);
                    }
                    previousElement = element;
                }
            }
            rtn += tree.ToHtmlString();


            if (1 == 0)
            {
                return("<div style='font-size: .65em; line-height: 1em;'>" + st.New(rtn).Replace("<", "&lt;").Replace(">", "&gt;").Replace("\n", "<br />").TheString + "</div>");
            }
            else
            {
                return(rtn);
            }
        }