private static void CreateBorderBackPathOnlyClosed(bool middle,
PaletteDrawBorders borders,
GraphicsPath borderPath,
Rectangle rect,
int arcLength,
int variant)
{
// Reduce the width and height by 1 pixel for drawing into rectangle
rect.Width--;
rect.Height--;
// 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)
{
rectF.X -= 0.25f;
rectF.Y -= 0.25f;
rectF.Width += 0.75f;
rectF.Height += 0.75f;
}
// Add only the border for drawing
switch (borders)
{
case PaletteDrawBorders.None:
break;
case PaletteDrawBorders.Top:
case PaletteDrawBorders.Bottom:
case PaletteDrawBorders.Left:
case PaletteDrawBorders.Right:
case PaletteDrawBorders.TopBottom:
case PaletteDrawBorders.LeftRight:
// When using the entire rectangle we do not need to adjust its size
rect.Width ++;
rect.Height++;
borderPath.AddRectangle(rect);
break;
case PaletteDrawBorders.TopLeft:
borderPath.AddLine(rectF.Left, rectF.Bottom + 1, rectF.Left, rectF.Top + arcLength);
borderPath.AddArc(rectF.Left, rectF.Top, arcLength, arcLength, 180f, 90f);
borderPath.AddLine(rectF.Left + arcLength, rectF.Top, rectF.Right + 1, rectF.Top);
borderPath.AddLine(rectF.Right, rectF.Top, rectF.Right, rectF.Bottom);
break;
case PaletteDrawBorders.TopRight:
borderPath.AddLine(rectF.Left - 1, rectF.Top, rectF.Right - arcLength, rectF.Top);
borderPath.AddArc(rectF.Right - arcLength, rectF.Top, arcLength, arcLength, -90f, 90f);
borderPath.AddLine(rectF.Right, rectF.Top + arcLength, rectF.Right, rectF.Bottom + 1);
borderPath.AddLine(rectF.Right, rectF.Bottom, rectF.Left, rectF.Bottom);
break;
case PaletteDrawBorders.BottomRight:
borderPath.AddLine(rectF.Right, rectF.Top - 1, rectF.Right, rectF.Bottom - arcLength);
borderPath.AddArc(rectF.Right - arcLength, rectF.Bottom - arcLength, arcLength, arcLength, 0f, 90f);
borderPath.AddLine(rectF.Right - arcLength, rectF.Bottom, rectF.Left - 1, rectF.Bottom);
borderPath.AddLine(rectF.Left, rectF.Bottom, rectF.Left, rectF.Top);
break;
case PaletteDrawBorders.BottomLeft:
borderPath.AddLine(rectF.Right + 1, rectF.Bottom, rectF.Left + arcLength, rectF.Bottom);
borderPath.AddArc(rectF.Left, rectF.Bottom - arcLength, arcLength, arcLength, 90f, 90f);
borderPath.AddLine(rectF.Left, rectF.Bottom - arcLength, rectF.Left, rectF.Top - 1);
borderPath.AddLine(rectF.Left, rectF.Top, rectF.Right, rectF.Top);
break;
case PaletteDrawBorders.TopBottomLeft:
borderPath.AddLine(rectF.Right + 1, rectF.Bottom, rectF.Left + arcLength, rectF.Bottom);
borderPath.AddArc(rectF.Left, rectF.Bottom - arcLength, arcLength, arcLength, 90f, 90f);
borderPath.AddArc(rectF.Left, rectF.Top, arcLength, arcLength, 180f, 90f);
borderPath.AddLine(rectF.Left + arcLength, rectF.Top, rectF.Right + 1, rectF.Top);
break;
case PaletteDrawBorders.TopBottomRight:
borderPath.AddLine(rectF.Left - 1, rectF.Top, rectF.Right - arcLength, rectF.Top);
borderPath.AddArc(rectF.Right - arcLength, rectF.Top, arcLength, arcLength, -90f, 90f);
borderPath.AddArc(rectF.Right - arcLength, rectF.Bottom - arcLength, arcLength, arcLength, 0f, 90f);
borderPath.AddLine(rectF.Right - arcLength, rectF.Bottom, rectF.Left - 1, rectF.Bottom);
break;
case PaletteDrawBorders.TopLeftRight:
borderPath.AddLine(rectF.Left, rectF.Bottom + 1, rectF.Left, rectF.Top + arcLength);
borderPath.AddArc(rectF.Left, rectF.Top, arcLength, arcLength, 180f, 90f);
borderPath.AddArc(rectF.Right - arcLength, rectF.Top, arcLength, arcLength, -90f, 90f);
borderPath.AddLine(rectF.Right, rectF.Top + arcLength, rectF.Right, rectF.Bottom + 1);
break;
case PaletteDrawBorders.BottomLeftRight:
borderPath.AddLine(rectF.Right, rectF.Top - 1, rectF.Right, rectF.Bottom - arcLength);
borderPath.AddArc(rectF.Right - arcLength, rectF.Bottom - arcLength, arcLength, arcLength, 0f, 90f);
borderPath.AddArc(rectF.Left, rectF.Bottom - arcLength, arcLength, arcLength, 90f, 90f);
borderPath.AddLine(rectF.Left, rectF.Bottom - arcLength, rectF.Left, rectF.Top - 1);
break;
}
}