示例#1
0
        private List <string> GetBindingSourceList(Hugula.Databinding.BindableObject bindableObject)
        {
            var list     = new List <string>();
            var bindings = bindableObject.GetBindings();


            foreach (var binding in bindings)
            {
                list.Add(BindingToString(binding));
            }

            return(list);
        }
示例#2
0
        private void BuildTree(Hugula.Databinding.BindableObject root, TreeNode treeNode)
        {
            var depth = treeNode.Depth() + 1;

            binderCount += root.GetBindings().Count;
            // 构建自身节点
            var rootNode = CreateNode(NodeType.Style1);

            rootNode.name   = string.Format("{0}({1})", root.name, root.GetType().Name);
            rootNode.target = root;
            if (enableExtraInfo)
            {
                var sourceList = GetBindingSourceList(root);
                rootNode.ExtraInfo = CollectSourceInfo(sourceList);
            }
            rootNode.depth = depth - 1;
            treeNode.AddNode(rootNode);

            //父节点连接
            var parnet = treeNode.parent;

            if (parnet != null)
            {
                var parentRoot = parnet.nodeList[0];
                var connection = CreateConnection();
                connection.startNode = parentRoot;
                connection.endNode   = rootNode;
                AddConnection(connection, true);
            }

            //children
            if (root is ICollectionBinder)
            {
                var container = root as Hugula.Databinding.ICollectionBinder;
                var children  = container.GetChildren();
                foreach (var item in children)
                {
                    NodeGUI node = null;
                    if (item is ICollectionBinder)
                    {
                        var childTreeNode = new TreeNode();
                        treeNode.AddChild(childTreeNode);
                        BuildTree(item, childTreeNode);
                    }
                    else if (item != null)
                    {
                        binderCount += item.GetBindings().Count;
                        node         = CreateNode(NodeType.Style2);
                        if (enableExtraInfo)
                        {
                            var sourceList = GetBindingSourceList(item);
                            node.ExtraInfo = CollectSourceInfo(sourceList);
                        }

                        var connection = CreateConnection();
                        connection.startNode = rootNode;  //= FindNodeUp(treeNode, NodeType.Style1);
                        connection.endNode   = node;
                        AddConnection(connection, true);

                        node.name   = string.Format("{0}({1})", item.name, item.GetType().Name);
                        node.target = item;
                        node.depth  = depth;

                        treeNode.AddNode(node);
                    }
                }
            }
        }