private void DrawBackground(Graphics paint, Rectangle buttonRect, ButtonCellStyleInfo style, bool drawHovered, CellButton cellButton) { Color color = style.BackColor; if (style.Enabled) { color = style.BackColor; } else { color = style.DisabledBackColor; } paint.FillRectangle(new SolidBrush(color), buttonRect); }
private void DrawBorder(Graphics paint, Rectangle buttonRect, ButtonCellStyleInfo style, bool drawHovered) { if (style.Enabled) { if (style.BorderColor != null) { paint.DrawRectangle(style.BorderColor, Rectangle.Round(buttonRect)); } } else { if (style.DisabledBorderColor != null) { paint.DrawRectangle(style.DisabledBorderColor, Rectangle.Round(buttonRect)); } } }
public virtual void DrawButton(Graphics paint, Rectangle cellRect, Rectangle buttonRect, string cellValue, ButtonCellStyleInfo style, DataColumnBase column, Syncfusion.WinForms.GridCommon.ScrollAxis.RowColumnIndex rowColumnIndex, int buttonIndex = 0) { // No need to draw the button when its not visible on the cell bounds. if (cellRect.Width < 5) { return; } var clipBound = paint.ClipBounds; var cellButton = (column.GridColumn as GridTextButtonColumn).CellButton; bool drawHovered = false; DrawBackground(paint, buttonRect, style, drawHovered, cellButton); if (cellRect.Contains(buttonRect)) { paint.SetClip(buttonRect); } else if (cellRect.IntersectsWith(buttonRect)) { Rectangle intersectRect = Rectangle.Intersect(cellRect, buttonRect); paint.SetClip(intersectRect); } if (cellButton.Image != null) { var imageSize = cellButton.Image.Size.IsEmpty ? cellButton.Image.Size : Size.Empty; Rectangle imageRectangle = buttonRect; DrawImage(paint, imageRectangle, cellButton.Image); } paint.SetClip(cellRect); DrawBorder(paint, buttonRect, style, drawHovered); paint.SetClip(clipBound); }