all groups > dotnet compact framework > may 2007 >
You're in the

dotnet compact framework

group:

Drawing Rounded Rectangles?


Drawing Rounded Rectangles? Craig Setera
5/25/2007 7:11:05 AM
dotnet compact framework:
What is the easiest way to draw rectangles with rounded corners in NetCF
1.0? It seems like the region support is minimal and doing rounded
rectangles appears to be difficult.

Thanks,
Re: Drawing Rounded Rectangles? ctacke/
5/25/2007 8:49:22 AM
I'd guess a custom polygon.


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Managed Code in an Embedded World
www.OpenNETCF.com


[quoted text, click to view]

Re: Drawing Rounded Rectangles? Fabio
5/27/2007 4:21:58 PM

"Craig Setera" <csete@nospam.mfoundry.com> ha scritto nel messaggio

[quoted text, click to view]

This is what I use in full fw:

public void PaintRoundRect(Pen p, Brush fillBrush, int x, int y, int width,
int height, int radius)

{

GraphicsPath gp = new GraphicsPath();

gp.AddArc(x + width - radius, y, radius, radius, 270, 90);

gp.AddArc(x + width - radius, y + height - radius, radius, radius, 0, 90);

gp.AddArc(x, y + height - radius, radius, radius, 90, 90);

gp.AddArc(x, y, radius, radius, 180, 90);

gp.CloseFigure();

if (fillBrush != null)

_graphics.FillPath(fillBrush, gp);

if (p != null)

_graphics.DrawPath(p, gp);

gp.Dispose();

}

AddThis Social Bookmark Button