Example #1
0
        protected internal virtual void OnPaintScrollBarArrow(
            PaintScrollBarArrowEventArgs e)
        {
            Graphics g = e.Graphics;
            Rectangle rect = e.ArrowRectangle;
            ControlState controlState = e.ControlState;
            ArrowDirection direction = e.ArrowDirection;
            bool bHorizontal = e.Orientation == Orientation.Horizontal;
            bool bEnabled = e.Enabled;

            Color backColor = BackNormal;
            Color baseColor = Base;
            Color borderColor = Border;
            Color innerBorderColor = InnerBorder;
            Color foreColor = Fore;

            bool changeColor = false;

            if (bEnabled)
            {
                switch (controlState)
                {
                    case ControlState.Hover:
                        baseColor = BackHover;
                        break;
                    case ControlState.Pressed:
                        baseColor = BackPressed;
                        changeColor = true;
                        break;
                    default:
                        baseColor = Base;
                        break;
                }
            }
            else
            {
                backColor = GetGray(backColor);
                baseColor = GetGray(Base);
                borderColor = GetGray(borderColor);
                foreColor = GetGray(foreColor);
            }

            using (SmoothingModeGraphics sg = new SmoothingModeGraphics(g))
            {
                ControlPaintEx.DrawScrollBarArraw(
                    g,
                    rect,
                    baseColor,
                    backColor,
                    borderColor,
                    innerBorderColor,
                    foreColor,
                    e.Orientation,
                    direction,
                    changeColor);
            }
        }
Example #2
0
        protected internal virtual void OnPaintScrollBarThumb(
            PaintScrollBarThumbEventArgs e)
        {
            bool bEnabled = e.Enabled;
            if (!bEnabled)
            {
                return;
            }

            Graphics g = e.Graphics;
            Rectangle rect = e.ThumbRectangle;
            ControlState controlState = e.ControlState;

            Color backColor = BackNormal;
            Color baseColor = Base;
            Color borderColor = Border;
            Color innerBorderColor = InnerBorder;

            bool changeColor = false;

            switch (controlState)
            {
                case ControlState.Hover:
                    baseColor = BackHover;
                    break;
                case ControlState.Pressed:
                    baseColor = BackPressed;
                    changeColor = true;
                    break;
                default:
                    baseColor = Base;
                    break;
            }

            using (SmoothingModeGraphics sg = new SmoothingModeGraphics(g))
            {
                ControlPaintEx.DrawScrollBarThumb(
                    g,
                    rect,
                    baseColor,
                    backColor,
                    borderColor,
                    innerBorderColor,
                    e.Orientation,
                    changeColor);
            }
        }
 private void DrawProgressBar(IntPtr hWnd)
 {
     Graphics g = this._bufferedGraphics.Graphics;
     g.Clear(Color.Transparent);
     Rectangle rect = new Rectangle(System.Drawing.Point.Empty, base.Size);
     bool bBlock = (this.Style != ProgressBarStyle.Marquee) || base.DesignMode;
     float basePosition = bBlock ? 0.3f : 0.45f;
     SmoothingModeGraphics sg = new SmoothingModeGraphics(g);
     if (this.Back != null)
     {
         Bitmap btm = new Bitmap(this.Back, base.Size);
         UpdateForm.CreateControlRegion(this, btm, 200);
         g.DrawImage(this.Back, rect);
     }
     else
     {
         RenderHelper.RenderBackgroundInternal(g, rect, this.TrackBack, this.Border, this.InnerBorder, this.RadiusStyle, this.Radius, basePosition, true, this.Glass, LinearGradientMode.Vertical);
     }
     Rectangle trackRect = rect;
     trackRect.Inflate(-this.BarMinusSize.Width, -this.BarMinusSize.Height);
     if (!bBlock)
     {
         GraphicsState state = g.Save();
         g.SetClip(trackRect);
         trackRect.X = this._trackX;
         trackRect.Width = 100;
         using (GraphicsPath path = new GraphicsPath())
         {
             path.AddEllipse(trackRect);
             g.SetClip(path, CombineMode.Intersect);
         }
         RenderHelper.RenderBackgroundInternal(g, trackRect, this.TrackFore, this.Border, this.InnerBorder, RoundStyle.None, 8, basePosition, false, this.BarGlass, LinearGradientMode.Vertical);
         using (LinearGradientBrush brush = new LinearGradientBrush(trackRect, this.InnerBorder, Color.Transparent, 0f))
         {
             Blend blend = new Blend();
             float[] CS_0_0002 = new float[3];
             CS_0_0002[1] = 1f;
             blend.Factors = CS_0_0002;
             float[] CS_0_0003 = new float[3];
             CS_0_0003[1] = 0.5f;
             CS_0_0003[2] = 1f;
             blend.Positions = CS_0_0003;
             brush.Blend = blend;
             g.FillRectangle(brush, trackRect);
         }
         g.Restore(state);
         goto Label_02F1;
     }
     trackRect.Width = (int) ((((double) base.Value) / ((double) (base.Maximum - base.Minimum))) * trackRect.Width);
     if (this.BarBack != null)
     {
         if (this.BarBackStyle == BackStyle.Tile)
         {
             using (TextureBrush Txbrus = new TextureBrush(this.BarBack))
             {
                 Txbrus.WrapMode = WrapMode.Tile;
                 g.FillRectangle(Txbrus, trackRect);
                 goto Label_019B;
             }
         }
         Bitmap btm = new Bitmap(this.BarBack, base.Size);
         g.DrawImageUnscaledAndClipped(btm, trackRect);
     }
     else
     {
         RenderHelper.RenderBackgroundInternal(g, trackRect, this.TrackFore, this.Border, this.InnerBorder, this.BarRadiusStyle, this.BarRadius, basePosition, false, this.BarGlass, LinearGradientMode.Vertical);
     }
     Label_019B:
     if (!string.IsNullOrEmpty(this._formatString) && this.TxtShow)
     {
         TextRenderer.DrawText(g, string.Format(this._formatString, ((double) base.Value) / ((double) (base.Maximum - base.Minimum))), base.Font, rect, base.ForeColor, TextFormatFlags.WordEllipsis | TextFormatFlags.SingleLine | TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter);
     }
     Label_02F1:
     sg.Dispose();
     IntPtr hDC = CCWin.Win32.NativeMethods.GetDC(hWnd);
     this._bufferedGraphics.Render(hDC);
     CCWin.Win32.NativeMethods.ReleaseDC(hWnd, hDC);
 }
        private void DrawProgressBar(IntPtr hWnd)
        {
            Graphics g = _bufferedGraphics.Graphics;
            g.Clear(Color.Transparent);
            Rectangle rect = new Rectangle(Point.Empty, Size);

            bool bBlock = Style != ProgressBarStyle.Marquee || base.DesignMode;
            float basePosition = bBlock ? .30f : .45f;

            SmoothingModeGraphics sg = new SmoothingModeGraphics(g);
            if (Back != null)
            {
                Bitmap btm = new Bitmap(Back, this.Size);
                if (Create)
                {
                    SkinTools.CreateControlRegion(this, btm, 200);
                }
                g.DrawImage(Back, rect);
            }
            else
            {
                RenderHelper.RenderBackgroundInternal(
                    g,
                    rect,
                    TrackBack,
                    Border,
                    InnerBorder,
                    RadiusStyle,
                    Radius,
                    basePosition,
                    true,
                    Glass,
                    LinearGradientMode.Vertical);
            }
            Rectangle trackRect = rect;
            trackRect.Inflate(-BarMinusSize.Width, -BarMinusSize.Height);
            if (bBlock)
            {
                trackRect.Width = (int)(((double)Value / (Maximum - Minimum)) * trackRect.Width);
                if (BarBack != null)
                {
                    if (BarBackStyle == BackStyle.Tile)
                    {
                        using (TextureBrush Txbrus = new TextureBrush(BarBack))
                        {
                            Txbrus.WrapMode = System.Drawing.Drawing2D.WrapMode.Tile;
                            g.FillRectangle(Txbrus, trackRect);
                        }

                    }
                    else
                    {
                        Bitmap btm = new Bitmap(BarBack, this.Size);
                        g.DrawImageUnscaledAndClipped(btm, trackRect);
                    }
                }
                else
                {
                    RenderHelper.RenderBackgroundInternal(
                        g,
                        trackRect,
                        TrackFore,
                        Border,
                        InnerBorder,
                        BarRadiusStyle,
                        BarRadius,
                        basePosition,
                        false,
                        BarGlass,
                        LinearGradientMode.Vertical);
                }
                if (!string.IsNullOrEmpty(_formatString) && TextFormat == TxtFormat.Percentage)
                {
                    TextRenderer.DrawText(
                        g,
                        string.Format(_formatString, (double)Value / (Maximum - Minimum)),
                        base.Font,
                        rect,
                        base.ForeColor,
                        TextFormatFlags.VerticalCenter |
                        TextFormatFlags.HorizontalCenter |
                        TextFormatFlags.SingleLine |
                        TextFormatFlags.WordEllipsis);
                }
                else if (TextFormat == TxtFormat.Proportion)
                {
                    TextRenderer.DrawText(
                            g,
                            Value + "/" + Maximum,
                            base.Font,
                            rect,
                            base.ForeColor,
                            TextFormatFlags.VerticalCenter |
                            TextFormatFlags.HorizontalCenter |
                            TextFormatFlags.SingleLine |
                            TextFormatFlags.WordEllipsis);
                }
            }
            else
            {
                GraphicsState state = g.Save();

                g.SetClip(trackRect);

                trackRect.X = _trackX;
                trackRect.Width = MarqueeWidth;

                using (GraphicsPath path = new GraphicsPath())
                {
                    path.AddEllipse(trackRect);
                    g.SetClip(path, CombineMode.Intersect);
                }

                RenderHelper.RenderBackgroundInternal(
                    g,
                    trackRect,
                    TrackFore,
                    Border,
                    InnerBorder,
                    RoundStyle.None,
                    8,
                    basePosition,
                    false,
                    BarGlass,
                    LinearGradientMode.Vertical);

                using (LinearGradientBrush brush = new LinearGradientBrush(
                    trackRect, InnerBorder, Color.Transparent, 0f))
                {
                    Blend blend = new Blend();
                    blend.Factors = new float[] { 0f, 1f, 0f };
                    blend.Positions = new float[] { 0f, .5f, 1f };
                    brush.Blend = blend;

                    g.FillRectangle(brush, trackRect);
                }

                g.Restore(state);
            }

            sg.Dispose();

            IntPtr hDC = NativeMethods.GetDC(hWnd);
            _bufferedGraphics.Render(hDC);
            NativeMethods.ReleaseDC(hWnd, hDC);
        }
 protected override void OnRenderButtonBackground(ToolStripItemRenderEventArgs e)
 {
     ToolStrip toolStrip = e.ToolStrip;
     ToolStripButton item = e.Item as ToolStripButton;
     Graphics g = e.Graphics;
     if (item == null)
     {
         return;
     }
     LinearGradientMode mode = (toolStrip.Orientation == Orientation.Horizontal) ? LinearGradientMode.Vertical : LinearGradientMode.Horizontal;
     SmoothingModeGraphics sg = new SmoothingModeGraphics(g);
     Rectangle bounds = new Rectangle(Point.Empty, item.Size);
     if (item.BackgroundImage != null)
     {
         Rectangle clipRect = item.Selected ? item.ContentRectangle : bounds;
         CCWin.SkinControl.ControlPaintEx.DrawBackgroundImage(g, item.BackgroundImage, this.ColorTable.Back, item.BackgroundImageLayout, bounds, clipRect);
     }
     Bitmap btm = null;
     Color color = Color.Red;
     if (item.CheckState == CheckState.Unchecked)
     {
         if (item.Selected)
         {
              btm = item.Pressed ? ((Bitmap) this.ColorTable.BaseItemDown) : ((Bitmap) this.ColorTable.BaseItemMouse);
             if (btm != null)
             {
                 CCWin.ImageDrawRect.DrawRect(g, btm, bounds, Rectangle.FromLTRB(this.ColorTable.BackRectangle.X, this.ColorTable.BackRectangle.Y, this.ColorTable.BackRectangle.Width, this.ColorTable.BackRectangle.Height), 1, 1);
             }
             else
             {
                 color = this.ColorTable.BaseItemHover;
                 if (item.Pressed)
                 {
                     color = this.ColorTable.BaseItemPressed;
                 }
                 RenderHelperStrip.RenderBackgroundInternal(g, bounds, color, this.ColorTable.BaseItemBorder, this.ColorTable.Back, this.ColorTable.BaseItemRadiusStyle, this.ColorTable.BaseItemRadius, this.ColorTable.BaseItemBorderShow, this.ColorTable.BaseItemAnamorphosis, mode);
             }
             goto Label_0302;
         }
         if (!(toolStrip is ToolStripOverflow))
         {
             goto Label_0302;
         }
         using (Brush brush = new SolidBrush(this.ColorTable.ItemHover))
         {
             g.FillRectangle(brush, bounds);
             goto Label_0302;
         }
     }
      btm = (Bitmap)this.ColorTable.BaseItemMouse;
      color = ControlPaint.Light(this.ColorTable.ItemHover);
     if (item.Selected)
     {
         color = this.ColorTable.ItemHover;
         btm = (Bitmap) this.ColorTable.BaseItemMouse;
     }
     if (item.Pressed)
     {
         color = this.ColorTable.ItemPressed;
         btm = (Bitmap) this.ColorTable.BaseItemDown;
     }
     if (btm == null)
     {
         RenderHelperStrip.RenderBackgroundInternal(g, bounds, color, this.ColorTable.BaseItemBorder, this.ColorTable.Back, this.ColorTable.BaseItemRadiusStyle, this.ColorTable.BaseItemRadius, this.ColorTable.BaseItemBorderShow, this.ColorTable.BaseItemAnamorphosis, mode);
     }
     else
     {
         CCWin.ImageDrawRect.DrawRect(g, btm, bounds, Rectangle.FromLTRB(this.ColorTable.BackRectangle.X, this.ColorTable.BackRectangle.Y, this.ColorTable.BackRectangle.Width, this.ColorTable.BackRectangle.Height), 1, 1);
     }
     Label_0302:
     sg.Dispose();
 }
 protected override void OnRenderDropDownButtonBackground(ToolStripItemRenderEventArgs e)
 {
     ToolStrip toolStrip = e.ToolStrip;
     ToolStripDropDownItem item = e.Item as ToolStripDropDownItem;
     if (item == null)
     {
         return;
     }
     LinearGradientMode mode = (toolStrip.Orientation == Orientation.Horizontal) ? LinearGradientMode.Vertical : LinearGradientMode.Horizontal;
     Graphics g = e.Graphics;
     SmoothingModeGraphics sg = new SmoothingModeGraphics(g);
     Rectangle bounds = new Rectangle(Point.Empty, item.Size);
     if (item.Pressed && item.HasDropDownItems)
     {
         if (this.ColorTable.BaseItemDown != null)
         {
             CCWin.ImageDrawRect.DrawRect(g, (Bitmap) this.ColorTable.BaseItemDown, bounds, Rectangle.FromLTRB(this.ColorTable.BackRectangle.X, this.ColorTable.BackRectangle.Y, this.ColorTable.BackRectangle.Width, this.ColorTable.BackRectangle.Height), 1, 1);
         }
         else
         {
             RenderHelperStrip.RenderBackgroundInternal(g, bounds, this.ColorTable.BaseItemPressed, this.ColorTable.BaseItemBorder, this.ColorTable.Back, this.ColorTable.BaseItemRadiusStyle, this.ColorTable.BaseItemRadius, this.ColorTable.BaseItemBorderShow, this.ColorTable.BaseItemAnamorphosis, mode);
         }
     }
     else if (item.Selected)
     {
         if (this.ColorTable.BaseItemDown != null)
         {
             CCWin.ImageDrawRect.DrawRect(g, (Bitmap) this.ColorTable.BaseItemMouse, bounds, Rectangle.FromLTRB(this.ColorTable.BackRectangle.X, this.ColorTable.BackRectangle.Y, this.ColorTable.BackRectangle.Width, this.ColorTable.BackRectangle.Height), 1, 1);
         }
         else
         {
             RenderHelperStrip.RenderBackgroundInternal(g, bounds, this.ColorTable.BaseItemHover, this.ColorTable.BaseItemBorder, this.ColorTable.Back, this.ColorTable.BaseItemRadiusStyle, this.ColorTable.BaseItemRadius, this.ColorTable.BaseItemBorderShow, this.ColorTable.BaseItemAnamorphosis, mode);
         }
     }
     else
     {
         if (toolStrip is ToolStripOverflow)
         {
             using (Brush brush = new SolidBrush(this.ColorTable.Back))
             {
                 g.FillRectangle(brush, bounds);
                 goto Label_0256;
             }
         }
         base.OnRenderDropDownButtonBackground(e);
     }
     Label_0256:
     sg.Dispose();
 }
        protected override void OnRenderOverflowButtonBackground(
            ToolStripItemRenderEventArgs e)
        {
            ToolStripItem item = e.Item;
            ToolStrip toolStrip = e.ToolStrip;
            Graphics g = e.Graphics;
            bool rightToLeft = item.RightToLeft == RightToLeft.Yes;

            SmoothingModeGraphics sg = new SmoothingModeGraphics(g);

            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 = toolStrip.Enabled ?
                ColorTable.Fore : SystemColors.ControlDark;

            using (Brush brush = new SolidBrush(arrowColor))
            {
                RenderHelperStrip.RenderArrowInternal(g, empty, direction, brush);
            }

            if (bHorizontal)
            {
                using (Pen pen = new Pen(arrowColor))
                {
                    g.DrawLine(
                        pen,
                        empty.Right - 8,
                        empty.Y - 2,
                        empty.Right - 2,
                        empty.Y - 2);
                    g.DrawLine(
                        pen,
                        empty.Right - 8,
                        empty.Y - 1,
                        empty.Right - 2,
                        empty.Y - 1);
                }
            }
            else
            {
                using (Pen pen = new Pen(arrowColor))
                {
                    g.DrawLine(
                        pen,
                        empty.X,
                        empty.Y,
                        empty.X,
                        empty.Bottom - 1);
                    g.DrawLine(
                        pen,
                        empty.X,
                        empty.Y + 1,
                        empty.X,
                        empty.Bottom);
                }
            }
        }
        protected override void OnRenderSplitButtonBackground(
            ToolStripItemRenderEventArgs e)
        {
            ToolStrip toolStrip = e.ToolStrip;
            ToolStripSplitButton item = e.Item as ToolStripSplitButton;

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

                Color arrowColor = toolStrip.Enabled ?
                    ColorTable.Fore : SystemColors.ControlDark;

                if (item.BackgroundImage != null)
                {
                    Rectangle clipRect = item.Selected ? item.ContentRectangle : bounds;
                    ControlPaintEx.DrawBackgroundImage(
                        g,
                        item.BackgroundImage,
                        ColorTable.Back,
                        item.BackgroundImageLayout,
                        bounds,
                        clipRect);
                }

                if (item.ButtonPressed)
                {
                    if (ColorTable.BaseItemDown != null)
                    {
                        ImageDrawRect.DrawRect(g, (Bitmap)ColorTable.BaseItemDown, bounds, Rectangle.FromLTRB(ColorTable.BackRectangle.X, ColorTable.BackRectangle.Y, ColorTable.BackRectangle.Width, ColorTable.BackRectangle.Height), 1, 1);
                    }
                    else
                    {
                        Rectangle buttonBounds = item.ButtonBounds;
                        Padding padding = (item.RightToLeft == RightToLeft.Yes) ?
                            new Padding(0, 1, 1, 1) : new Padding(1, 1, 0, 1);
                        buttonBounds = LayoutUtils.DeflateRect(buttonBounds, padding);
                        RenderHelperStrip.RenderBackgroundInternal2(
                           g,
                           bounds,
                           ColorTable.BaseItemHover,
                           ColorTable.BaseItemBorder,
                           ColorTable.Back,
                           ColorTable.BaseItemRadiusStyle,
                           ColorTable.BaseItemRadius,
                           ColorTable.BaseItemBorderShow,
                           ColorTable.BaseItemAnamorphosis,
                           mode);

                        buttonBounds.Inflate(-1, -1);
                        g.SetClip(buttonBounds);
                        RenderHelperStrip.RenderBackgroundInternal1(
                           g,
                           buttonBounds,
                           ColorTable.BaseItemPressed,
                           ColorTable.BaseItemBorder,
                           ColorTable.Back,
                           RoundStyle.Left,
                           false,
                           ColorTable.ItemAnamorphosis,
                           mode);
                        g.ResetClip();

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

                if (item.Pressed || item.DropDownButtonPressed)
                {
                    if (ColorTable.BaseItemDown != null)
                    {
                        ImageDrawRect.DrawRect(g, (Bitmap)ColorTable.BaseItemDown, bounds, Rectangle.FromLTRB(ColorTable.BackRectangle.X, ColorTable.BackRectangle.Y, ColorTable.BackRectangle.Width, ColorTable.BackRectangle.Height), 1, 1);
                    }
                    else
                    {
                        RenderHelperStrip.RenderBackgroundInternal2(
                          g,
                          bounds,
                          ColorTable.BaseItemPressed,
                          ColorTable.BaseItemBorder,
                          ColorTable.Back,
                          ColorTable.BaseItemRadiusStyle,
                          ColorTable.BaseItemRadius,
                          ColorTable.BaseItemBorderShow,
                          ColorTable.BaseItemAnamorphosis,
                          mode);
                    }
                    base.DrawArrow(
                       new ToolStripArrowRenderEventArgs(
                       g,
                       item,
                       item.DropDownButtonBounds,
                       arrowColor,
                       ArrowDirection.Down));
                    return;
                }

                if (item.Selected)
                {
                    if (ColorTable.BaseItemMouse != null)
                    {
                        ImageDrawRect.DrawRect(g, (Bitmap)ColorTable.BaseItemMouse, bounds, Rectangle.FromLTRB(ColorTable.BackRectangle.X, ColorTable.BackRectangle.Y, ColorTable.BackRectangle.Width, ColorTable.BackRectangle.Height), 1, 1);
                    }
                    else
                    {
                        RenderHelperStrip.RenderBackgroundInternal2(
                          g,
                          bounds,
                          ColorTable.BaseItemHover,
                          ColorTable.BaseItemBorder,
                          ColorTable.Back,
                          ColorTable.BaseItemRadiusStyle,
                          ColorTable.BaseItemRadius,
                          ColorTable.BaseItemBorderShow,
                          ColorTable.BaseItemAnamorphosis,
                          mode);
                        using (Pen pen = new Pen(ColorTable.BaseItemSplitter))
                        {
                            g.DrawLine(
                               pen,
                               item.SplitterBounds.Left,
                               item.SplitterBounds.Top,
                               item.SplitterBounds.Left,
                               item.SplitterBounds.Bottom);
                        }
                    }
                    base.DrawArrow(
                        new ToolStripArrowRenderEventArgs(
                        g,
                        item,
                        item.DropDownButtonBounds,
                        arrowColor,
                        ArrowDirection.Down));
                    return;
                }

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

            base.OnRenderSplitButtonBackground(e);
        }
        protected override void OnRenderImageMargin(
            ToolStripRenderEventArgs e)
        {
            ToolStrip toolStrip = e.ToolStrip;
            Graphics g = e.Graphics;
            Rectangle bounds = e.AffectedBounds;

            if (toolStrip is ToolStripDropDown)
            {
                bool bRightToLeft = toolStrip.RightToLeft == RightToLeft.Yes;

                Rectangle imageBackRect = bounds;
                Rectangle logoRect = bounds;
                if (bRightToLeft)
                {
                    logoRect.X -= 2;
                    imageBackRect.X = logoRect.X;
                }
                else
                {
                    logoRect.X += 2;
                    imageBackRect.X = logoRect.Right;
                }
                logoRect.Y += 1;
                logoRect.Height -= 2;

                using (LinearGradientBrush brush = new LinearGradientBrush(
                    logoRect,
                    ColorTable.TitleColor,
                    ColorTable.Back,
                    90f))
                {
                    Blend blend = new Blend();
                    blend.Positions = new float[] { 0f, .2f, 1f };
                    blend.Factors = new float[] { 0f, 0.1f, .9f };
                    brush.Blend = blend;
                    logoRect.Y += 1;
                    logoRect.Height -= 2;
                    using (GraphicsPath path =
                        GraphicsPathHelper.CreatePath(logoRect, ColorTable.TitleRadius, ColorTable.TitleRadiusStyle, false))
                    {
                        using (SmoothingModeGraphics sg = new SmoothingModeGraphics(g))
                        {
                            if (ColorTable.TitleAnamorphosis)
                            {
                                g.FillPath(brush, path);
                            }
                            else
                            {
                                SolidBrush br = new SolidBrush(ColorTable.TitleColor);
                                g.FillPath(br, path);
                            }
                        }
                    }
                }
            }
            else
            {
                base.OnRenderImageMargin(e);
            }
        }
        protected override void OnRenderItemCheck(
            ToolStripItemImageRenderEventArgs e)
        {
            ToolStrip toolStrip = e.ToolStrip;
            Graphics g = e.Graphics;

            if (toolStrip is ToolStripDropDown &&
               e.Item is ToolStripMenuItem)
            {
                Rectangle rect = e.ImageRectangle;

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

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

                using (SmoothingModeGraphics sg = new SmoothingModeGraphics(g))
                {
                    using (GraphicsPath path = new GraphicsPath())
                    {
                        path.AddRectangle(rect);
                        using (PathGradientBrush brush = new PathGradientBrush(path))
                        {
                            brush.CenterColor = Color.White;
                            brush.SurroundColors = new Color[] { ControlPaint.Light(ColorTable.Back) };
                            Blend blend = new Blend();
                            blend.Positions = new float[] { 0f, 0.3f, 1f };
                            blend.Factors = new float[] { 0f, 0.5f, 1f };
                            brush.Blend = blend;
                            g.FillRectangle(brush, rect);
                        }
                    }

                    using (Pen pen = new Pen(ControlPaint.Light(ColorTable.Back)))
                    {
                        g.DrawRectangle(pen, rect);
                    }

                    ControlPaintEx.DrawCheckedFlag(g, rect, ColorTable.Fore);
                }
            }
            else
            {
                base.OnRenderItemCheck(e);
            }
        }
        protected override void OnRenderButtonBackground(
            ToolStripItemRenderEventArgs e)
        {
            ToolStrip toolStrip = e.ToolStrip;
            ToolStripButton item = e.Item as ToolStripButton;
            Graphics g = e.Graphics;

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

                if (item.BackgroundImage != null)
                {
                    Rectangle clipRect = item.Selected ? item.ContentRectangle : bounds;
                    ControlPaintEx.DrawBackgroundImage(
                        g,
                        item.BackgroundImage,
                        ColorTable.Back,
                        item.BackgroundImageLayout,
                        bounds,
                        clipRect);
                }

                if (item.CheckState == CheckState.Unchecked)
                {
                    if (item.Selected)
                    {
                        Bitmap btm = item.Pressed ? (Bitmap)ColorTable.BaseItemDown : (Bitmap)ColorTable.BaseItemMouse;
                        if (btm != null)
                        {
                            ImageDrawRect.DrawRect(g, btm, bounds, Rectangle.FromLTRB(ColorTable.BackRectangle.X, ColorTable.BackRectangle.Y, ColorTable.BackRectangle.Width, ColorTable.BackRectangle.Height), 1, 1);
                        }
                        else
                        {
                            Color color = ColorTable.BaseItemHover;
                            if (item.Pressed)
                            {
                                color = ColorTable.BaseItemPressed;
                            }
                            RenderHelperStrip.RenderBackgroundInternal2(
                                g,
                                bounds,
                                color,
                                ColorTable.BaseItemBorder,
                                ColorTable.Back,
                                ColorTable.BaseItemRadiusStyle,
                                ColorTable.BaseItemRadius,
                                ColorTable.BaseItemBorderShow,
                                ColorTable.BaseItemAnamorphosis,
                                mode);
                        }
                    }
                    else
                    {
                        if (toolStrip is ToolStripOverflow)
                        {
                            using (Brush brush = new SolidBrush(ColorTable.ItemHover))
                            {
                                g.FillRectangle(brush, bounds);
                            }
                        }
                    }
                }
                else
                {

                    Bitmap btm = (Bitmap)ColorTable.BaseItemMouse;
                    Color color = ControlPaint.Light(ColorTable.ItemHover);
                    if (item.Selected)
                    {
                        color = ColorTable.ItemHover;
                        btm = (Bitmap)ColorTable.BaseItemMouse;
                    }
                    if (item.Pressed)
                    {
                        color = ColorTable.ItemPressed;
                        btm = (Bitmap)ColorTable.BaseItemDown;
                    }

                    if (btm == null)
                    {
                        RenderHelperStrip.RenderBackgroundInternal2(
                            g,
                            bounds,
                            color,
                            ColorTable.BaseItemBorder,
                            ColorTable.Back,
                            ColorTable.BaseItemRadiusStyle,
                            ColorTable.BaseItemRadius,
                            ColorTable.BaseItemBorderShow,
                            ColorTable.BaseItemAnamorphosis,
                            mode);
                    }
                    else
                    {
                        ImageDrawRect.DrawRect(g, btm, bounds, Rectangle.FromLTRB(ColorTable.BackRectangle.X, ColorTable.BackRectangle.Y, ColorTable.BackRectangle.Width, ColorTable.BackRectangle.Height), 1, 1);
                    }
                }
                sg.Dispose();
            }
        }
 private void DrawSolidStatusGrip(
     Graphics g,
     Rectangle bounds,
     Color innerColor,
     Color outerColor
     )
 {
     using (SmoothingModeGraphics sg = new SmoothingModeGraphics(g))
     {
         using (Pen innerPen = new Pen(innerColor),
             outerPen = new Pen(outerColor))
         {
             //outer line
             g.DrawLine(
                 outerPen,
                 new Point(bounds.Width - 14, bounds.Height - 6),
                 new Point(bounds.Width - 4, bounds.Height - 16));
             g.DrawLine(
                 innerPen,
                 new Point(bounds.Width - 13, bounds.Height - 6),
                 new Point(bounds.Width - 4, bounds.Height - 15));
             // line
             g.DrawLine(
                 outerPen,
                 new Point(bounds.Width - 12, bounds.Height - 6),
                 new Point(bounds.Width - 4, bounds.Height - 14));
             g.DrawLine(
                 innerPen,
                 new Point(bounds.Width - 11, bounds.Height - 6),
                 new Point(bounds.Width - 4, bounds.Height - 13));
             // line
             g.DrawLine(
                 outerPen,
                 new Point(bounds.Width - 10, bounds.Height - 6),
                 new Point(bounds.Width - 4, bounds.Height - 12));
             g.DrawLine(
                 innerPen,
                 new Point(bounds.Width - 9, bounds.Height - 6),
                 new Point(bounds.Width - 4, bounds.Height - 11));
             // line
             g.DrawLine(
                 outerPen,
                 new Point(bounds.Width - 8, bounds.Height - 6),
                 new Point(bounds.Width - 4, bounds.Height - 10));
             g.DrawLine(
                 innerPen,
                 new Point(bounds.Width - 7, bounds.Height - 6),
                 new Point(bounds.Width - 4, bounds.Height - 9));
             // inner line
             g.DrawLine(
                 outerPen,
                 new Point(bounds.Width - 6, bounds.Height - 6),
                 new Point(bounds.Width - 4, bounds.Height - 8));
             g.DrawLine(
                 innerPen,
                 new Point(bounds.Width - 5, bounds.Height - 6),
                 new Point(bounds.Width - 4, bounds.Height - 7));
         }
     }
 }
        private void DrawDottedStatusGrip(
            Graphics g,
            Rectangle bounds,
            Color innerColor,
            Color outerColor)
        {
            Rectangle shape = new Rectangle(0, 0, 2, 2);
            shape.X = bounds.Width - 17;
            shape.Y = bounds.Height - 8;
            using (SmoothingModeGraphics sg = new SmoothingModeGraphics(g))
            {
                DrawCircle(g, shape, outerColor, innerColor);

                shape.X = bounds.Width - 12;
                DrawCircle(g, shape, outerColor, innerColor);

                shape.X = bounds.Width - 7;
                DrawCircle(g, shape, outerColor, innerColor);

                shape.Y = bounds.Height - 13;
                DrawCircle(g, shape, outerColor, innerColor);

                shape.Y = bounds.Height - 18;
                DrawCircle(g, shape, outerColor, innerColor);

                shape.Y = bounds.Height - 13;
                shape.X = bounds.Width - 12;
                DrawCircle(g, shape, outerColor, innerColor);
            }
        }
        private void DrawDottedGrip(
            Graphics g,
            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(g))
            {
                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(
                                g,
                                posRect,
                                outerColor,
                                innerColor);
                        }
                        else
                        {
                            int innerWin32Corlor = ColorTranslator.ToWin32(innerColor);
                            int outerWin32Corlor = ColorTranslator.ToWin32(outerColor);

                            hdc = g.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);

                            g.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(g, posRect, outerColor, innerColor);
                        }
                        else
                        {
                            int innerWin32Corlor = ColorTranslator.ToWin32(innerColor);
                            int outerWin32Corlor = ColorTranslator.ToWin32(outerColor);
                            hdc = g.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);

                            g.ReleaseHdc(hdc);
                        }
                    }
                }
            }
        }
        protected override void OnRenderToolStripBorder(
            ToolStripRenderEventArgs e)
        {
            ToolStrip toolStrip = e.ToolStrip;
            Graphics g = e.Graphics;
            Rectangle bounds = e.AffectedBounds;

            if (toolStrip is ToolStripDropDown)
            {
                if (ColorTable.RadiusStyle == RoundStyle.None)
                {
                    bounds.Width--;
                    bounds.Height--;
                }
                using (SmoothingModeGraphics sg = new SmoothingModeGraphics(g))
                {
                    using (GraphicsPath path =
                        GraphicsPathHelper.CreatePath(bounds, ColorTable.BackRadius, ColorTable.RadiusStyle, true))
                    {
                        using (Pen pen = new Pen(ColorTable.DropDownImageSeparator))
                        {
                            path.Widen(pen);
                            g.DrawPath(pen, path);
                        }
                    }
                }

                if (!(toolStrip is ToolStripOverflow))
                {
                    bounds.Inflate(-1, -1);
                    using (GraphicsPath innerPath = GraphicsPathHelper.CreatePath(
                        bounds, ColorTable.BackRadius, ColorTable.RadiusStyle, true))
                    {
                        using (Pen pen = new Pen(ColorTable.Back))
                        {
                            g.DrawPath(pen, innerPath);
                        }
                    }
                }
            }
            else
            {
                base.OnRenderToolStripBorder(e);
            }
        }