Exemplo n.º 1
0
        protected override Size MeasureOverride(Size availableSize)
        {
            if (Children.Count == 0)
            {
                return(new Size(100, 20));
            }

            Size     szFinal = new Size(0, 0);
            string   strRoot = Root;
            TreeNode tnRoot  = this.FindName(strRoot) as TreeNode;

            foreach (UIElement uiel in InternalChildren)
            {
                uiel.Measure(availableSize);
                Size szThis = uiel.DesiredSize;

                if (szThis.Width > szFinal.Width || szThis.Height > szFinal.Height)
                {
                    szFinal = new Size(
                        Math.Max(szThis.Width, szFinal.Width),
                        Math.Max(szThis.Height, szFinal.Height));
                }
            }

            if (tnRoot != null)
            {
                SetParents(tnRoot);
                _ltd = new LayeredTreeDraw(tnRoot, HorizontalBuffer, HorizontalBufferSubtree, VerticalBuffer, VerticalJustification.top);
                _ltd.LayoutTree();
                szFinal = new Size(_ltd.PxOverallWidth, _ltd.PxOverallHeight);
            }

            return(szFinal);
        }
Exemplo n.º 2
0
        public static void CollapsePropertyChange(DependencyObject o, DependencyPropertyChangedEventArgs e)
        {
            TreeNode tn = o as TreeNode;

            if (tn != null && tn.Collapsible)
            {
                bool fCollapsed = ((bool)e.NewValue);
                foreach (TreeNode tnCur in LayeredTreeDraw.VisibleDescendants <TreeNode>(tn))
                {
                    tnCur.Visibility = fCollapsed ? Visibility.Hidden : Visibility.Visible;
                }
            }
        }