示例#1
0
        /// <summary>
        /// Convert nodes tree to list.
        /// </summary>
        /// <returns>The list.</returns>
        /// <param name="sourceNodes">Source nodes.</param>
        /// <param name="depth">Depth.</param>
        /// <param name="list">List.</param>
        protected virtual int Nodes2List(IObservableList <TreeNode <TItem> > sourceNodes, int depth, ObservableList <ListNode <TItem> > list)
        {
            var added_nodes = 0;

            foreach (var node in sourceNodes)
            {
                if (!node.IsVisible)
                {
                    continue;
                }
                list.Add(new ListNode <TItem>(node, depth));
                if ((node.IsExpanded) && (node.Nodes != null) && (node.Nodes.Count > 0))
                {
                    var used = Nodes2List(node.Nodes, depth + 1, list);
                    node.UsedNodesCount = used;
                }
                else
                {
                    node.UsedNodesCount = 0;
                }
                added_nodes += 1;
            }
            return(added_nodes);
        }