ill attach a ss of both the smoothed version, then the ugly version. It appears any time i set the region to my rounded rectangle shape the back color of my form is being shown behind the path's pixels making the smooth look turn ugly. How can I do this better?
Attempting to make a rounded form thats smoothed!
Smoothness disrupted by form after setting forms region to path
The code im using to draw the rectangle
SolidBrush sb = new SolidBrush(Color.Black);
Size s = new Size(10, 10);
Rectangle r = new Rectangle(new Point(0, 0), s);
r.Width = this.Width;
r.Height = this.Height;
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
SetNewRegion.FillRoundedRectangle(e.Graphics, sb, r, 25);
the SetNewRegion file function.
public static void FillRoundedRectangle(this Graphics graphics, Brush brush, Rectangle bounds, int cornerRadius)
{
if (graphics == null)
throw new ArgumentNullException("graphics");
if (brush == null)
throw new ArgumentNullException("brush");
using (GraphicsPath path = RoundedRect(bounds, cornerRadius))
{
graphics.FillPath(brush, path);
}
}
public static GraphicsPath RoundedRect(Rectangle bounds, int radius)
{
int diameter = radius * 2;
Size size = new Size(diameter, diameter);
Rectangle arc = new Rectangle(bounds.Location, size);
GraphicsPath path = new GraphicsPath();
if (radius == 0)
{
path.AddRectangle(bounds);
return path;
}
path.AddArc(arc, 180, 90);
arc.X = bounds.Right - diameter;
path.AddArc(arc, 270, 90);
arc.Y = bounds.Bottom - diameter;
path.AddArc(arc, 0, 90);
arc.X = bounds.Left;
path.AddArc(arc, 90, 90);
path.CloseFigure();
return path;
}
Then finally, simply adding the region by using an altered version of FillRoundedRectangle to enable me to build a region using the same path but in region form.
this.Region = SetNewRegion.WindowBounds(e.Graphics, sb, r, 25);