public static void SelectionSetContainment(Node<SelectionSetCheckNode> root, NW.ModelItemCollection currentSelection)
{
foreach (Node<SelectionSetCheckNode> savedItem in root.Children)
{
var node = savedItem.Value.SavedItem;
if (node is NW.SelectionSet selectionSet)
{
var selectionSetItems = selectionSet.GetSelectedItems();
if (currentSelection.IsContentsIntersected(selectionSetItems))
savedItem.Value.State = currentSelection.IsSelected(selectionSetItems) ? CheckState.Equals : CheckState.Contains;
}
else if (node is NW.FolderItem)
SelectionSetContainment(savedItem, currentSelection);
}
}
我有一个Node
类,其中包含SelectionSetCheckNode
个对象。上面粘贴的代码显示了如何遍历我的节点并在叶节点上设置枚举值。
我现在想要的是再次遍历我的树,并根据它的子节点在父节点上设置值。
类似的东西:
false
/ | \
true true false
/ \
true true
我将使用我的枚举整数值来通过添加int值并与子计数进行比较来推断父节点上的状态(None,Equals或Contains)。我会感激任何帮助和提前感谢。