Exemplo n.º 1
0
        private static void FixTreeNodes(ref TreeNode <CssTreeItem> tn)
        {
            foreach (TreeNode <CssTreeItem> node in tn)
            {
                if (node.Parent != null)
                {
                    node.Data.FullSelector = node.Parent.Data.FullSelector + ">" + node.Data.Selector;

                    node.Data.Tag      = HtmlAddons.GetTag(node.Data.Selector);
                    node.Data.TagClass = HtmlAddons.GetClass(node.Data.Selector);
                    node.Data.TagId    = HtmlAddons.GetId(node.Data.Selector);
                }
            }

            foreach (TreeNode <CssTreeItem> node in tn)
            {
                if (node.Parent != null)
                {
                    if (node.Data.Tag.Equals("|"))
                    {
                        node.Data.Tag          = "div";
                        node.Data.FullSelector = node.Data.FullSelector.Replace("|", "div");
                        node.Data.Selector     = node.Data.Selector.Replace("|", "");
                    }
                    if (node.Data.FullSelector.Contains("|"))
                    {
                        node.Data.FullSelector = node.Data.FullSelector.Replace("|", "div");
                        node.Data.Selector     = node.Data.Selector.Replace("|", "");
                    }
                }
            }
        }
Exemplo n.º 2
0
        private static void CreateTreeNodes(string[] tmpsels, string tmpmed, ref TreeNode <CssTreeItem> tn)
        {
            string tmpt = HtmlAddons.GetTag(tmpsels[0]);
            string tmps = tmpsels[0];

            if (String.IsNullOrEmpty(tmpt))
            {
                tmpt = "|";
                tmps = tmpt + tmps;
            }

            CssTreeItem            cti    = new CssTreeItem(tmps, tmpmed, tn.Data.FullSelector + ">" + tmps, tmpt);
            TreeNode <CssTreeItem> myfind = tn.FindTreeNode(node => node.Data != null && node.Data.FullSelector.Equals(cti.FullSelector));

            if (myfind == null)
            {
                tn.AddChild(cti);
            }

            string tmpiter = cti.FullSelector;

            for (int i = 1; i < tmpsels.Length; i++)
            {
                TreeNode <CssTreeItem> myfind2 = tn.FindTreeNode(node => node.Data != null && node.Data.FullSelector.Equals(tmpiter));
                tmpiter = tmpiter + ">" + tmpsels[i];
                TreeNode <CssTreeItem> myfind3 = myfind2.FindTreeNode(node => node.Data != null && node.Data.FullSelector.Equals(tmpiter));
                tmps = tmpsels[i];
                tmpt = HtmlAddons.GetTag(tmpsels[i]);

                if (String.IsNullOrEmpty(tmpt))
                {
                    tmpt = "|";
                    tmps = tmpt + tmps;
                }

                if (myfind3 == null)
                {
                    myfind2.AddChild(new CssTreeItem(tmps, tmpmed, tmpiter, tmpt));
                }
            }
        }