private void DrawDottedGrip(
            Graphics graphics,
            Rectangle bounds,
            bool vertical,
            bool largeDot,
            Color innerColor,
            Color outerColor)
        {
            bounds.Height -= 3;
            Point     position = new Point(bounds.X, bounds.Y);
            int       sep;
            Rectangle posRect = new Rectangle(0, 0, 2, 2);

            using (SmoothingModeGraphics sg = new SmoothingModeGraphics(graphics))
            {
                IntPtr hdc;

                if (vertical)
                {
                    sep         = bounds.Height;
                    position.Y += 8;
                    for (int i = 0; position.Y > 4; i += 4)
                    {
                        position.Y = sep - (2 + i);
                        if (largeDot)
                        {
                            posRect.Location = position;
                            DrawCircle(
                                graphics,
                                posRect,
                                outerColor,
                                innerColor);
                        }
                        else
                        {
                            int innerWin32Corlor = ColorTranslator.ToWin32(innerColor);
                            int outerWin32Corlor = ColorTranslator.ToWin32(outerColor);

                            hdc = graphics.GetHdc();

                            SetPixel(
                                hdc,
                                position.X,
                                position.Y,
                                innerWin32Corlor);
                            SetPixel(
                                hdc,
                                position.X + 1,
                                position.Y,
                                outerWin32Corlor);
                            SetPixel(
                                hdc,
                                position.X,
                                position.Y + 1,
                                outerWin32Corlor);

                            SetPixel(
                                hdc,
                                position.X + 3,
                                position.Y,
                                innerWin32Corlor);
                            SetPixel(
                                hdc,
                                position.X + 4,
                                position.Y,
                                outerWin32Corlor);
                            SetPixel(
                                hdc,
                                position.X + 3,
                                position.Y + 1,
                                outerWin32Corlor);

                            graphics.ReleaseHdc(hdc);
                        }
                    }
                }
                else
                {
                    bounds.Inflate(-2, 0);
                    sep         = bounds.Width;
                    position.X += 2;

                    for (int i = 1; position.X > 0; i += 4)
                    {
                        position.X = sep - (2 + i);
                        if (largeDot)
                        {
                            posRect.Location = position;
                            DrawCircle(graphics, posRect, outerColor, innerColor);
                        }
                        else
                        {
                            int innerWin32Corlor = ColorTranslator.ToWin32(innerColor);
                            int outerWin32Corlor = ColorTranslator.ToWin32(outerColor);
                            hdc = graphics.GetHdc();

                            SetPixel(
                                hdc,
                                position.X,
                                position.Y,
                                innerWin32Corlor);
                            SetPixel(
                                hdc,
                                position.X + 1,
                                position.Y,
                                outerWin32Corlor);
                            SetPixel(
                                hdc,
                                position.X,
                                position.Y + 1,
                                outerWin32Corlor);

                            SetPixel(
                                hdc,
                                position.X + 3,
                                position.Y,
                                innerWin32Corlor);
                            SetPixel(
                                hdc,
                                position.X + 4,
                                position.Y,
                                outerWin32Corlor);
                            SetPixel(
                                hdc,
                                position.X + 3,
                                position.Y + 1,
                                outerWin32Corlor);

                            graphics.ReleaseHdc(hdc);
                        }
                    }
                }
            }
        }
        protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e)
        {
            ToolStrip toolStrip     = e.ToolStrip;
            var       isHeadControl = false;

            if (toolStrip.Tag != null && toolStrip.Tag.ToString().Contains("$"))
            {
                isHeadControl = true;
            }

            Graphics graphics = e.Graphics;

            if (toolStrip is ToolStripDropDown && e.Item is ToolStripMenuItem)
            {
                bool      drawLogo     = DrawLogo(toolStrip);
                int       offsetMargin = drawLogo ? OffsetMargin : 0;
                Rectangle rect         = e.ImageRectangle;

                if (e.Item.RightToLeft == RightToLeft.Yes)
                {
                    rect.X -= offsetMargin + 2;
                }
                else
                {
                    rect.X += offsetMargin + 2;
                }

                rect.Width   = 13;
                rect.Y      += 1;
                rect.Height -= 3;

                using (SmoothingModeGraphics sg = new SmoothingModeGraphics(graphics))
                {
                    using (GraphicsPath path = new GraphicsPath())
                    {
                        path.AddRectangle(rect);
                        using (PathGradientBrush brush = new PathGradientBrush(path))
                        {
                            brush.CenterColor    = StyleSet.ToolStripDropDownPressedCenterColor;
                            brush.CenterColor    = Color.Red;
                            brush.SurroundColors = new Color[] { isHeadControl?StyleSet.HeadToolStripItemPressedBackColor : StyleSet.ControlPressedBackColor };
                            Blend blend = new Blend();
                            blend.Positions = new float[] { 0f, 0.3f, 1f };
                            blend.Factors   = new float[] { 0f, 0.5f, 1f };
                            brush.Blend     = blend;
                            graphics.FillRectangle(brush, rect);
                        }
                    }

                    using (Pen pen = new Pen(StyleSet.HeadToolStripItemPressedBackColor))
                    {
                        graphics.DrawRectangle(pen, rect);
                    }

                    GraphicsHelper.DrawHollowwRectangle(graphics, rect, isHeadControl ? StyleSet.HeadToolStripItemCheckedBorderColor : StyleSet.ControlCheckedBorderColor);
                }
            }
            else
            {
                base.OnRenderItemCheck(e);
            }
        }
        protected override void OnRenderSplitButtonBackground(ToolStripItemRenderEventArgs e)
        {
            ToolStrip toolStrip     = e.ToolStrip;
            var       isHeadControl = false;

            if (toolStrip.Tag != null && toolStrip.Tag.ToString().Contains("$"))
            {
                isHeadControl = true;
            }
            ToolStripSplitButton item = e.Item as ToolStripSplitButton;

            if (item != null)
            {
                Graphics           graphics = e.Graphics;
                LinearGradientMode mode     = toolStrip.Orientation == Orientation.Horizontal ?
                                              LinearGradientMode.Vertical : LinearGradientMode.Horizontal;
                Rectangle             bounds = new Rectangle(Point.Empty, item.Size);
                SmoothingModeGraphics sg     = new SmoothingModeGraphics(graphics);

                Color arrowColor = SystemColors.ControlDarkDark;

                if (item.BackgroundImage != null)
                {
                    Rectangle clipRect = item.Selected ? item.ContentRectangle : bounds;
                    GraphicsHelper.DrawBackgroundImage(
                        graphics,
                        item.BackgroundImage,
                        isHeadControl ? StyleSet.HeadToolStripItemInnerBorderColor : StyleSet.ControlInnerBorderColor,
                        item.BackgroundImageLayout,
                        bounds,
                        clipRect);
                }

                if (item.ButtonPressed)
                {
                    Rectangle buttonBounds = item.ButtonBounds;
                    Padding   padding      = (item.RightToLeft == RightToLeft.Yes) ?
                                             new Padding(0, 1, 1, 1) : new Padding(1, 1, 0, 1);
                    buttonBounds = GraphicsHelper.DeflateRect(buttonBounds, padding);
                    GraphicsHelper.DrawBackground(
                        graphics,
                        bounds,
                        isHeadControl ? StyleSet.HeadToolStripItemHoveringBackColor : StyleSet.ControlHoveringBackColor,
                        isHeadControl ? StyleSet.HeadToolStripItemBorderColor : StyleSet.ControlBorderColor,
                        isHeadControl ? StyleSet.HeadToolStripItemInnerBorderColor : StyleSet.ControlInnerBorderColor,
                        isHeadControl ? RoundStyle.All : RoundStyle.None,
                        isHeadControl ? 8 : 0,
                        isHeadControl ? 0.45f : 0f,
                        true,
                        true,
                        mode);

                    buttonBounds.Inflate(-1, -1);
                    graphics.SetClip(buttonBounds);
                    GraphicsHelper.DrawBackground(
                        graphics,
                        buttonBounds,
                        isHeadControl ? StyleSet.HeadToolStripItemPressedBackColor : StyleSet.ControlPressedBackColor,
                        isHeadControl ? StyleSet.HeadToolStripItemBorderColor : StyleSet.ControlBorderColor,
                        isHeadControl ? StyleSet.HeadToolStripItemInnerBorderColor : StyleSet.ControlInnerBorderColor,
                        isHeadControl ? RoundStyle.All : RoundStyle.None,
                        isHeadControl ? 8 : 0,
                        isHeadControl ? 0.45f : 0f,
                        false,
                        true,
                        mode);
                    graphics.ResetClip();

                    using (Pen pen = new Pen(StyleSet.HeadToolStripItemBorderColor))
                    {
                        graphics.DrawLine(
                            pen,
                            item.SplitterBounds.Left,
                            item.SplitterBounds.Top,
                            item.SplitterBounds.Left,
                            item.SplitterBounds.Bottom);
                    }
                    base.DrawArrow(
                        new ToolStripArrowRenderEventArgs(
                            graphics,
                            item,
                            item.DropDownButtonBounds,
                            arrowColor,
                            ArrowDirection.Down));
                    return;
                }

                if (item.Pressed || item.DropDownButtonPressed)
                {
                    GraphicsHelper.DrawBackground(
                        graphics,
                        bounds,
                        isHeadControl ? StyleSet.HeadToolStripItemPressedBackColor : StyleSet.ControlPressedBackColor,
                        isHeadControl ? StyleSet.HeadToolStripItemBorderColor : StyleSet.ControlBorderColor,
                        isHeadControl ? StyleSet.HeadToolStripItemInnerBorderColor : StyleSet.ControlInnerBorderColor,
                        isHeadControl ? RoundStyle.All : RoundStyle.None,
                        isHeadControl ? 8 : 0,
                        isHeadControl ? 0.45f : 0f,
                        true,
                        true,
                        mode);
                    base.DrawArrow(
                        new ToolStripArrowRenderEventArgs(
                            graphics,
                            item,
                            item.DropDownButtonBounds,
                            arrowColor,
                            ArrowDirection.Down));
                    return;
                }

                if (item.Selected)
                {
                    GraphicsHelper.DrawBackground(
                        graphics,
                        bounds,
                        isHeadControl ? StyleSet.HeadToolStripItemHoveringBackColor : StyleSet.ControlHoveringBackColor,
                        isHeadControl ? StyleSet.HeadToolStripItemBorderColor : StyleSet.ControlBorderColor,
                        isHeadControl ? StyleSet.HeadToolStripItemInnerBorderColor : StyleSet.ControlInnerBorderColor,
                        isHeadControl ? RoundStyle.All : RoundStyle.None,
                        isHeadControl ? 8 : 0,
                        isHeadControl ? 0.45f : 0f,
                        true,
                        true,
                        mode);
                    using (Pen pen = new Pen(StyleSet.HeadToolStripItemBorderColor))
                    {
                        graphics.DrawLine(
                            pen,
                            item.SplitterBounds.Left,
                            item.SplitterBounds.Top,
                            item.SplitterBounds.Left,
                            item.SplitterBounds.Bottom);
                    }
                    base.DrawArrow(
                        new ToolStripArrowRenderEventArgs(
                            graphics,
                            item,
                            item.DropDownButtonBounds,
                            arrowColor,
                            ArrowDirection.Down));
                    return;
                }

                base.DrawArrow(
                    new ToolStripArrowRenderEventArgs(
                        graphics,
                        item,
                        item.DropDownButtonBounds,
                        arrowColor,
                        ArrowDirection.Down));
                return;
            }

            base.OnRenderSplitButtonBackground(e);
        }
        protected override void OnRenderOverflowButtonBackground(ToolStripItemRenderEventArgs e)
        {
            ToolStripItem item        = e.Item;
            ToolStrip     toolStrip   = e.ToolStrip;
            Graphics      graphics    = e.Graphics;
            bool          rightToLeft = item.RightToLeft == RightToLeft.Yes;

            SmoothingModeGraphics sg = new SmoothingModeGraphics(graphics);

            RenderOverflowBackground(e, rightToLeft);

            bool      bHorizontal = toolStrip.Orientation == Orientation.Horizontal;
            Rectangle empty       = Rectangle.Empty;

            if (rightToLeft)
            {
                empty = new Rectangle(0, item.Height - 8, 10, 5);
            }
            else
            {
                empty = new Rectangle(item.Width - 12, item.Height - 8, 10, 5);
            }
            ArrowDirection direction = bHorizontal ?
                                       ArrowDirection.Down : ArrowDirection.Right;
            int x = (rightToLeft && bHorizontal) ? -1 : 1;

            empty.Offset(x, 1);

            Color arrowColor = SystemColors.ControlDark;

            using (Brush brush = new SolidBrush(arrowColor))
            {
                GraphicsHelper.DrawArrow(graphics, empty, direction, brush);
            }

            if (bHorizontal)
            {
                using (Pen pen = new Pen(arrowColor))
                {
                    graphics.DrawLine(
                        pen,
                        empty.Right - 8,
                        empty.Y - 2,
                        empty.Right - 2,
                        empty.Y - 2);
                    graphics.DrawLine(
                        pen,
                        empty.Right - 8,
                        empty.Y - 1,
                        empty.Right - 2,
                        empty.Y - 1);
                }
            }
            else
            {
                using (Pen pen = new Pen(arrowColor))
                {
                    graphics.DrawLine(
                        pen,
                        empty.X,
                        empty.Y,
                        empty.X,
                        empty.Bottom - 1);
                    graphics.DrawLine(
                        pen,
                        empty.X,
                        empty.Y + 1,
                        empty.X,
                        empty.Bottom);
                }
            }
        }
        protected override void OnRenderButtonBackground(ToolStripItemRenderEventArgs e)
        {
            ToolStrip toolStrip     = e.ToolStrip;
            var       isHeadControl = false;

            if (toolStrip.Tag != null && toolStrip.Tag.ToString().Contains("$"))
            {
                isHeadControl = true;
            }
            var      item    = e.Item as ToolStripButton;
            Graphics graphcs = e.Graphics;

            if (item != null)
            {
                LinearGradientMode mode = toolStrip.Orientation == Orientation.Horizontal ?
                                          LinearGradientMode.Vertical : LinearGradientMode.Horizontal;
                var smoothGraphics = new SmoothingModeGraphics(graphcs);
                var bounds         = new Rectangle(Point.Empty, item.Size);

                if (item.BackgroundImage != null)
                {
                    Rectangle clipRect = item.Selected ? item.ContentRectangle : bounds;
                    GraphicsHelper.DrawBackgroundImage(
                        graphcs,
                        item.BackgroundImage,
                        isHeadControl ? StyleSet.HeadToolStripItemInnerBorderColor : StyleSet.ControlInnerBorderColor,
                        item.BackgroundImageLayout,
                        bounds,
                        clipRect);
                }

                if (item.CheckState == CheckState.Unchecked)
                {
                    if (item.Selected)
                    {
                        Color color = isHeadControl ? StyleSet.HeadToolStripItemHoveringBackColor : StyleSet.ControlHoveringBackColor;
                        if (item.Pressed)
                        {
                            color = isHeadControl ? StyleSet.HeadToolStripItemPressedBackColor : StyleSet.ControlPressedBackColor;
                        }
                        GraphicsHelper.DrawBackground(
                            graphcs,
                            bounds,
                            color,
                            isHeadControl ? StyleSet.HeadToolStripItemBorderColor : StyleSet.ControlBorderColor,
                            isHeadControl ? StyleSet.HeadToolStripItemInnerBorderColor : StyleSet.ControlInnerBorderColor,
                            isHeadControl ? RoundStyle.All : RoundStyle.None,
                            isHeadControl ?8:0,
                            isHeadControl ?0.45f:0f,
                            true,
                            true,
                            mode);
                    }
                    else
                    {
                        if (toolStrip is ToolStripOverflow)
                        {
                            using (Brush brush = new SolidBrush(isHeadControl ? StyleSet.HeadToolStripItemHoveringBackColor : StyleSet.ControlHoveringBackColor))
                            {
                                graphcs.FillRectangle(brush, bounds);
                            }
                        }
                    }
                }
                else
                {
                    Color color = ControlPaint.Light(isHeadControl ? StyleSet.HeadToolStripItemHoveringBackColor : StyleSet.ControlHoveringBackColor);
                    if (item.Selected)
                    {
                        color = isHeadControl ? StyleSet.HeadToolStripItemHoveringBackColor : StyleSet.ControlHoveringBackColor;
                    }
                    if (item.Pressed)
                    {
                        color = isHeadControl ? StyleSet.HeadToolStripItemPressedBackColor : StyleSet.ControlPressedBackColor;
                    }
                    GraphicsHelper.DrawBackground(
                        graphcs,
                        bounds,
                        color,
                        isHeadControl ? StyleSet.HeadToolStripItemBorderColor : StyleSet.ControlBorderColor,
                        isHeadControl ? StyleSet.HeadToolStripItemInnerBorderColor : StyleSet.ControlInnerBorderColor,
                        isHeadControl ? RoundStyle.All : RoundStyle.None,
                        isHeadControl ? 8 : 0,
                        isHeadControl ? 0.45f : 0f,
                        true,
                        true,
                        mode);
                }
                smoothGraphics.Dispose();
            }
        }