示例#1
0
 /// <summary>
 /// Refresh tree control
 /// </summary>
 public void RefreshTree()
 {
     //Auto enable scroll for new content size
     _ltd = new LayeredTreeDraw(m_RootNode, 17.5, 17.5, 17.5, VerticalJustification.top);
     _ltd.LayoutTree();
     this.AutoScrollMinSize = new Size((int)_ltd.PxOverallWidth + this.Margin.Left + this.Margin.Right, (int)_ltd.PxOverallHeight + this.Margin.Top + this.Margin.Bottom);
     Invalidate();
 }
示例#2
0
        /// <summary>
        /// Prepare for Tree node draw.
        /// </summary>
        /// <param name="gpRoot"></param>
        /// <param name="funNodeValue">delegate for callbaack for retrieve GPNode string representation</param>
        public void DrawTreeExpression(GPNode gpRoot, NodeValue funNodeValue, NodeBackground funNodeBackground = null)
        {
            Clear();

            //define callbacks for
            _funNodeValueCallback      = funNodeValue;
            _funNodeBackgroundCallback = funNodeBackground;

            //Collection holds tree nodes
            Queue <GPNode>         dataTree = new Queue <GPNode>();
            Queue <TreeNodeDrawer> ctrls    = new Queue <TreeNodeDrawer>();

            //current node
            GPNode         node     = null;
            TreeNodeDrawer treeCtrl = null;

            treeCtrl = AddNode(gpRoot.value, gpRoot.marked, null);

            ctrls.Enqueue(treeCtrl);
            dataTree.Enqueue(gpRoot);

            while (dataTree.Count > 0)
            {
                //get next node
                node     = dataTree.Dequeue();
                treeCtrl = ctrls.Dequeue();

                if (node.children != null)
                {
                    for (int i = 0; i < node.children.Length; i++)
                    {
                        var tn = AddNode(node.children[i].value, node.children[i].marked, treeCtrl);
                        dataTree.Enqueue(node.children[i]);
                        ctrls.Enqueue(tn);
                    }
                }
            }

            _ltd = new LayeredTreeDraw(m_RootNode, 17.5, 17.5, 17.5, VerticalJustification.top);
            _ltd.LayoutTree();

            //Auto enable scroll for new content size
            this.AutoScrollMinSize = new Size((int)_ltd.PxOverallWidth + this.Margin.Left + this.Margin.Right, (int)_ltd.PxOverallHeight + this.Margin.Top + this.Margin.Bottom);
            Invalidate();
        }