Esempio 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;
            TreeCanvasNode tnRoot  = this.FindName(strRoot) as TreeCanvasNode;

            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);
        }
Esempio n. 2
0
        public static TreeCanvasNode GetParentElement(TreeCanvasNode tn)
        {
            TreeCanvas     tc;
            TreeCanvasNode tnParent;

            if (tn == null)
            {
                return(null);
            }
            tc = tn.Parent as TreeCanvas;
            if (tc == null)
            {
                return(null);
            }
            string strParent = tn.TreeParent;

            if (strParent == null)
            {
                return(null);
            }

            tnParent = tc.FindName(strParent) as TreeCanvasNode;
            if (tnParent == null)
            {
                return(null);
            }
            return(tnParent);
        }
Esempio n. 3
0
        static public void CollapsiblePropertyChange(DependencyObject o, DependencyPropertyChangedEventArgs e)
        {
            TreeCanvasNode tn = o as TreeCanvasNode;

            if (((bool)e.NewValue) == false && tn != null)
            {
                tn.Collapsed = false;
            }
        }
Esempio n. 4
0
        public TreeCanvasNode AddNode(Object objContent, string strName, string strParent)
        {
            TreeCanvasNode tnNew = new TreeCanvasNode();

            SetName(tnNew, strName);
            tnNew.Content    = objContent;
            tnNew.TreeParent = strParent;
            Children.Add(tnNew);
            return(tnNew);
        }
Esempio n. 5
0
        public TreeCanvasNode AddRoot(Object objContent, string strName)
        {
            TreeCanvasNode tnNew = new TreeCanvasNode();

            SetName(tnNew, strName);
            tnNew.Content = objContent;
            Children.Add(tnNew);
            Root = strName;
            return(tnNew);
        }
Esempio n. 6
0
        private static object CollapsePropertyCoerce(DependencyObject d, object value)
        {
            TreeCanvasNode tn         = (TreeCanvasNode)d;
            bool           fCollapsed = (bool)value;

            if (!tn.Collapsible)
            {
                fCollapsed = false;
            }
            return(fCollapsed);
        }
Esempio n. 7
0
        internal bool SetParent()
        {
            TreeCanvasNode tn = GetParentElement(this);

            if (tn == null)
            {
                return(false);
            }
            tn.TreeChildren.Add(this);
            return(true);
        }
Esempio n. 8
0
        private void OnContextCreated(ProcessProxy context)
        {
            if (context.Parent == null)
            {
                Dictionary[context.Guid] = CreateNode(null, context);
                return;
            }
            //else
            TreeCanvasNode parentNode = Dictionary[context.Parent.Guid];

            Dictionary[context.Guid] = CreateNode(parentNode, context);
        }
Esempio n. 9
0
        static public void CollapsePropertyChange(DependencyObject o, DependencyPropertyChangedEventArgs e)
        {
            TreeCanvasNode tn = o as TreeCanvasNode;

            if (tn != null && tn.Collapsible)
            {
                bool fCollapsed = ((bool)e.NewValue);
                foreach (TreeCanvasNode tnCur in LayeredTreeDraw.VisibleDescendants <TreeCanvasNode>(tn))
                {
                    tnCur.Visibility = fCollapsed ? Visibility.Hidden : Visibility.Visible;
                }
            }
        }
Esempio n. 10
0
        protected override Size ArrangeOverride(Size finalSize)
        {
            foreach (UIElement uiel in InternalChildren)
            {
                TreeCanvasNode tn         = uiel as TreeCanvasNode;
                Point          ptLocation = new Point(0, 0);
                if (tn != null)
                {
                    ptLocation = new Point(_ltd.X(tn), _ltd.Y(tn));
                }
                uiel.Arrange(new Rect(ptLocation, uiel.DesiredSize));
            }

            return(finalSize);
        }
Esempio n. 11
0
        private void SetParents(TreeCanvasNode tnRoot)
        {
            // First pass to clear all parents
            foreach (UIElement uiel in InternalChildren)
            {
                TreeCanvasNode tn = uiel as TreeCanvasNode;
                if (tn != null)
                {
                    tn.ClearParent();
                }
            }

            // Second pass to properly set them from their children...
            foreach (UIElement uiel in InternalChildren)
            {
                TreeCanvasNode tn = uiel as TreeCanvasNode;
                if (tn != null && tn != tnRoot)
                {
                    tn.SetParent();
                }
            }
        }
Esempio n. 12
0
        public TreeCanvasNode CreateNode(TreeCanvasNode parent, ProcessProxy context)
        {
            if (context == null)
            {
                return(null);
            }
            //else
            System.Windows.Controls.Button control = new System.Windows.Controls.Button();
            control.Content = context.Label;
            control.Click  += (s, e) => InspectContext(context);
            //
            TreeCanvasNode canvasNode;

            if (parent == null)
            {
                canvasNode = Canvas.AddRoot(control);
            }
            else
            {
                canvasNode = Canvas.AddNode(control, parent);
            }
            return(canvasNode);
        }
Esempio n. 13
0
 public TreeCanvasNode AddNode(Object objContent, TreeCanvasNode tnParent)
 {
     return(AddNode(objContent, StrNextName(), tnParent.Name));
 }
Esempio n. 14
0
 public TreeCanvasNode AddNode(Object objContent, string strName, TreeCanvasNode tnParent)
 {
     return(AddNode(objContent, strName, tnParent.Name));
 }
Esempio n. 15
0
 private void SetName(TreeCanvasNode tn, string strName)
 {
     tn.Name = strName;
     RegisterName(strName, tn);
 }