Example #1
0
 public override int GetRowOffset(GridColumnHandler column, int rowIndex)
 {
     if (object.ReferenceEquals(column.Widget, this.Widget.Columns[0]))
     {
         return(INDENT_WIDTH + controller.LevelAtRow(rowIndex) * INDENT_WIDTH);
     }
     else
     {
         return(0);
     }
 }
Example #2
0
        public override bool CellMouseClick(GridColumnHandler column, swf.MouseEventArgs e, int rowIndex)
        {
            if (rowIndex >= 0 && object.ReferenceEquals(column.Widget, this.Widget.Columns[0]))
            {
                var offset = INDENT_WIDTH + controller.LevelAtRow(rowIndex) * INDENT_WIDTH;
                if (e.X < offset && e.X >= offset - INDENT_WIDTH)
                {
                    if (controller.IsExpanded(rowIndex))
                    {
                        controller.CollapseRow(rowIndex);
                    }
                    else
                    {
                        controller.ExpandRow(rowIndex);
                    }

                    return(true);
                }
            }
            return(false);
        }
Example #3
0
        public override void Paint(GridColumnHandler column, sd.Graphics graphics, sd.Rectangle clipBounds, sd.Rectangle cellBounds, int rowIndex, swf.DataGridViewElementStates cellState, object value, object formattedValue, string errorText, swf.DataGridViewCellStyle cellStyle, swf.DataGridViewAdvancedBorderStyle advancedBorderStyle, ref swf.DataGridViewPaintParts paintParts)
        {
            if (object.ReferenceEquals(column.Widget, this.Widget.Columns[0]))
            {
                // paint the background
                if (paintParts.HasFlag(swf.DataGridViewPaintParts.Background))
                {
                    sd.Brush brush;
                    if (cellState.HasFlag(swf.DataGridViewElementStates.Selected))
                    {
                        brush = new sd.SolidBrush(cellStyle.SelectionBackColor);
                    }
                    else
                    {
                        brush = new sd.SolidBrush(cellStyle.BackColor);
                    }
                    graphics.FillRectangle(brush, cellBounds);
                    paintParts &= ~swf.DataGridViewPaintParts.Background;
                }

                var node     = controller.GetNodeAtRow(rowIndex);
                var treeRect = cellBounds;
                treeRect.X    += node.Level * INDENT_WIDTH;
                treeRect.Width = 16;

                if (ClassicStyle && ClassicGridLines)
                {
                    // Draw grid lines - for classic style
                    using (var linePen = new sd.Pen(sd.SystemBrushes.ControlDark, 1.0f))
                    {
                        var lineRect = treeRect;
                        lineRect.X       += 7;
                        lineRect.Width    = 10;
                        linePen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
                        var isFirstSibling = node.IsFirstNode;
                        var isLastSibling  = node.IsLastNode;
                        if (node.Level == 0)
                        {
                            // the Root nodes display their lines differently
                            if (isFirstSibling && isLastSibling)
                            {
                                // only node, both first and last. Just draw horizontal line
                                graphics.DrawLine(linePen, lineRect.X, cellBounds.Top + cellBounds.Height / 2, lineRect.Right, cellBounds.Top + cellBounds.Height / 2);
                            }
                            else if (isLastSibling)
                            {
                                // last sibling doesn't draw the line extended below. Paint horizontal then vertical
                                graphics.DrawLine(linePen, lineRect.X, cellBounds.Top + cellBounds.Height / 2, lineRect.Right, cellBounds.Top + cellBounds.Height / 2);
                                graphics.DrawLine(linePen, lineRect.X, cellBounds.Top, lineRect.X, cellBounds.Top + cellBounds.Height / 2);
                            }
                            else if (isFirstSibling)
                            {
                                // first sibling doesn't draw the line extended above. Paint horizontal then vertical
                                graphics.DrawLine(linePen, lineRect.X, cellBounds.Top + cellBounds.Height / 2, lineRect.Right, cellBounds.Top + cellBounds.Height / 2);
                                graphics.DrawLine(linePen, lineRect.X, cellBounds.Top + cellBounds.Height / 2, lineRect.X, cellBounds.Bottom);
                            }
                            else
                            {
                                // normal drawing draws extended from top to bottom. Paint horizontal then vertical
                                graphics.DrawLine(linePen, lineRect.X, cellBounds.Top + cellBounds.Height / 2, lineRect.Right, cellBounds.Top + cellBounds.Height / 2);
                                graphics.DrawLine(linePen, lineRect.X, cellBounds.Top, lineRect.X, cellBounds.Bottom);
                            }
                        }
                        else
                        {
                            if (isLastSibling)
                            {
                                // last sibling doesn't draw the line extended below. Paint horizontal then vertical
                                graphics.DrawLine(linePen, lineRect.X, cellBounds.Top + cellBounds.Height / 2, lineRect.Right, cellBounds.Top + cellBounds.Height / 2);
                                graphics.DrawLine(linePen, lineRect.X, cellBounds.Top, lineRect.X, cellBounds.Top + cellBounds.Height / 2);
                            }
                            else
                            {
                                // normal drawing draws extended from top to bottom. Paint horizontal then vertical
                                graphics.DrawLine(linePen, lineRect.X, cellBounds.Top + cellBounds.Height / 2, lineRect.Right, cellBounds.Top + cellBounds.Height / 2);
                                graphics.DrawLine(linePen, lineRect.X, cellBounds.Top, lineRect.X, cellBounds.Bottom);
                            }

                            // paint lines of previous levels to the root
                            int horizontalStop = lineRect.X - INDENT_WIDTH;
                            var previousNode   = node.Parent;

                            while (previousNode != null)
                            {
                                if (!previousNode.IsLastNode)
                                {
                                    // paint vertical line
                                    graphics.DrawLine(linePen, horizontalStop, lineRect.Top, horizontalStop, lineRect.Bottom);
                                }
                                previousNode   = previousNode.Parent;
                                horizontalStop = horizontalStop - INDENT_WIDTH;
                            }
                        }
                    }
                }

                if (node.Item.Expandable)
                {
                    // draw open/close glyphs
                    if (swf.Application.RenderWithVisualStyles)
                    {
                        EnsureGlyphRenderers();
                        if (controller.IsExpanded(rowIndex))
                        {
                            openRenderer.DrawBackground(graphics, new sd.Rectangle(treeRect.X, treeRect.Y + (treeRect.Height / 2) - 8, 16, 16));
                        }
                        else
                        {
                            closedRenderer.DrawBackground(graphics, new sd.Rectangle(treeRect.X, treeRect.Y + (treeRect.Height / 2) - 8, 16, 16));
                        }
                    }
                    else
                    {
                        // todo: draw +/- manually
                        var glyphRect = treeRect;
                        glyphRect.Width = glyphRect.Height = 8;
                        glyphRect.X    += 3;
                        glyphRect.Y    += (treeRect.Height - glyphRect.Height) / 2;
                        graphics.FillRectangle(sd.SystemBrushes.Window, glyphRect);
                        graphics.DrawRectangle(sd.SystemPens.ControlDark, glyphRect);
                        glyphRect.Inflate(-2, -2);
                        if (!controller.IsExpanded(rowIndex))
                        {
                            var midx = glyphRect.X + glyphRect.Width / 2;
                            graphics.DrawLine(sd.SystemPens.ControlDarkDark, midx, glyphRect.Top, midx, glyphRect.Bottom);
                        }

                        var midy = glyphRect.Y + glyphRect.Height / 2;
                        graphics.DrawLine(sd.SystemPens.ControlDarkDark, glyphRect.Left, midy, glyphRect.Right, midy);
                    }
                }
            }
        }
Example #4
0
 public virtual bool CellMouseClick(GridColumnHandler column, swf.MouseEventArgs e, int rowIndex)
 {
     return(false);
 }
Example #5
0
 public virtual int GetRowOffset(GridColumnHandler column, int rowIndex)
 {
     return(0);
 }
Example #6
0
 public virtual void Paint(GridColumnHandler column, System.Drawing.Graphics graphics, System.Drawing.Rectangle clipBounds, System.Drawing.Rectangle cellBounds, int rowIndex, swf.DataGridViewElementStates cellState, object value, object formattedValue, string errorText, swf.DataGridViewCellStyle cellStyle, swf.DataGridViewAdvancedBorderStyle advancedBorderStyle, ref swf.DataGridViewPaintParts paintParts)
 {
 }