Esempio n. 1
0
        // tree DOM handling
        private static void AddElement(SciterElement tree_el_parent, SciterElement origin_el_add)
        {
            SciterNode origin_nd = origin_el_add.ToNode();

            Debug.Assert(origin_nd.IsElement);

            string        tag         = origin_el_add.Tag;
            SciterElement tree_el_new = SciterElement.Create("option");

            tree_el_parent.Append(tree_el_new);
            uint uid = origin_el_add.UID; Debug.Assert(uid != 0);

            tree_el_new.SetAttribute("value", uid.ToString());
            tree_el_new.SetHTML(UI_ElementCaption(origin_el_add));


            bool has_real_childs = false;
            uint nchilds         = origin_nd.ChildrenCount;

            for (uint i = 0; i < nchilds; i++)
            {
                SciterNode nd = origin_nd[i];
                if (nd.IsElement)
                {
                    AddElement(tree_el_new, nd.ToElement());
                    has_real_childs = true;
                }
                else
                {
                    bool new_option = AddNode(tree_el_new, uid, nd);
                    if (new_option)
                    {
                        has_real_childs = true;
                    }
                }
            }

            if (has_real_childs)
            {
                if (tag == "html" || tag == "body")
                {
                    tree_el_new.SetState(SciterXDom.ELEMENT_STATE_BITS.STATE_EXPANDED);                    //tree_el_new.set_attribute("expanded", "");
                }
                else
                {
                    tree_el_new.SetState(SciterXDom.ELEMENT_STATE_BITS.STATE_COLLAPSED);
                }
            }
        }
Esempio n. 2
0
        public static void CountElements()
        {
            g_dom_count_elem = 0;
            g_dom_count_node = 0;

            Action <SciterNode> f_VisitNode = (SciterNode origin_nd) =>
            {
                g_dom_count_node++;
                Debug.Assert(origin_nd.ChildrenCount == 0);
            };

            Action <SciterElement> f_VisitElement = null;

            f_VisitElement = (SciterElement origin_el) =>
            {
                g_dom_count_elem++;

                SciterNode origin_nd = origin_el.ToNode();
                uint       nchilds   = origin_nd.ChildrenCount;
                for (uint i = 0; i < nchilds; i++)
                {
                    SciterNode nd = origin_nd[i];
                    if (nd.IsElement)
                    {
                        f_VisitElement(nd.ToElement());
                    }
                    else
                    {
                        f_VisitNode(nd);
                    }
                }
            };

            SciterElement origin_el_root = State.g_el_frameroot[0];

            //debug assert(origin_el_root);
            if (origin_el_root != null)
            {
                f_VisitElement(origin_el_root);
            }
        }
Esempio n. 3
0
 public static bool TryGetChild(this SciterNode sciterNode, int index, out SciterNode value)
 {
     value = default;
     return(sciterNode?.TryGetChildInternal(index: index, value: out value) == true);
 }
Esempio n. 4
0
 public static SciterNode GetChild(this SciterNode sciterNode, int index)
 {
     return(sciterNode?.GetChildInternal(index: index));
 }
Esempio n. 5
0
 public static bool TryCastToElement(this SciterNode sciterNode, out SciterElement value)
 {
     value = default;
     return(sciterNode?.TryCastToElementInternal(value: out value) == true);
 }
Esempio n. 6
0
 public static SciterElement CastToElement(this SciterNode sciterNode)
 {
     return(sciterNode?.CastToElementInternal());
 }
Esempio n. 7
0
 public static bool TryGetChildCount(this SciterNode sciterNode, out int value)
 {
     return(sciterNode.TryGetChildCountInternal(out value));
 }
Esempio n. 8
0
 public static int GetChildCount(this SciterNode sciterNode)
 {
     return(sciterNode.GetChildCountInternal());
 }
Esempio n. 9
0
 public static string GetText(this SciterNode sciterNode)
 {
     return(sciterNode?.GetTextInternal());
 }
Esempio n. 10
0
 public static bool TryCreateCommentNode(this SciterNode sciterNode, string text, out SciterNode value)
 {
     value = default;
     return(sciterNode?.TryCreateCommentNodeInternal(text: text, value: out value) == true);
 }
Esempio n. 11
0
 public static SciterNode CreateCommentNode(this SciterNode sciterNode, string text)
 {
     return(sciterNode?.CreateCommentNodeInternal(text: text));
 }
Esempio n. 12
0
 public static bool TrySetText(this SciterNode sciterNode, string text)
 {
     return(sciterNode?.TrySetTextInternal(text: text) == true);
 }
Esempio n. 13
0
 public static SciterNode SetText(this SciterNode sciterNode, string text)
 {
     sciterNode?.SetTextInternal(text: text);
     return(sciterNode);
 }
Esempio n. 14
0
 public static bool TryGetText(this SciterNode sciterNode, out string text)
 {
     text = default;
     return(sciterNode?.TryGetTextInternal(text: out text) == true);
 }
Esempio n. 15
0
        private static bool AddNode(SciterElement tree_el_parent, uint origin_parent_uid, SciterNode origin_nd)
        {
            Debug.Assert(origin_nd.ChildrenCount == 0);

            if (origin_nd.IsComment)
            {
                return(false);
            }

            if (string.IsNullOrWhiteSpace(origin_nd.Text))
            {
                return(false);
            }

            SciterElement tree_el_new = SciterElement.Create("option");

            tree_el_parent.Append(tree_el_new);
            tree_el_new.SetAttribute("value", origin_parent_uid.ToString());            // UID
            tree_el_new.Text = origin_nd.Text;
            return(true);
        }