/// <summary> /// Draws a glowing border around a given rectangle. /// </summary> /// <param name="g">The current Graphics object.</param> /// <param name="content">The rectangle that should contain the content.</param> /// <param name="glowColor">The color of the glow effect (will become 50 percent transparent).</param> /// <param name="size">The size of the glow effect.</param> /// <param name="radius">The optional radius for rounded corners.</param> public static void Glow(this Graphics g, Rectangle content, Color glowColor, int size = 10, float radius = 0) { var rect = new Rectangle(content.Left - size, content.Top - size, content.Width + 2 * size, 2 * size + content.Height); var gp = new GraphicsPath(); gp.AddRoundRectangle(rect, radius); var pgb = new PathGradientBrush(gp); pgb.CenterColor = glowColor; pgb.SurroundColors = new Color[] { Color.FromArgb(0, 0, 0, 0) }; g.FillRectangle(pgb, rect); }
/// <summary> /// Adds a rectangle with round corners to the current GraphicsPath. /// </summary> /// <param name="gp">The current GraphicsPath object.</param> /// <param name="rectangle">The rectangle which defines the area to be added.</param> /// <param name="radius">The radius of the different corners starting with the upper left corner.</param> /// <returns>The current GraphicsPath object.</returns> public static GraphicsPath AddRoundRectangle(this GraphicsPath gp, RectangleF rectangle, params float[] radius) { return(gp.AddRoundRectangle(rectangle.Location, rectangle.Size, radius)); }
/// <summary> /// Adds a rectangle with round corners to the current GraphicsPath. /// </summary> /// <param name="gp">The current GraphicsPath object.</param> /// <param name="rectangle">The rectangle which defines the area to be added.</param> /// <param name="radius">The radius of the different corners starting with the upper left corner.</param> /// <returns>The current GraphicsPath object.</returns> public static GraphicsPath AddRoundRectangle(this GraphicsPath gp, Rectangle rectangle, params float[] radius) { return(gp.AddRoundRectangle((RectangleF)rectangle, radius)); }