本文整理汇总了C#中ITreeNode.ChildNodes方法的典型用法代码示例。如果您正苦于以下问题:C# ITreeNode.ChildNodes方法的具体用法?C# ITreeNode.ChildNodes怎么用?C# ITreeNode.ChildNodes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITreeNode
的用法示例。
在下文中一共展示了ITreeNode.ChildNodes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TargetTreeNodes
private Size TargetTreeNodes(Point location,
ITreeNode node,
MetaElementStateDict stateDict,
bool downwards)
{
Size totalSize = Utility.SizeZero;
UIElement element = node as UIElement;
if ((element != null) && (stateDict.ContainsKey(element)))
{
// Do not measure children of items being removed
if (stateDict[element].Status != MetaElementStatus.Removing)
{
// Starting size covers only the node
totalSize = element.DesiredSize;
// Process each sub tree
Point childLocation = new Point(location.X + element.DesiredSize.Width, location.Y);
Size childTotalSize = Utility.SizeZero;
foreach (ITreeNode child in node.ChildNodes())
{
Size childSize = TargetTreeNodes(childLocation, child, stateDict, downwards);
// Stack all the sub trees vertically in sizing
childTotalSize.Width = Math.Max(childTotalSize.Width, childSize.Width);
childTotalSize.Height += childSize.Height;
childLocation.Y += childSize.Height;
}
// Place the set of sub trees to the right of this node
totalSize.Width += childTotalSize.Width;
totalSize.Height = Math.Max(totalSize.Height, childTotalSize.Height);
}
// Position the node vertically centered
Rect newTargetRect = new Rect(location.X,
location.Y + (totalSize.Height - element.DesiredSize.Height) / 2,
element.DesiredSize.Width,
element.DesiredSize.Height);
// Store the new target rectangle
if (!stateDict[element].TargetRect.Equals(newTargetRect))
{
stateDict[element].TargetChanged = true;
stateDict[element].TargetRect = newTargetRect;
}
}
return totalSize;
}
示例2: MeasureTreeNodes
private Size MeasureTreeNodes(ITreeNode node,
MetaElementStateDict stateDict,
bool downwards)
{
Size totalSize = Utility.SizeZero;
UIElement element = node as UIElement;
if ((element != null) && (stateDict.ContainsKey(element)))
{
// Use element size as the starting total size
element.Measure(Utility.SizeInfinity);
// Do not measure children of items being removed
if (stateDict[element].Status != MetaElementStatus.Removing)
{
// Starting size covers only the node
totalSize = element.DesiredSize;
// Process each sub tree
Size childTotalSize = Utility.SizeZero;
foreach (ITreeNode child in node.ChildNodes())
{
Size childSize = MeasureTreeNodes(child, stateDict, downwards);
// Stack all the sub trees vertically in sizing
childTotalSize.Width = Math.Max(childTotalSize.Width, childSize.Width);
childTotalSize.Height += childSize.Height;
}
// Place the set of sub trees to the right of this node
totalSize.Width += childTotalSize.Width;
totalSize.Height = Math.Max(totalSize.Height, childTotalSize.Height);
}
}
return totalSize;
}