Exemplo n.º 1
0
        public virtual int GetAutoHeight(Node n, int index, NodeSpecificCellProperties preNscp)
        {
            NodeSpecificCellProperties properties = (preNscp == null) ? this.GetNodeSpecificProperties(n) : preNscp;

            properties.CachedAutoHeight = this.m_Bounds.Height;
            return(properties.CachedAutoHeight);
        }
Exemplo n.º 2
0
        internal bool CustomizeCells(Node node)
        {
            bool flag = false;

            if (!this.HasCustomizedCells || (this.Parent == null))
            {
                return(false);
            }
            int count = this.m_CellTemplates.Count;

            for (int i = 0; i < count; i++)
            {
                Cell cell = this.m_CellTemplates[i];
                if (cell.CustomizeCell)
                {
                    object data = cell[node, i];
                    CustomizeCellEventArgs e = new CustomizeCellEventArgs(cell, data, node);
                    this.OnCustomizeCell(e);
                    NodeSpecificCellProperties nodeSpecificProperties = cell.GetNodeSpecificProperties(node);
                    bool flag2 = nodeSpecificProperties.Visible.HasValue ? nodeSpecificProperties.Visible.Value : cell.Visible;
                    nodeSpecificProperties.Visible          = new bool?(e.Cell.Visible);
                    nodeSpecificProperties.CachedAutoHeight = e.Cell.GetAutoHeight(e.Node, i, nodeSpecificProperties);
                    nodeSpecificProperties.Cea = e;
                    if (e.Cell.Visible != flag2)
                    {
                        flag = true;
                    }
                }
            }
            return(flag);
        }
Exemplo n.º 3
0
        public bool IsVisible(Node node)
        {
            NodeSpecificCellProperties nodeSpecificProperties = this.GetNodeSpecificProperties(node);

            if (!nodeSpecificProperties.Visible.HasValue)
            {
                return(this.Visible);
            }
            return(nodeSpecificProperties.Visible.Value);
        }
Exemplo n.º 4
0
        internal int GetCellClick(int pos_x, int pos_y, Node node)
        {
            int num = this.m_CellTemplates.Count - 1;

            while (num >= 0)
            {
                NodeSpecificCellProperties nodeSpecificProperties = this.m_CellTemplates[num].GetNodeSpecificProperties(node);
                if ((nodeSpecificProperties.Visible.Value && nodeSpecificProperties.CachedBounds.HasValue) && nodeSpecificProperties.CachedBounds.Value.Contains(pos_x, pos_y))
                {
                    return(num);
                }
                num--;
            }
            return(num);
        }
Exemplo n.º 5
0
        internal NodeSpecificCellProperties GetNodeSpecificProperties(Node node)
        {
            NodeSpecificCellProperties properties = null;

            if (node != null)
            {
                properties = (NodeSpecificCellProperties)node.NodeSpecificCellProperties[this];
                if (properties == null)
                {
                    properties = new NodeSpecificCellProperties(this);
                    node.NodeSpecificCellProperties[this] = properties;
                }
            }
            return(properties);
        }
Exemplo n.º 6
0
        public override int GetAutoHeight(Node n, int index, NodeSpecificCellProperties preNscp)
        {
            int num = 0;

            if (!base.AutoHeight)
            {
                return(base.Bounds.Height);
            }
            NodeSpecificCellProperties properties = (preNscp == null) ? base.GetNodeSpecificProperties(n) : preNscp;

            if (properties.CachedAutoHeight >= 0)
            {
                return(properties.CachedAutoHeight);
            }
            string text = this.GetText(base[n, index]);

            if (((text == null) || (text.Length == 0)) || !properties.Visible.Value)
            {
                return(0);
            }
            int gridWidth = 0;

            Resco.Controls.AdvancedTree.AdvancedTree parent = base.Parent;
            if (parent != null)
            {
                gridWidth = parent.Width - ((n.Level * parent.NodeIndent) + parent.PlusMinusSize.Width);
                if (parent.ScrollbarVisible)
                {
                    gridWidth -= parent.ScrollbarWidth;
                }
            }
            if (gridWidth != 0)
            {
                Rectangle rectangle = base.CalculateCellWidth(gridWidth);
                rectangle.Width -= 3;
                if (rectangle.Width > base.Parent.ScrollbarWidth)
                {
                    WrapTextData data = Utility.WrapText(base.Graphics, text, this.m_Font, rectangle.Width);
                    num = (data != null) ? (data.Height + 2) : 0;
                }
            }
            properties.CachedAutoHeight = num;
            return(num);
        }
Exemplo n.º 7
0
 public override int GetAutoHeight(Node n, int index, NodeSpecificCellProperties preNscp)
 {
     int num = 0;
     if (!base.AutoHeight)
     {
         return base.Bounds.Height;
     }
     NodeSpecificCellProperties properties = (preNscp == null) ? base.GetNodeSpecificProperties(n) : preNscp;
     if (properties.CachedAutoHeight >= 0)
     {
         return properties.CachedAutoHeight;
     }
     string text = this.GetText(base[n, index]);
     if (((text == null) || (text.Length == 0)) || !properties.Visible.Value)
     {
         return 0;
     }
     int gridWidth = 0;
     Resco.Controls.AdvancedTree.AdvancedTree parent = base.Parent;
     if (parent != null)
     {
         gridWidth = parent.Width - ((n.Level * parent.NodeIndent) + parent.PlusMinusSize.Width);
         if (parent.ScrollbarVisible)
         {
             gridWidth -= parent.ScrollbarWidth;
         }
     }
     if (gridWidth != 0)
     {
         Rectangle rectangle = base.CalculateCellWidth(gridWidth);
         rectangle.Width -= 3;
         if (rectangle.Width > base.Parent.ScrollbarWidth)
         {
             WrapTextData data = Utility.WrapText(base.Graphics, text, this.m_Font, rectangle.Width);
             num = (data != null) ? (data.Height + 2) : 0;
         }
     }
     properties.CachedAutoHeight = num;
     return num;
 }
Exemplo n.º 8
0
        protected internal virtual void Draw(Graphics gr, int xOffset, int yOffset, Node node, int width, int height)
        {
            bool  rightToLeft;
            int   num;
            Color colorKey;

            if (this.Parent != null)
            {
                rightToLeft = this.Parent.RightToLeft;
                num         = this.Parent.ScrollbarVisible ? this.Parent.ScrollbarWidth : 0;
            }
            else
            {
                rightToLeft = false;
                num         = 0;
            }
            this.CurrentNode = node;
            if (height == -1)
            {
                height = this.GetHeight(node);
            }
            if (this.m_BackColor == Color.Transparent)
            {
                if (this.Parent.UseGradient)
                {
                    colorKey = this.Parent.m_colorKey;
                }
                else
                {
                    colorKey = this.Parent.BackColor;
                }
            }
            else
            {
                colorKey = this.m_BackColor;
            }
            int x = !rightToLeft ? xOffset : ((width + num) - (xOffset + this.Parent.PlusMinusSize.Width));

            if (((this.Parent != null) && (!this.Parent.UseGradient || (this.Parent.GradientBackColor.FillDirection == FillDirection.Vertical))) && !this.m_useTemplateBackground)
            {
                Brush brush = Resco.Controls.AdvancedTree.AdvancedTree.GetBrush(colorKey);
                if (!rightToLeft)
                {
                    gr.FillRectangle(brush, 0, yOffset, xOffset + this.Parent.PlusMinusSize.Width, height);
                }
                else
                {
                    gr.FillRectangle(brush, x, yOffset, xOffset + this.Parent.PlusMinusSize.Width, height);
                }
            }
            else if (this.m_useTemplateBackground)
            {
                this.DrawBackground(gr, 0, yOffset, width, height, colorKey);
            }
            if (((this.Parent != null) && this.Parent.ShowPlusMinus) && !node.HidePlusMinus)
            {
                int num3 = this.Parent.PlusMinusSize.Width - (2 * this.Parent.PlusMinusMargin.Width);
                int num4 = this.Parent.PlusMinusSize.Height - (2 * this.Parent.PlusMinusMargin.Height);
                int num5 = num3 / 2;
                int num6 = num4 / 2;
                gr.DrawRectangle(Resco.Controls.AdvancedTree.AdvancedTree.GetPen(Color.Gray), (int)(x + this.Parent.PlusMinusMargin.Width), (int)(this.Parent.PlusMinusMargin.Height + yOffset), (int)(num3 - 1), (int)(num4 - 1));
                int num7 = (this.Parent.PlusMinusMargin.Width + x) + num5;
                int num8 = (this.Parent.PlusMinusMargin.Height + yOffset) + num6;
                gr.DrawLine(Resco.Controls.AdvancedTree.AdvancedTree.GetPen(Color.Black), num7 - (num5 / 2), num8, num7 + (num5 / 2), num8);
                if (!node.IsExpanded)
                {
                    gr.DrawLine(Resco.Controls.AdvancedTree.AdvancedTree.GetPen(Color.Black), num7, num8 - (num6 / 2), num7, num8 + (num6 / 2));
                }
            }
            if ((this.Parent != null) && this.Parent.TreeNodeLines)
            {
                int  num9  = this.Parent.PlusMinusSize.Width - (2 * this.Parent.PlusMinusMargin.Width);
                int  num10 = this.Parent.PlusMinusSize.Height - (2 * this.Parent.PlusMinusMargin.Height);
                int  num11 = num9 / 2;
                int  num12 = num10 / 2;
                int  num13 = (this.Parent.PlusMinusMargin.Width + x) + num11;
                int  num14 = (this.Parent.PlusMinusMargin.Height + yOffset) + num12;
                bool flag2 = node.ParentCollection.IndexOf(node) == (node.ParentCollection.Count - 1);
                if (node.HidePlusMinus)
                {
                    gr.DrawLine(Resco.Controls.AdvancedTree.AdvancedTree.GetPen(Color.Gray), num13, num14, x + (this.Parent.PlusMinusSize.Width * (!rightToLeft ? 1 : -1)), num14);
                    gr.DrawLine(Resco.Controls.AdvancedTree.AdvancedTree.GetPen(Color.Gray), num13, yOffset, num13, flag2 ? num14 : (yOffset + this.Height));
                }
                else
                {
                    gr.DrawLine(Resco.Controls.AdvancedTree.AdvancedTree.GetPen(Color.Gray), x + (!rightToLeft ? (this.Parent.PlusMinusSize.Width - this.Parent.PlusMinusMargin.Width) : 0), num14, x + (!rightToLeft ? this.Parent.PlusMinusSize.Width : this.Parent.PlusMinusMargin.Width), num14);
                    gr.DrawLine(Resco.Controls.AdvancedTree.AdvancedTree.GetPen(Color.Gray), num13, yOffset, num13, yOffset + this.Parent.PlusMinusMargin.Height);
                    if (!flag2)
                    {
                        gr.DrawLine(Resco.Controls.AdvancedTree.AdvancedTree.GetPen(Color.Gray), num13, (yOffset + this.Parent.PlusMinusSize.Height) - this.Parent.PlusMinusMargin.Height, num13, yOffset + this.Height);
                    }
                }
                int num15 = x + ((!rightToLeft ? -1 : 1) * this.Parent.PlusMinusSize.Width);
                for (Node node2 = node.Parent; node2 != null; node2 = node2.Parent)
                {
                    if (node2.ParentCollection.IndexOf(node2) != (node2.ParentCollection.Count - 1))
                    {
                        num13 = (num15 + this.Parent.PlusMinusMargin.Width) + ((this.Parent.PlusMinusSize.Width - (2 * this.Parent.PlusMinusMargin.Width)) / 2);
                        gr.DrawLine(Resco.Controls.AdvancedTree.AdvancedTree.GetPen(Color.Gray), num13, yOffset, num13, yOffset + this.Height);
                    }
                    num15 += (!rightToLeft ? -1 : 1) * this.Parent.PlusMinusSize.Width;
                }
            }
            if (this.Parent != null)
            {
                xOffset += this.Parent.PlusMinusSize.Width;
            }
            x = !rightToLeft ? xOffset : (num - xOffset);
            if (!this.m_useTemplateBackground)
            {
                this.DrawBackground(gr, x, yOffset, width, height, colorKey);
            }
            int count = this.m_CellTemplates.Count;

            for (int i = 0; i < count; i++)
            {
                Cell cell = this.m_CellTemplates[i];
                NodeSpecificCellProperties nscp = null;
                object data = null;
                if (cell.CustomizeCell && (this.Parent != null))
                {
                    nscp = cell.GetNodeSpecificProperties(node);
                    if (nscp.Cea != null)
                    {
                        cell = nscp.Cea.Cell;
                        data = nscp.Cea.Data;
                    }
                }
                else
                {
                    data = cell[node, i];
                }
                if (cell is ButtonCell)
                {
                    ((ButtonCell)cell).Pressed = node.PressedButtonIndex == i;
                }
                if ((cell != null) && cell.Visible)
                {
                    cell.Draw(gr, xOffset, yOffset, width, data, nscp);
                }
                if (nscp != null)
                {
                    nscp.Cea = null;
                }
            }
        }
Exemplo n.º 9
0
        protected internal virtual Rectangle CalculateBounds(int xOffset, int yOffset, Node node, int gridWidth, NodeSpecificCellProperties preNscp)
        {
            Rectangle rectangle;
            NodeSpecificCellProperties nodeSpecificProperties = preNscp;

            if (nodeSpecificProperties == null)
            {
                nodeSpecificProperties = this.GetNodeSpecificProperties(node);
            }
            if ((node != null) && nodeSpecificProperties.CachedBounds.HasValue)
            {
                rectangle = nodeSpecificProperties.CachedBounds.Value;
            }
            else
            {
                int cachedAutoHeight = 0;
                if ((nodeSpecificProperties != null) && (nodeSpecificProperties.CachedAutoHeight >= 0))
                {
                    cachedAutoHeight = nodeSpecificProperties.CachedAutoHeight;
                }
                rectangle = this.CalculateCellWidth(gridWidth - xOffset);
                if (this.AutoHeight && (cachedAutoHeight > this.m_Bounds.Height))
                {
                    rectangle.Height = cachedAutoHeight;
                }
                if ((this.Anchor & AnchorStyles.Bottom) == AnchorStyles.Bottom)
                {
                    if ((this.Anchor & AnchorStyles.Top) == AnchorStyles.Top)
                    {
                        rectangle.Height = node.ActualHeight - (this.m_anchorSizeTop + this.m_anchorSizeBottom);
                        if (rectangle.Height < 0)
                        {
                            rectangle.Height = 0;
                        }
                    }
                    else
                    {
                        rectangle.Y = node.ActualHeight - (this.m_anchorSizeBottom + rectangle.Height);
                        if (rectangle.Y < 0)
                        {
                            rectangle.Y = 0;
                        }
                    }
                }
                else if (rectangle.Bottom > node.ActualHeight)
                {
                    rectangle.Height = node.ActualHeight - rectangle.Y;
                }
                if ((this.Parent != null) ? this.Parent.RightToLeft : false)
                {
                    rectangle.X = this.Parent.Width - rectangle.Right;
                    xOffset    *= -1;
                }
                if (nodeSpecificProperties != null)
                {
                    nodeSpecificProperties.CachedBounds = new Rectangle?(rectangle);
                }
            }
            rectangle.Offset(xOffset, yOffset);
            return(rectangle);
        }
Exemplo n.º 10
0
        protected internal virtual void Draw(System.Drawing.Graphics gr, int xOffset, int yOffset, int gridWidth, object data, NodeSpecificCellProperties nscp)
        {
            this.CurrentData = data;
            Rectangle drawbounds = this.CalculateBounds(xOffset, yOffset, this.Owner.CurrentNode, gridWidth, nscp);

            if (this.m_bVisible)
            {
                this.DrawBackground(gr, drawbounds);
                this.DrawContent(gr, drawbounds, data);
                this.DrawBorder(gr, drawbounds);
            }
            this.CurrentData = null;
        }