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) { if (!object.ReferenceEquals(cachedGraphicsKey, graphics) || cachedGraphics == null) { cachedGraphicsKey = graphics; cachedGraphics = new Graphics(Handler.Generator, new GraphicsHandler(graphics, shouldDisposeGraphics: false)); } if (Handler.Widget.PaintHandler != null) { var b = graphics.ClipBounds; graphics.SetClip(clipBounds); Handler.Widget.PaintHandler(new DrawableCellPaintArgs { Graphics = cachedGraphics, CellBounds = new RectangleF(cellBounds.ToEto()), Item = value, CellState = cellState.ToEto(), }); graphics.SetClip(b); // restore } }
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) { if (!object.ReferenceEquals(cachedGraphicsKey, graphics) || cachedGraphics == null) { cachedGraphicsKey = graphics; cachedGraphics = new Graphics(new GraphicsHandler(graphics, shouldDisposeGraphics: false)); } graphics.SetClip(cellBounds); var args = new DrawableCellPaintEventArgs(cachedGraphics, cellBounds.ToEto(), cellState.ToEto(), value); Handler.Callback.OnPaint(Handler.Widget, args); graphics.ResetClip(); }
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, dispose: 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); }
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); }