ComponentFactory.Krypton.Toolkit.RenderStandard.CreateBorderBackPathComplete C# (CSharp) Method

CreateBorderBackPathComplete() private static method

private static CreateBorderBackPathComplete ( bool middle, PaletteDrawBorders borders, GraphicsPath borderPath, Rectangle rect, int arcLength ) : void
middle bool
borders PaletteDrawBorders
borderPath System.Drawing.Drawing2D.GraphicsPath
rect System.Drawing.Rectangle
arcLength int
return void
        private static void CreateBorderBackPathComplete(bool middle,
                                                         PaletteDrawBorders borders,
                                                         GraphicsPath borderPath,
                                                         Rectangle rect,
                                                         int arcLength)
        {
            // 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;
            }
            // Define area that covers the border and the inside
            switch (borders)
            {
                case PaletteDrawBorders.None:
                case PaletteDrawBorders.Top:
                case PaletteDrawBorders.Bottom:
                case PaletteDrawBorders.Left:
                case PaletteDrawBorders.Right:
                case PaletteDrawBorders.TopBottom:
                case PaletteDrawBorders.LeftRight:
                    // Just add a simple rectangle as a quick way of adding four lines
                    borderPath.AddRectangle(rect);
                    break;
                case PaletteDrawBorders.TopLeft:
                    borderPath.AddLine(rectF.Left, rectF.Bottom, rectF.Left, rectF.Top + arcLength);
                    borderPath.AddArc(rectF.Left, rectF.Top, arcLength, arcLength, 180f, 90f);
                    borderPath.AddLine(rectF.Left + arcLength, rectF.Top, rectF.Right, rectF.Top);
                    borderPath.AddLine(rectF.Right, rectF.Top, rectF.Right, rectF.Bottom);
                    borderPath.AddLine(rectF.Right, rectF.Bottom, rectF.Left, rectF.Bottom);
                    break;
                case PaletteDrawBorders.TopRight:
                    borderPath.AddLine(rectF.Left, 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);
                    borderPath.AddLine(rectF.Right, rectF.Bottom, rectF.Left, rectF.Bottom);
                    borderPath.AddLine(rectF.Left, rectF.Bottom, rectF.Left, rectF.Top);
                    break;
                case PaletteDrawBorders.BottomRight:
                    // Reduce the width and height by 1 pixel for drawing into rectFangle
                    rectF.Width -= 1;
                    rectF.Height -= 1;

                    borderPath.AddLine(rectF.Right, rectF.Top, 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, rectF.Bottom);
                    borderPath.AddLine(rectF.Left, rectF.Bottom, rectF.Left, rectF.Top);
                    borderPath.AddLine(rectF.Left, rectF.Top, rectF.Right, rectF.Top);
                    break;
                case PaletteDrawBorders.BottomLeft:
                    // Reduce the width and height by 1 pixel for drawing into rectangle
                    rectF.X++;
                    rectF.Width -= 1;
                    rectF.Height -= 1;

                    borderPath.AddLine(rectF.Right, 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);
                    borderPath.AddLine(rectF.Left, rectF.Top, rectF.Right, rectF.Top);
                    borderPath.AddLine(rectF.Right, rectF.Top, rectF.Right, rectF.Bottom);
                    break;
                case PaletteDrawBorders.TopBottomLeft:
                    borderPath.AddLine(rectF.Right, 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, rectF.Top);
                    borderPath.AddLine(rectF.Right, rectF.Top, rectF.Right, rectF.Bottom);
                    break;
                case PaletteDrawBorders.TopBottomRight:
                    // Reduce the width and height by 1 pixel for drawing into rectangle
                    rectF.Width -= 1;
                    rectF.Height -= 1;

                    borderPath.AddLine(rectF.Left, 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, rectF.Bottom);
                    borderPath.AddLine(rectF.Left, rectF.Bottom, rectF.Left, rectF.Top);
                    break;
                case PaletteDrawBorders.TopLeftRight:
                    borderPath.AddLine(rectF.Left, rectF.Bottom, 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);
                    borderPath.AddLine(rectF.Right, rectF.Bottom, rectF.Left, rectF.Bottom);
                    break;
                case PaletteDrawBorders.BottomLeftRight:
                    // Reduce the width and height by 1 pixel for drawing into rectangle
                    rectF.X++;
                    rectF.Width -= 1;
                    rectF.Height -= 1;

                    borderPath.AddLine(rectF.Right, rectF.Top, 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.Top, rectF.Right, rectF.Top);
                    break;
            }
        }
RenderStandard