private const double ROUNDED_RECT_RAD_PERCENT = .05d;//5 percent /// <summary> /// Gets the graphics path. /// </summary> /// <param name="container">The container.</param> /// <param name="shape">The shape.</param> /// <returns>GraphicsPath.</returns> public static GraphicsPath GetGraphicsPath(Rectangle container, ControlShape shape) { GraphicsPath path = new GraphicsPath(); Rectangle pathRect = container; pathRect.Width -= 1; pathRect.Height -= 1; switch (shape) { case ControlShape.Rect: path.AddRectangle(pathRect); break; case ControlShape.RoundedRect: //radius is 10% of smallest side int rad = (int)(Math.Min(pathRect.Height, pathRect.Width) * ROUNDED_RECT_RAD_PERCENT); CustomExtensions.AddRoundedRectangle(path, pathRect, rad); break; case ControlShape.Circular: path.AddEllipse(pathRect); break; } return(path); }
/// <summary> /// Get3s the d shine path. /// </summary> /// <param name="container">The container.</param> /// <param name="shape">The shape.</param> /// <returns>GraphicsPath.</returns> public static GraphicsPath Get3DShinePath(Rectangle container, ControlShape shape) { GraphicsPath path = new GraphicsPath(); Rectangle pathRect = container; pathRect.Width -= 1; pathRect.Height -= 1; RectangleF halfRect = new RectangleF(pathRect.X, pathRect.Y, pathRect.Width, pathRect.Height / 2f); if (pathRect.Height > 0 && pathRect.Width > 0) { switch (shape) { case ControlShape.Rect: path.AddRectangle(halfRect); break; case ControlShape.RoundedRect: //radius is 10% of smallest side int rad = (int)(Math.Min(halfRect.Height, halfRect.Width) * ROUNDED_RECT_RAD_PERCENT); CustomExtensions.AddRoundedRectangle(path, halfRect, rad); break; case ControlShape.Circular: path.AddArc(pathRect, 180, 142); PointF[] pts = new PointF[] { path.GetLastPoint(), new PointF(container.Width * .70f, container.Height * .33f), new PointF(container.Width * .25f, container.Height * .5f), path.PathPoints[0] }; path.AddCurve(pts); path.CloseFigure(); break; } } return(path); }