コード例 #1
0
 public CollapsedEventArgs(TreeGridNode node) : base(node)
 {
 }
コード例 #2
0
        protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
        {
            TreeGridNode owningNode = this.OwningNode;

            if (owningNode != null)
            {
                Image image = owningNode.Image;
                if ((this.ImageHeight == 0) && (image != null))
                {
                    this.UpdateStyle();
                }
                base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);
                Rectangle glyphRect = new Rectangle(cellBounds.X + this.GlyphMargin, cellBounds.Y, this.INDENT_WIDTH, cellBounds.Height - 1);
                int       num       = glyphRect.Width / 2;
                int       level     = this.Level;
                if (image != null)
                {
                    Point point;
                    if (this.ImageHeight > cellBounds.Height)
                    {
                        point = new Point(glyphRect.X + this.GlyphWidth, cellBounds.Y + this.ImageHeightOffset);
                    }
                    else
                    {
                        point = new Point(glyphRect.X + this.GlyphWidth, ((cellBounds.Height / 2) - (this.ImageHeight / 2)) + cellBounds.Y);
                    }
                    GraphicsContainer container = graphics.BeginContainer();
                    graphics.SetClip(cellBounds);
                    graphics.DrawImageUnscaled(image, point);
                    graphics.EndContainer(container);
                }
                if (owningNode.BaseTGV.ShowLines)
                {
                    using (Pen pen = new Pen(SystemBrushes.ControlDark, 1f))
                    {
                        pen.DashStyle = DashStyle.Dot;
                        bool isLastSibling  = owningNode.IsLastSibling;
                        bool isFirstSibling = owningNode.IsFirstSibling;
                        if (owningNode.Level == 1)
                        {
                            if (isFirstSibling && isLastSibling)
                            {
                                graphics.DrawLine(pen, glyphRect.X + 4, cellBounds.Top + (cellBounds.Height / 2), glyphRect.Right, cellBounds.Top + (cellBounds.Height / 2));
                            }
                            else if (isLastSibling)
                            {
                                graphics.DrawLine(pen, glyphRect.X + 4, cellBounds.Top + (cellBounds.Height / 2), glyphRect.Right, cellBounds.Top + (cellBounds.Height / 2));
                                graphics.DrawLine(pen, glyphRect.X + 4, cellBounds.Top, glyphRect.X + 4, cellBounds.Top + (cellBounds.Height / 2));
                            }
                            else if (isFirstSibling)
                            {
                                graphics.DrawLine(pen, glyphRect.X + 4, cellBounds.Top + (cellBounds.Height / 2), glyphRect.Right, cellBounds.Top + (cellBounds.Height / 2));
                                graphics.DrawLine(pen, glyphRect.X + 4, cellBounds.Top + (cellBounds.Height / 2), glyphRect.X + 4, cellBounds.Bottom);
                            }
                            else
                            {
                                graphics.DrawLine(pen, glyphRect.X + 4, cellBounds.Top + (cellBounds.Height / 2), glyphRect.Right, cellBounds.Top + (cellBounds.Height / 2));
                                graphics.DrawLine(pen, glyphRect.X + 4, cellBounds.Top, glyphRect.X + 4, cellBounds.Bottom);
                            }
                        }
                        else
                        {
                            if (isLastSibling)
                            {
                                graphics.DrawLine(pen, glyphRect.X + 4, cellBounds.Top + (cellBounds.Height / 2), glyphRect.Right, cellBounds.Top + (cellBounds.Height / 2));
                                graphics.DrawLine(pen, glyphRect.X + 4, cellBounds.Top, glyphRect.X + 4, cellBounds.Top + (cellBounds.Height / 2));
                            }
                            else
                            {
                                graphics.DrawLine(pen, glyphRect.X + 4, cellBounds.Top + (cellBounds.Height / 2), glyphRect.Right, cellBounds.Top + (cellBounds.Height / 2));
                                graphics.DrawLine(pen, glyphRect.X + 4, cellBounds.Top, glyphRect.X + 4, cellBounds.Bottom);
                            }
                            TreeGridNode parent = owningNode.Parent;
                            for (int i = (glyphRect.X + 4) - this.INDENT_WIDTH; !parent.IsRoot; i -= this.INDENT_WIDTH)
                            {
                                if (!(!parent.HasChildren || parent.IsLastSibling))
                                {
                                    graphics.DrawLine(pen, i, cellBounds.Top, i, cellBounds.Bottom);
                                }
                                parent = parent.Parent;
                            }
                        }
                    }
                }
                if (owningNode.HasChildren || owningNode.BaseTGV.VirtualNodes)
                {
                    if (owningNode.IsExpanded)
                    {
                        graphics.DrawImage(Resources.Expanded1, new Rectangle(glyphRect.X, (glyphRect.Y + (glyphRect.Height / 2)) - 4, this.NodeSize, this.NodeSize));
                    }
                    else
                    {
                        graphics.DrawImage(Resources.Collapse1, new Rectangle(glyphRect.X, (glyphRect.Y + (glyphRect.Height / 2)) - 4, this.NodeSize, this.NodeSize));
                    }
                }
                if (this.IsHaveCheckBox && this.DrawCheckBox)
                {
                    this._checkboxRegion = this.GetCheckBoxRegion(glyphRect, CheckBoxRenderer.GetGlyphSize(graphics, this._PaintState));
                    CheckBoxRenderer.DrawCheckBox(graphics, new Point(this._checkboxRegion.X, this._checkboxRegion.Y), this._PaintState);
                }
            }
        }