Exemple #1
0
        /// <summary>
        /// Clear selection recursively for inner nodes.
        /// </summary>
        /// <param name="blocks">The blocks collection</param>
        /// <param name="parentBr">The parent block reference</param>
        public static void CleanCurrentNodes(BlockKeyedCollection blocks, BlockReference parentBr)
        {
            Block toClean;

            if (blocks.TryGetValue(parentBr.BlockName, out toClean))
            {
                for (int i = 0; i < toClean.Entities.Count; i++)
                {
                    if (toClean.Entities[i] is BlockReference)
                    {
                        toClean.Entities[i].Selected = false;
                        CleanCurrentNodes(blocks, (BlockReference)toClean.Entities[i]);
                    }
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Recursive function to populate the tree.
        /// </summary>
        /// <param name="tv">The treeView control</param>
        /// <param name="entList">The entity list</param>
        /// <param name="blocks">The block collection</param>
        /// <param name="parentNode">The parent node. Can be null for root level nodes.</param>
        public static void PopulateTree(TreeView tv, List <Entity> entList, BlockKeyedCollection blocks, TreeNode parentNode = null)
        {
            ItemCollection nodes;

            if (parentNode == null)
            {
                tv.Items.Clear();
                nodes = tv.Items;
            }
            else
            {
                nodes = parentNode.Items;
            }

            for (int i = 0; i < entList.Count; i++)
            {
                Entity ent = entList[i];
                if (ent is BlockReference)
                {
                    Block  child;
                    string blockName = ((BlockReference)ent).BlockName;

                    if (blocks.TryGetValue(blockName, out child))
                    {
                        TreeNode parentTn = new TreeNode(parentNode, GetNodeName(blockName, i), false);
                        parentTn.Tag = ent;

                        nodes.Add(parentTn);
                        PopulateTree(tv, child.Entities, blocks, parentTn);
                    }
                }
                else
                {
                    string type = ent.GetType().ToString().Split('.').LastOrDefault();
                    var    node = new TreeNode(parentNode, GetNodeName(type, i), true);
                    node.Tag = ent;
                    nodes.Add(node);
                }
            }
        }