コード例 #1
0
        private void DrawScrollBarArrawTest(Graphics g)
        {
            Rectangle rect = new Rectangle(100, 50, 20, 20);

            ControlPaintEx.DrawScrollBarArraw(g, rect, Color.Black, Color.Bisque, Color.BlueViolet,
                                              Color.CadetBlue, Color.Chartreuse, Orientation.Vertical, ArrowDirection.Down, true);
        }
コード例 #2
0
        protected internal virtual void OnPaintScrollBarThumb(TCEventArgs.PaintScrollBarThumbEventArgs e)
        {
            if (e.Enabled)
            {
                Graphics     graphics       = e.Graphics;
                Rectangle    thumbRectangle = e.ThumbRectangle;
                ControlState controlState   = e.ControlState;
                Color        backNormal     = this.BackNormal;
                Color        begin          = this.Base;
                Color        border         = this.Border;
                Color        innerBorder    = this.InnerBorder;
                bool         changeColor    = false;
                switch (controlState)
                {
                case ControlState.Hover:
                    begin = this.BackHover;
                    break;

                case ControlState.Pressed:
                    begin       = this.BackPressed;
                    changeColor = true;
                    break;

                default:
                    begin = this.Base;
                    break;
                }
                using (new SmoothingModeGraphics(graphics))
                {
                    ControlPaintEx.DrawScrollBarThumb(graphics, thumbRectangle, begin, backNormal, border, innerBorder, e.Orientation, changeColor);
                }
            }
        }
コード例 #3
0
        protected internal virtual void OnPaintScrollBarTrack(TCEventArgs.PaintScrollBarTrackEventArgs e)
        {
            Graphics  g = e.Graphics;
            Rectangle trackRectangle = e.TrackRectangle;
            Color     gray           = this.GetGray(this.Base);

            ControlPaintEx.DrawScrollBarTrack(g, trackRectangle, gray, Color.White, e.Orientation);
        }
コード例 #4
0
        protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e)
        {
            ToolStrip toolStrip = e.ToolStrip;
            Graphics  graphics  = e.Graphics;

            if ((toolStrip is ToolStripDropDown) && (e.Item is ToolStripMenuItem))
            {
                Rectangle imageRectangle = e.ImageRectangle;
                if (e.Item.RightToLeft == RightToLeft.Yes)
                {
                    imageRectangle.X -= 2;
                }
                else
                {
                    imageRectangle.X += 2;
                }
                imageRectangle.Width = 13;
                imageRectangle.Y++;
                imageRectangle.Height -= 3;
                using (new SmoothingModeGraphics(graphics))
                {
                    using (GraphicsPath path = new GraphicsPath())
                    {
                        path.AddRectangle(imageRectangle);
                        using (PathGradientBrush brush = new PathGradientBrush(path))
                        {
                            brush.CenterColor    = Color.White;
                            brush.SurroundColors = new Color[] { ControlPaint.Light(this.ColorTable.Back) };
                            Blend   blend    = new Blend();
                            float[] numArray = new float[3];
                            numArray[1]     = 0.3f;
                            numArray[2]     = 1f;
                            blend.Positions = numArray;
                            float[] numArray2 = new float[3];
                            numArray2[1]  = 0.5f;
                            numArray2[2]  = 1f;
                            blend.Factors = numArray2;
                            brush.Blend   = blend;
                            graphics.FillRectangle(brush, imageRectangle);
                        }
                    }
                    using (Pen pen = new Pen(ControlPaint.Light(this.ColorTable.Back)))
                    {
                        graphics.DrawRectangle(pen, imageRectangle);
                    }
                    ControlPaintEx.DrawCheckedFlag(graphics, imageRectangle, this.ColorTable.Fore);
                    return;
                }
            }
            base.OnRenderItemCheck(e);
        }
コード例 #5
0
        protected internal virtual void OnPaintScrollBarArrow(TCEventArgs.PaintScrollBarArrowEventArgs e)
        {
            Graphics       graphics       = e.Graphics;
            Rectangle      arrowRectangle = e.ArrowRectangle;
            ControlState   controlState   = e.ControlState;
            ArrowDirection arrowDirection = e.ArrowDirection;
            Orientation    orientation    = e.Orientation;
            bool           enabled        = e.Enabled;
            Color          backNormal     = this.BackNormal;
            Color          begin          = this.Base;
            Color          border         = this.Border;
            Color          innerBorder    = this.InnerBorder;
            Color          fore           = this.Fore;
            bool           changeColor    = false;

            if (enabled)
            {
                switch (controlState)
                {
                case ControlState.Hover:
                    begin = this.BackHover;
                    goto Label_00BD;

                case ControlState.Pressed:
                    begin       = this.BackPressed;
                    changeColor = true;
                    goto Label_00BD;
                }
                begin = this.Base;
            }
            else
            {
                backNormal = this.GetGray(backNormal);
                begin      = this.GetGray(this.Base);
                border     = this.GetGray(border);
                fore       = this.GetGray(fore);
            }
Label_00BD:
            using (new SmoothingModeGraphics(graphics))
            {
                ControlPaintEx.DrawScrollBarArraw(graphics, arrowRectangle, begin, backNormal, border, innerBorder, fore, e.Orientation, arrowDirection, changeColor);
            }
        }
コード例 #6
0
 internal static void RenderBackgroundInternal(Graphics g, Rectangle rect, Color baseColor, Color borderColor, Color innerBorderColor, RoundStyle style, int roundWidth, float basePosition, bool drawBorder, bool drawGlass, LinearGradientMode mode)
 {
     if (drawBorder)
     {
         rect.Width--;
         rect.Height--;
     }
     if ((rect.Width != 0) && (rect.Height != 0))
     {
         using (LinearGradientBrush brush = new LinearGradientBrush(rect, Color.Transparent, Color.Transparent, mode))
         {
             Color[]    colorArray = new Color[] { GetColor(baseColor, 0, 0x23, 0x18, 9), GetColor(baseColor, 0, 13, 8, 3), baseColor, GetColor(baseColor, 0, 0x23, 0x18, 9) };
             ColorBlend blend      = new ColorBlend();
             float[]    numArray   = new float[4];
             numArray[1]               = basePosition;
             numArray[2]               = basePosition + 0.05f;
             numArray[3]               = 1f;
             blend.Positions           = numArray;
             blend.Colors              = colorArray;
             brush.InterpolationColors = blend;
             if (style != RoundStyle.None)
             {
                 using (GraphicsPath path = GraphicsPathHelper.CreatePath(rect, roundWidth, style, false))
                 {
                     g.FillPath(brush, path);
                 }
                 if (drawGlass)
                 {
                     if (baseColor.A > 80)
                     {
                         Rectangle rectangle = rect;
                         if (mode == LinearGradientMode.Vertical)
                         {
                             rectangle.Height = (int)(rectangle.Height * basePosition);
                         }
                         else
                         {
                             rectangle.Width = (int)(rect.Width * basePosition);
                         }
                         using (GraphicsPath path2 = GraphicsPathHelper.CreatePath(rectangle, roundWidth, RoundStyle.Top, false))
                         {
                             using (SolidBrush brush2 = new SolidBrush(Color.FromArgb(0x80, 0xff, 0xff, 0xff)))
                             {
                                 g.FillPath(brush2, path2);
                             }
                         }
                     }
                     RectangleF glassRect = rect;
                     if (mode == LinearGradientMode.Vertical)
                     {
                         glassRect.Y      = rect.Y + (rect.Height * basePosition);
                         glassRect.Height = (rect.Height - (rect.Height * basePosition)) * 2f;
                     }
                     else
                     {
                         glassRect.X     = rect.X + (rect.Width * basePosition);
                         glassRect.Width = (rect.Width - (rect.Width * basePosition)) * 2f;
                     }
                     ControlPaintEx.DrawGlass(g, glassRect, 170, 0);
                 }
                 if (!drawBorder)
                 {
                     return;
                 }
                 using (GraphicsPath path3 = GraphicsPathHelper.CreatePath(rect, roundWidth, style, false))
                 {
                     using (Pen pen = new Pen(borderColor))
                     {
                         g.DrawPath(pen, path3);
                     }
                 }
                 rect.Inflate(-1, -1);
                 using (GraphicsPath path4 = GraphicsPathHelper.CreatePath(rect, roundWidth, style, false))
                 {
                     using (Pen pen2 = new Pen(innerBorderColor))
                     {
                         g.DrawPath(pen2, path4);
                     }
                     return;
                 }
             }
             g.FillRectangle(brush, rect);
             if (drawGlass)
             {
                 if (baseColor.A > 80)
                 {
                     Rectangle rectangle2 = rect;
                     if (mode == LinearGradientMode.Vertical)
                     {
                         rectangle2.Height = (int)(rectangle2.Height * basePosition);
                     }
                     else
                     {
                         rectangle2.Width = (int)(rect.Width * basePosition);
                     }
                     using (SolidBrush brush3 = new SolidBrush(Color.FromArgb(0x80, 0xff, 0xff, 0xff)))
                     {
                         g.FillRectangle(brush3, rectangle2);
                     }
                 }
                 RectangleF ef2 = rect;
                 if (mode == LinearGradientMode.Vertical)
                 {
                     ef2.Y      = rect.Y + (rect.Height * basePosition);
                     ef2.Height = (rect.Height - (rect.Height * basePosition)) * 2f;
                 }
                 else
                 {
                     ef2.X     = rect.X + (rect.Width * basePosition);
                     ef2.Width = (rect.Width - (rect.Width * basePosition)) * 2f;
                 }
                 ControlPaintEx.DrawGlass(g, ef2, 200, 0);
             }
             if (drawBorder)
             {
                 using (Pen pen3 = new Pen(borderColor))
                 {
                     g.DrawRectangle(pen3, rect);
                 }
                 rect.Inflate(-1, -1);
                 using (Pen pen4 = new Pen(innerBorderColor))
                 {
                     g.DrawRectangle(pen4, rect);
                 }
             }
         }
     }
 }
コード例 #7
0
        private void DrawScrollBarSizerTest(Graphics g)
        {
            Rectangle rect = new Rectangle(100, 70, 20, 50);

            ControlPaintEx.DrawScrollBarSizer(g, rect, Color.Black, Color.Bisque);
        }
コード例 #8
0
        private void DrawCheckedFlagTest(Graphics g)
        {
            Rectangle rect = new Rectangle(50, 50, 20, 20);

            ControlPaintEx.DrawCheckedFlag(g, rect, Color.Black);
        }
コード例 #9
0
        protected override void OnRenderSplitButtonBackground(ToolStripItemRenderEventArgs e)
        {
            ToolStrip            toolStrip = e.ToolStrip;
            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);
                new SmoothingModeGraphics(graphics);
                Color arrowColor = toolStrip.Enabled ? this.ColorTable.Fore : SystemColors.ControlDark;
                if (item.BackgroundImage != null)
                {
                    Rectangle clipRect = item.Selected ? item.ContentRectangle : bounds;
                    ControlPaintEx.DrawBackgroundImage(graphics, item.BackgroundImage, this.ColorTable.Back, item.BackgroundImageLayout, bounds, clipRect);
                }
                if (item.ButtonPressed)
                {
                    if (this.ColorTable.BaseItemDown != null)
                    {
                        ImageDrawRect.DrawRect(graphics, (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
                    {
                        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);
                        RenderHelper.RenderBackgroundInternal(graphics, bounds, this.ColorTable.BaseItemHover, this.ColorTable.BaseItemBorder, this.ColorTable.Back, this.ColorTable.BaseItemRadiusStyle, this.ColorTable.BaseItemRadius, this.ColorTable.BaseItemBorderShow, this.ColorTable.BaseItemAnamorphosis, mode);
                        buttonBounds.Inflate(-1, -1);
                        graphics.SetClip(buttonBounds);
                        RenderHelper.RenderBackgroundInternal(graphics, buttonBounds, this.ColorTable.BaseItemPressed, this.ColorTable.BaseItemBorder, this.ColorTable.Back, RoundStyle.Left, false, true, mode);
                        graphics.ResetClip();
                        using (Pen pen = new Pen(this.ColorTable.BaseItemSplitter))
                        {
                            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));
                }
                else if (item.Pressed || item.DropDownButtonPressed)
                {
                    if (this.ColorTable.BaseItemDown != null)
                    {
                        ImageDrawRect.DrawRect(graphics, (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
                    {
                        RenderHelper.RenderBackgroundInternal(graphics, bounds, this.ColorTable.BaseItemPressed, this.ColorTable.BaseItemBorder, this.ColorTable.Back, this.ColorTable.BaseItemRadiusStyle, this.ColorTable.BaseItemRadius, this.ColorTable.BaseItemBorderShow, this.ColorTable.BaseItemAnamorphosis, mode);
                    }
                    base.DrawArrow(new ToolStripArrowRenderEventArgs(graphics, item, item.DropDownButtonBounds, arrowColor, ArrowDirection.Down));
                }
                else if (item.Selected)
                {
                    if (this.ColorTable.BaseItemMouse != null)
                    {
                        ImageDrawRect.DrawRect(graphics, (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
                    {
                        RenderHelper.RenderBackgroundInternal(graphics, bounds, this.ColorTable.BaseItemHover, this.ColorTable.BaseItemBorder, this.ColorTable.Back, this.ColorTable.BaseItemRadiusStyle, this.ColorTable.BaseItemRadius, this.ColorTable.BaseItemBorderShow, this.ColorTable.BaseItemAnamorphosis, mode);
                        using (Pen pen2 = new Pen(this.ColorTable.BaseItemSplitter))
                        {
                            graphics.DrawLine(pen2, item.SplitterBounds.Left, item.SplitterBounds.Top, item.SplitterBounds.Left, item.SplitterBounds.Bottom);
                        }
                    }
                    base.DrawArrow(new ToolStripArrowRenderEventArgs(graphics, item, item.DropDownButtonBounds, arrowColor, ArrowDirection.Down));
                }
                else
                {
                    base.DrawArrow(new ToolStripArrowRenderEventArgs(graphics, item, item.DropDownButtonBounds, arrowColor, ArrowDirection.Down));
                }
            }
            else
            {
                base.OnRenderSplitButtonBackground(e);
            }
        }
コード例 #10
0
        protected override void OnRenderButtonBackground(ToolStripItemRenderEventArgs e)
        {
            ToolStrip       toolStrip = e.ToolStrip;
            ToolStripButton item      = e.Item as ToolStripButton;
            Graphics        graphics  = e.Graphics;

            if (item == null)
            {
                return;
            }
            LinearGradientMode    mode      = (toolStrip.Orientation == Orientation.Horizontal) ? LinearGradientMode.Vertical : LinearGradientMode.Horizontal;
            SmoothingModeGraphics graphics2 = new SmoothingModeGraphics(graphics);
            Rectangle             bounds    = new Rectangle(Point.Empty, item.Size);

            if (item.BackgroundImage != null)
            {
                Rectangle clipRect = item.Selected ? item.ContentRectangle : bounds;
                ControlPaintEx.DrawBackgroundImage(graphics, item.BackgroundImage, this.ColorTable.Back, item.BackgroundImageLayout, bounds, clipRect);
            }
            if (item.CheckState == CheckState.Unchecked)
            {
                if (item.Selected)
                {
                    Bitmap img = item.Pressed ? ((Bitmap)this.ColorTable.BaseItemDown) : ((Bitmap)this.ColorTable.BaseItemMouse);
                    if (img != null)
                    {
                        ImageDrawRect.DrawRect(graphics, img, bounds, Rectangle.FromLTRB(this.ColorTable.BackRectangle.X, this.ColorTable.BackRectangle.Y, this.ColorTable.BackRectangle.Width, this.ColorTable.BackRectangle.Height), 1, 1);
                    }
                    else
                    {
                        Color baseItemHover = this.ColorTable.BaseItemHover;
                        if (item.Pressed)
                        {
                            baseItemHover = this.ColorTable.BaseItemPressed;
                        }
                        RenderHelper.RenderBackgroundInternal(graphics, bounds, baseItemHover, 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))
                {
                    graphics.FillRectangle(brush, bounds);
                    goto Label_0302;
                }
            }
            Bitmap baseItemMouse = (Bitmap)this.ColorTable.BaseItemMouse;
            Color  baseColor     = ControlPaint.Light(this.ColorTable.ItemHover);

            if (item.Selected)
            {
                baseColor     = this.ColorTable.ItemHover;
                baseItemMouse = (Bitmap)this.ColorTable.BaseItemMouse;
            }
            if (item.Pressed)
            {
                baseColor     = this.ColorTable.ItemPressed;
                baseItemMouse = (Bitmap)this.ColorTable.BaseItemDown;
            }
            if (baseItemMouse == null)
            {
                RenderHelper.RenderBackgroundInternal(graphics, bounds, baseColor, this.ColorTable.BaseItemBorder, this.ColorTable.Back, this.ColorTable.BaseItemRadiusStyle, this.ColorTable.BaseItemRadius, this.ColorTable.BaseItemBorderShow, this.ColorTable.BaseItemAnamorphosis, mode);
            }
            else
            {
                ImageDrawRect.DrawRect(graphics, baseItemMouse, bounds, Rectangle.FromLTRB(this.ColorTable.BackRectangle.X, this.ColorTable.BackRectangle.Y, this.ColorTable.BackRectangle.Width, this.ColorTable.BackRectangle.Height), 1, 1);
            }
Label_0302:
            graphics2.Dispose();
        }