コード例 #1
0
 /// <summary>
 /// 遍历某节点下的所有节点
 /// </summary>
 /// <param name="node"></param>
 /// <param name="action"></param>
 public static void traveseNode(PropertyNodeItem node, Action <PropertyNodeItem> action)
 {
     foreach (PropertyNodeItem child in node.Children)
     {
         traveseNode(child, action);
     }
     action(node);
 }
コード例 #2
0
 //子节点构造函数
 public PropertyNodeItem(String name, String displayName, Layer layer, PropertyNodeItem parent)
 {
     Children         = new List <PropertyNodeItem>();
     this.nodeType    = NodeType.LeafNode;
     this.Name        = name;
     this.DisplayName = displayName;
     this.layer       = layer;
     this.parent      = parent;
     this.level       = this.parent.level + 1;
     isChecked        = true;
 }
コード例 #3
0
        /// <summary>
        /// 寻找某个节点
        /// </summary>
        /// <param name="roots"></param>
        /// <param name="predicate"></param>
        /// <returns></returns>
        public static PropertyNodeItem findNode(List <PropertyNodeItem> roots, Predicate <PropertyNodeItem> predicate)
        {
            PropertyNodeItem result = null;

            foreach (PropertyNodeItem root in roots)
            {
                result = findNode(root, predicate);
                if (result != null)
                {
                    break;
                }
            }
            return(result);
        }
コード例 #4
0
 /// <summary>
 /// 寻找某个节点
 /// </summary>
 /// <param name="root"></param>
 /// <param name="predicate"></param>
 /// <returns></returns>
 public static PropertyNodeItem findNode(PropertyNodeItem root, Predicate <PropertyNodeItem> predicate)
 {
     foreach (PropertyNodeItem child in root.Children)
     {
         if (predicate(child))
         {
             return(child);
         }
         else
         {
             findNode(child, predicate);
         }
     }
     return(null);
 }