Пример #1
0
        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
0
        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);
        }
Пример #3
0
        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;
        }
Пример #4
0
        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;
        }