private static void FillAndStrokeButtonBackground( Graphics g, Rectangle bounds, Color backColor, Color borderColor, bool pressed) { // the background is filled and stroked as a rounded rectangle using (GraphicsPath path = bounds.CreateRoundedRectanglePath(1)) { // reset the background to white g.FillPath(Brushes.White, path); // fill the rounded rectangle with a shiny vertical gradient using (Brush brush = CreateButtonBackgroundBrush(bounds, backColor, pressed ? 32 : 64)) g.FillPath(brush, path); // stroke the rounded rectangle with a subtle shiny vertical gradient using (Brush brush = CreateButtonBackgroundBrush(bounds, borderColor, pressed ? 192 : 128)) using (Pen pen = new Pen(brush)) g.DrawPath(pen, path); } }