public void FillRoundRectangle(Rectangle rect, int radius, Color color) { if (rect.Width < 1 || rect.Height < 1) return; GraphicsPath path = GetRoundPath(rect, radius, 0, PathMode.All, RoundedCorners.All); using (BrushPlus brush = new SolidBrushPlus(color)) { this.FillPath(brush, path); } }
public void FillRoundRectangle(Rectangle rect, int radius, Color color) { if (rect.Width < 1 || rect.Height < 1) { return; } GraphicsPath path = GetRoundPath(rect, radius, 0, PathMode.All, RoundedCorners.All); using (BrushPlus brush = new SolidBrushPlus(color)) { this.FillPath(brush, path); } }
public void GradientFillShape(Rectangle rect, int radius, Color startColor, Color endColor, GradientMode gradientMode, GraphicShape shape, RoundedCorners corners) { if (rect.Width < 1 || rect.Height < 1) return; PathFunc func = GetShapeFunc(shape); SmoothingMode mode = SmoothingMode; try { SmoothingMode = SmoothingMode.None; int x = rect.X, y = rect.Y, w = rect.Width, h = rect.Height; int reflectionHeight = h / 2; PointF p1 = new PointF(x, y); PointF p2 = new PointF(x, y + reflectionHeight); if (gradientMode == GradientMode.Top) { PathMode pathMode = endColor.A == 255 ? PathMode.Bottom : PathMode.All; using (GraphicsPath path = func(rect, radius, reflectionHeight, pathMode, corners)) { using (SolidBrushPlus brush = new SolidBrushPlus(endColor)) { this.FillPath(brush, path); } } using (GraphicsPath path = func(rect, radius, reflectionHeight, PathMode.Top, corners)) { using (LinearGradientBrush brush = new LinearGradientBrush(p1, p2, startColor, endColor)) { this.FillPath(brush, path); } } } else { PathMode pathMode = endColor.A == 255 ? PathMode.Top : PathMode.All; using (GraphicsPath path = func(rect, radius, reflectionHeight, PathMode.All, corners)) { using (SolidBrushPlus brush = new SolidBrushPlus(endColor)) { this.FillPath(brush, path); } } using (GraphicsPath path = func(rect, radius, reflectionHeight, PathMode.Bottom, corners)) { p1.Y = y + reflectionHeight - 1; p2.Y = y + h; using (LinearGradientBrush brush = new LinearGradientBrush(p1, p2, endColor, startColor)) { this.FillPath(brush, path); } } } } finally { SmoothingMode = mode; } }
private void PaintTemplateBackground() { Graphics g = Graphics; Rectangle r = ClientBounds; Color color = BackColor; if (IsTransparent) { color = ColorConverter.AlphaColor(color, 220); using (GraphicsPlus gp = new GraphicsPlus(g)) { using (SolidBrushPlus backGround = new SolidBrushPlus(color)) { gp.FillRectangle(backGround, r); } } } else { using (SolidBrush brush = new SolidBrush(color)) { g.FillRectangle(brush, r); } } }
/// <summary> /// Creates and paints the button bitmap of the virtual scrollbar. /// </summary> /// <param name="width">The width of the button.</param> /// <param name="height">The height of the button.</param> /// <returns>The button image.</returns> protected virtual Image CreateScrollButtonBitmap(int width, int height) { Bitmap bm = new Bitmap(width, height); using (Graphics g = Graphics.FromImage(bm)) { int r = Math.Min(width, height / 2) - 1; if (r < 1) r = 1; backgroundBrush.Color = Color.Fuchsia; //g.Clear(Color.Fuchsia); g.FillRectangle(backgroundBrush, 0, 0, width, height); using (GraphicsPlus gp = new GraphicsPlus(g)) { Rectangle bounds = new Rectangle(0, 0, width - 1, height - 1); gp.SmoothingMode = SmoothingMode.None; Color color = scrollbarButtonColor; using (SolidBrushPlus brush = new SolidBrushPlus(color, true)) { gp.FillRoundRectangle(bounds, r, brush); } using (PenPlus pen = new PenPlus(ScrollBarButtonBorderColor, 1, true)) { gp.DrawRoundRectangle(bounds, r, pen); } } } return bm; }
protected virtual void OnPaintBackground(FluidPaintEventArgs e) { if (PaintBackground != null) PaintBackground(this, e); else { if (!BackColor.IsEmpty && BackColor != Color.Transparent) { Graphics g = e.Graphics; if (BackColor.A == 255 || BackColor.A == 0) { SolidBrush brush = Brushes.GetBrush(BackColor); g.FillRectangle(brush, e.ControlBounds); } else { using (GraphicsPlus gp = new GraphicsPlus(g)) { using (SolidBrushPlus brush = new SolidBrushPlus(BackColor)) { gp.FillRectangle(brush, e.ControlBounds); } } } } } }
public void GradientFillShape(Rectangle rect, int radius, Color startColor, Color endColor, GradientMode gradientMode, GraphicShape shape, RoundedCorners corners) { if (rect.Width < 1 || rect.Height < 1) { return; } PathFunc func = GetShapeFunc(shape); SmoothingMode mode = SmoothingMode; try { SmoothingMode = SmoothingMode.None; int x = rect.X, y = rect.Y, w = rect.Width, h = rect.Height; int reflectionHeight = h / 2; PointF p1 = new PointF(x, y); PointF p2 = new PointF(x, y + reflectionHeight); if (gradientMode == GradientMode.Top) { PathMode pathMode = endColor.A == 255 ? PathMode.Bottom : PathMode.All; using (GraphicsPath path = func(rect, radius, reflectionHeight, pathMode, corners)) { using (SolidBrushPlus brush = new SolidBrushPlus(endColor)) { this.FillPath(brush, path); } } using (GraphicsPath path = func(rect, radius, reflectionHeight, PathMode.Top, corners)) { using (LinearGradientBrush brush = new LinearGradientBrush(p1, p2, startColor, endColor)) { this.FillPath(brush, path); } } } else { PathMode pathMode = endColor.A == 255 ? PathMode.Top : PathMode.All; using (GraphicsPath path = func(rect, radius, reflectionHeight, PathMode.All, corners)) { using (SolidBrushPlus brush = new SolidBrushPlus(endColor)) { this.FillPath(brush, path); } } using (GraphicsPath path = func(rect, radius, reflectionHeight, PathMode.Bottom, corners)) { p1.Y = y + reflectionHeight - 1; p2.Y = y + h; using (LinearGradientBrush brush = new LinearGradientBrush(p1, p2, endColor, startColor)) { this.FillPath(brush, path); } } } } finally { SmoothingMode = mode; } }