private static void CreateAllBorderBackPath(bool middle,
GraphicsPath borderPath,
Rectangle rect,
int width,
int rounding,
bool forBorder,
int arcLength,
int arcLength1)
{
// If there is no room for any rounding effect...
if (rounding <= 0)
{
// If the width is an odd number then need to reduce by 1 in each dimension
if (forBorder && middle && ((width % 2) == 1))
{
rect.Width -= 1;
rect.Height -= 1;
}
// Just add a simple rectangle as a quick way of adding four lines
borderPath.AddRectangle(rect);
}
else
{
// We create the path using a floating point rectangle
RectangleF rectF = new RectangleF(rect.X, rect.Y, rect.Width, rect.Height);
// If trying to get the outside edge then perform some offsetting so that
// when converted to a region it draws nicely inside the path outline
if (!middle && ((width % 2) == 1))
{
rectF.X -= 0.25f;
rectF.Y -= 0.25f;
rectF.Width += 0.75f;
rectF.Height += 0.75f;
}
// The border is made of up a quarter of a circle arc, in each corner
borderPath.AddArc(rectF.Left, rectF.Top, arcLength, arcLength, 180f, 90f);
borderPath.AddArc(rectF.Right - arcLength1, rectF.Top, arcLength, arcLength, 270f, 90f);
borderPath.AddArc(rectF.Right - arcLength1, rectF.Bottom - arcLength1, arcLength, arcLength, 0f, 90f);
borderPath.AddArc(rectF.Left, rectF.Bottom - arcLength1, arcLength, arcLength, 90f, 90f);
// Make the last and first arc join up
borderPath.CloseFigure();
}
}