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

CreateBorderBackPath() private static method

private static CreateBorderBackPath ( bool forBorder, bool middle, Rectangle rect, PaletteDrawBorders borders, int borderWidth, int borderRounding, bool smoothing, int variant ) : GraphicsPath
forBorder bool
middle bool
rect System.Drawing.Rectangle
borders PaletteDrawBorders
borderWidth int
borderRounding int
smoothing bool
variant int
return System.Drawing.Drawing2D.GraphicsPath
        private static GraphicsPath CreateBorderBackPath(bool forBorder,
                                                         bool middle,
                                                         Rectangle rect,
                                                         PaletteDrawBorders borders,
                                                         int borderWidth,
                                                         int borderRounding,
                                                         bool smoothing,
                                                         int variant)
        {
            Rectangle origRect = rect;

            GraphicsPath borderPath = new GraphicsPath();

            // A zero size rectangle cannot be drawn, so return a null path
            if ((rect.Width > 0) && (rect.Height > 0))
            {
                // Only use a rounding that will fit inside the rect
                int rounding = Math.Min(borderRounding, Math.Min(rect.Width / 2, rect.Height / 2) - borderWidth);

                // Shrink the rect by half the width of the pen, because the pen will
                // draw half the distance overlapping each side of the centre anyway.
                // Unless not drawing into the middle in which case give the outside.
                int halfBorderWidthTL = (middle ? borderWidth / 2 : 0);

                // Only adjust the edges that are being drawn
                if (CommonHelper.HasTopBorder(borders))
                {
                    rect.Y += halfBorderWidthTL;
                    rect.Height -= halfBorderWidthTL;
                }

                if (CommonHelper.HasLeftBorder(borders))
                {
                    rect.X += halfBorderWidthTL;
                    rect.Width -= halfBorderWidthTL;
                }

                if (CommonHelper.HasBottomBorder(borders))
                    rect.Height -= halfBorderWidthTL;

                if (CommonHelper.HasRightBorder(borders))
                    rect.Width -= halfBorderWidthTL;

                // Find the width/height of the arc box
                int arcLength = rounding * 2;
                int arcLength1 = arcLength + 1;

                // If drawing all the four borders use a single routine
                if (CommonHelper.HasAllBorders(borders))
                    CreateAllBorderBackPath(middle, borderPath, rect, borderWidth, rounding, forBorder, arcLength, arcLength1);
                else
                {
                    // Are we calculating just the borders to be drawn?
                    if (forBorder)
                    {
                        // Are we calculating for the outside of the border edge? This is used for a KryptonForm
                        // which needs to create a region that is the outside edge of the borders.
                        if (!middle)
                        {
                            // If rounding is used we need to use a path so that corner rounding is honored but
                            // because this is going to be used as a region we need to close the path as well.
                            if (rounding > 0)
                                CreateBorderBackPathOnlyClosed(middle, borders, borderPath, rect, arcLength, variant);
                            else
                            {
                                // Without rounding we just provide the entire area
                                borderPath.AddRectangle(rect);
                            }
                        }
                        else
                        {
                            // We are calculating the middle of the border as the brush will then draw the entire
                            // border from the middle outwards.

                            if (rounding > 0)
                                CreateBorderBackPathOnly(middle, borders, borderPath, rect, arcLength, variant);
                            else
                                CreateBorderBackPathOnly(borders, borderPath, rect, variant);
                        }
                    }
                    else
                    {
                        // Calculating a complete path for the entire area and not just the specified borders
                        // If there is rounding we need to calculate a path that honors the rounding at corners
                        if (rounding > 0)
                            CreateBorderBackPathComplete(middle, borders, borderPath, rect, arcLength);
                        else
                        {
                            // Without rounding the complete path is always just the entire area
                            borderPath.AddRectangle(rect);
                        }
                    }
                }
            }

            return borderPath;
        }
RenderStandard