Example #1
0
            protected override void Paint(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, swf.DataGridViewPaintParts paintParts)
            {
                // save graphics state to prevent artifacts in other paint operations in the grid
                var state = graphics.Save();

                if (!ReferenceEquals(cachedGraphicsKey, graphics) || cachedGraphics == null)
                {
                    cachedGraphicsKey = graphics;
                    cachedGraphics    = new Graphics(new GraphicsHandler(graphics, dispose: false));
                }
                else
                {
                    ((GraphicsHandler)cachedGraphics.Handler).SetInitialState();
                }
                graphics.PixelOffsetMode = sd.Drawing2D.PixelOffsetMode.Half;
                graphics.SetClip(cellBounds);
                var color = new sd.SolidBrush(cellState.HasFlag(swf.DataGridViewElementStates.Selected) ? cellStyle.SelectionBackColor : cellStyle.BackColor);

                graphics.FillRectangle(color, cellBounds);
                var args = new CellPaintEventArgs(cachedGraphics, cellBounds.ToEto(), cellState.ToEto(), value);

                Handler.Callback.OnPaint(Handler.Widget, args);
                graphics.ResetClip();
                graphics.Restore(state);
            }
Example #2
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)
 {
 }
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
        protected void Paint(sd.Graphics graphics, sd.Rectangle clipBounds, ref 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 (CellConfig != null)
            {
                CellConfig.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, ref paintParts);

                var offset = CellConfig.GetRowOffset(rowIndex);
                cellBounds.X     += offset;
                cellBounds.Width -= offset;
            }
        }
Example #5
0
            protected override void Paint(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, swf.DataGridViewPaintParts paintParts)
            {
                // save graphics state to prevent artifacts in other paint operations in the grid
                var state = graphics.Save();

                if (!object.ReferenceEquals(cachedGraphicsKey, graphics) || cachedGraphics == null)
                {
                    cachedGraphicsKey = graphics;
                    cachedGraphics    = new Graphics(new GraphicsHandler(graphics, shouldDisposeGraphics: false));
                }
                else
                {
                    ((GraphicsHandler)cachedGraphics.Handler).SetInitialState();
                }
                graphics.SetClip(cellBounds);
#pragma warning disable 618
                var args = new DrawableCellPaintEventArgs(cachedGraphics, cellBounds.ToEto(), cellState.ToEto(), value);
                Handler.Callback.OnPaint(Handler.Widget, args);
#pragma warning restore 618
                graphics.ResetClip();
                graphics.Restore(state);
            }
Example #6
0
 protected override void Paint(sd.Graphics graphics, sd.Rectangle clipBounds, sd.Rectangle cellBounds, int rowIndex, swf.DataGridViewElementStates elementState, object value, object formattedValue, string errorText, swf.DataGridViewCellStyle cellStyle, swf.DataGridViewAdvancedBorderStyle advancedBorderStyle, swf.DataGridViewPaintParts paintParts)
 {
     Handler.Paint(graphics, clipBounds, ref cellBounds, rowIndex, elementState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, ref paintParts);
     base.Paint(graphics, clipBounds, cellBounds, rowIndex, elementState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);
 }
Example #7
0
 public void Paint(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 (GridHandler != null)
     {
         GridHandler.Paint(this, graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, ref paintParts);
     }
 }