当前位置: 首页>>代码示例>>C#>>正文


C# ITreeNode.ChildNodes方法代码示例

本文整理汇总了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;
        }
开发者ID:ComponentFactory,项目名称:Quicksilver,代码行数:50,代码来源:TreeLayout.cs

示例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;
        }
开发者ID:ComponentFactory,项目名称:Quicksilver,代码行数:37,代码来源:TreeLayout.cs


注:本文中的ITreeNode.ChildNodes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。