Ejemplo n.º 1
0
        internal void OnNodeChanged(object sender, NodeEventArgsType e, object oParam)
        {
            object       obj2     = oParam;
            Node         r        = (Node)sender;
            NodeTemplate template = this.GetTemplate(r);

            switch (e)
            {
            case NodeEventArgsType.Selection:
                if (!((bool)oParam))
                {
                    this.SetSelected(null);
                    return;
                }
                this.SetSelected(r);
                return;

            case NodeEventArgsType.TemplateIndex:
            {
                int          offset    = 0;
                NodeTemplate template2 = this.GetTemplate(r, (int)oParam);
                offset -= template2.GetHeight(r);
                r.ResetCachedBounds(null);
                offset += template.GetHeight(r);
                this.OnChanged(base.List.IndexOf(r), new TreeResizeEventArgs(offset));
                return;
            }

            case NodeEventArgsType.BeforeExpand:
                this.OnChanged(this, new TreeChangedEventArgs(TreeEventArgsType.BeforeExpand, oParam));
                return;

            case NodeEventArgsType.AfterExpand:
                this.OnChanged(this, new TreeRefreshEventArgs(true));
                this.OnChanged(this, new TreeChangedEventArgs(TreeEventArgsType.AfterExpand, oParam));
                return;

            case NodeEventArgsType.BeforeCollapse:
                this.OnChanged(this, new TreeChangedEventArgs(TreeEventArgsType.BeforeCollapse, oParam));
                return;

            case NodeEventArgsType.AfterCollapse:
                this.OnChanged(this, new TreeRefreshEventArgs(true));
                this.OnChanged(this, new TreeChangedEventArgs(TreeEventArgsType.AfterCollapse, oParam));
                return;
            }
            if ((template != null) && template.AutoHeight)
            {
                int actualHeight = r.ActualHeight;
                r.ResetCachedBounds(null);
                int height = template.GetHeight(r);
                if (height != actualHeight)
                {
                    this.OnChanged(base.List.IndexOf(r), new TreeResizeEventArgs(height - actualHeight));
                    return;
                }
            }
            this.OnChanged(base.List.IndexOf(sender), new TreeChangedEventArgs(TreeEventArgsType.NodeChange, obj2));
        }
Ejemplo n.º 2
0
        internal int Draw(Graphics gr, TemplateSet ts, int width, int ymax, int ymin, int iNode, int iNodeOffset, ref bool resetScrollbar)
        {
            int yOffset = iNodeOffset;
            int count   = base.List.Count;

            this.LastDrawnNodeOffset = yOffset;
            this.LastDrawnNode       = iNode;
            while (this.LastDrawnNode < count)
            {
                Node node = null;
                if ((this.LastDrawnNode >= 0) && (this.LastDrawnNode < base.InnerList.Count))
                {
                    node = base.InnerList[this.LastDrawnNode] as Node;
                }
                if (node != null)
                {
                    NodeTemplate template = node.GetTemplate(ts);
                    int          height   = 0;
                    int          num4     = -1;
                    int          xOffset  = node.Level * this.m_AdvancedTree.NodeIndent;
                    if (template.CustomizeCells(node))
                    {
                        num4 = template.GetHeight(node);
                        node.ResetCachedBounds(null);
                    }
                    height = template.GetHeight(node);
                    if ((num4 >= 0) && (height != num4))
                    {
                        resetScrollbar = true;
                    }
                    if ((yOffset + height) >= ymin)
                    {
                        template.Draw(gr, xOffset, yOffset, node, width, -1);
                    }
                    this.LastDrawnNodeOffset = yOffset;
                    yOffset += height;
                    if (this.AdvancedTree.GridLines)
                    {
                        if (yOffset >= 0)
                        {
                            gr.DrawLine(this.m_AdvancedTree.m_penBorder, 0, yOffset, this.AdvancedTree.Width, yOffset);
                        }
                        yOffset++;
                    }
                    if (node.IsExpanded)
                    {
                        yOffset = node.Nodes.Draw(gr, ts, width, ymax, ymin, 0, yOffset, ref resetScrollbar);
                    }
                    if (yOffset > ymax)
                    {
                        return(yOffset);
                    }
                }
                this.LastDrawnNode++;
            }
            this.LastDrawnNodeOffset = yOffset;
            return(yOffset);
        }
Ejemplo n.º 3
0
        internal int GetHeight(int i, TemplateSet ts, bool subNodes)
        {
            if ((i < 0) || (i >= base.List.Count))
            {
                return(0);
            }
            Node         node     = (Node)base.InnerList[i];
            NodeTemplate template = ts[node.CurrentTemplateIndex];

            if (template == null)
            {
                return(0);
            }
            int height = template.GetHeight(node);

            if (subNodes && node.IsExpanded)
            {
                height += node.Nodes.CalculateNodesHeight();
            }
            if (this.AdvancedTree.GridLines)
            {
                return(height + 1);
            }
            return(height);
        }
Ejemplo n.º 4
0
        internal int CalculateNodesHeight()
        {
            int num = 0;

            foreach (Node node in base.List)
            {
                NodeTemplate template = this.GetTemplate(node);
                if (this.AdvancedTree.GridLines)
                {
                    num += template.GetHeight(node) + 1;
                }
                else
                {
                    num += template.GetHeight(node);
                }
                if (node.IsExpanded)
                {
                    num += node.Nodes.CalculateNodesHeight();
                }
            }
            return(num);
        }
Ejemplo n.º 5
0
        internal Point GetNodeClick(int iNode, int iNodeOffset, int pos_x, int pos_y, out int yOffset, out int yOut, out Node node)
        {
            int num  = 0;
            int num2 = iNodeOffset;

            yOffset = 0;
            yOut    = num2;
            node    = null;
            if (num2 <= pos_y)
            {
                for (int i = iNode; i < base.List.Count; i++)
                {
                    Node         r        = (Node)base.InnerList[i];
                    NodeTemplate template = this.GetTemplate(r);
                    int          height   = template.GetHeight(r);
                    if (this.AdvancedTree.GridLines)
                    {
                        num2 += height + 1;
                    }
                    else
                    {
                        num2 += height;
                    }
                    if (num2 > pos_y)
                    {
                        bool flag = (this.AdvancedTree != null) && this.AdvancedTree.RightToLeft;
                        yOffset = num2 - (this.AdvancedTree.GridLines ? (height + 1) : height);
                        num     = (r.Level * this.AdvancedTree.NodeIndent) + (this.AdvancedTree.ShowPlusMinus ? this.AdvancedTree.PlusMinusSize.Width : 0);
                        if (flag)
                        {
                            num *= -1;
                        }
                        int y = template.GetCellClick(pos_x - num, pos_y - yOffset, r);
                        node = r;
                        return(new Point(i, y));
                    }
                    if (r.IsExpanded)
                    {
                        Point point = r.Nodes.GetNodeClick(0, num2, pos_x, pos_y, out yOffset, out num2, out node);
                        if ((point.X != -1) || (point.Y != -1))
                        {
                            return(point);
                        }
                    }
                    yOut = num2;
                }
            }
            return(new Point(-1, -1));
        }