CSharp examples for System.Drawing:Graphics
Draw Round Rect
using System.Reflection; using System.IO;//from ww w .j a va 2 s .c om using System.Drawing.Drawing2D; using System.Drawing; using System.Text; using System.Collections.Generic; using System; public class Main{ public static GraphicsPath DrawRoundRect(Rectangle rect, int radius) { int x = rect.X; int y = rect.Y; int width = rect.Width; int height = rect.Height; return DrawRoundRect(x, y, width - 2, height - 1, radius); } public static GraphicsPath DrawRoundRect(int x, int y, int width, int height, int radius) { GraphicsPath gp = new GraphicsPath(); gp.AddArc(x, y, radius, radius, 180, 90); gp.AddArc(width - radius, y, radius, radius, 270, 90); gp.AddArc(width - radius, height - radius, radius, radius, 0, 90); gp.AddArc(x, height - radius, radius, radius, 90, 90); gp.CloseAllFigures(); return gp; } }