Beispiel #1
0
        public static void DrawScrollBarArraw(
            Graphics g,
            Rectangle rect,
            Color begin,
            Color end,
            Color border,
            Color innerBorder,
            Color fore,
            Orientation orientation,
            ArrowDirection arrowDirection,
            bool changeColor)
        {
            if (changeColor)
            {
                Color tmp = begin;
                begin = end;
                end   = tmp;
            }

            bool bHorizontal        = orientation == Orientation.Horizontal;
            LinearGradientMode mode = bHorizontal ?
                                      LinearGradientMode.Vertical : LinearGradientMode.Horizontal;

            rect.Inflate(-1, -1);

            Blend blend = new Blend();

            blend.Factors   = new float[] { 1f, 0.5f, 0f };
            blend.Positions = new float[] { 0f, 0.5f, 1f };

            DrawGradientRoundRect(
                g,
                rect,
                begin,
                end,
                border,
                innerBorder,
                blend,
                mode,
                4,
                RoundStyle.All,
                true,
                true);

            using (SolidBrush brush = new SolidBrush(fore))
            {
                RenderHelper.RenderArrowInternal(
                    g,
                    rect,
                    arrowDirection,
                    brush);
            }
        }
        protected override void OnRenderOverflowButtonBackground(ToolStripItemRenderEventArgs e)
        {
            ToolStripItem item        = e.Item;
            ToolStrip     toolStrip   = e.ToolStrip;
            Graphics      graphics    = e.Graphics;
            bool          rightToLeft = item.RightToLeft == RightToLeft.Yes;

            new SmoothingModeGraphics(graphics);
            this.RenderOverflowBackground(e, rightToLeft);
            bool      flag2 = 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 = flag2 ? ArrowDirection.Down : ArrowDirection.Right;
            int            x         = (rightToLeft && flag2) ? -1 : 1;

            empty.Offset(x, 1);
            Color color = toolStrip.Enabled ? this.ColorTable.Fore : SystemColors.ControlDark;

            using (Brush brush = new SolidBrush(color))
            {
                RenderHelper.RenderArrowInternal(graphics, empty, direction, brush);
            }
            if (flag2)
            {
                using (Pen pen = new Pen(color))
                {
                    graphics.DrawLine(pen, (int)(empty.Right - 8), (int)(empty.Y - 2), (int)(empty.Right - 2), (int)(empty.Y - 2));
                    graphics.DrawLine(pen, (int)(empty.Right - 8), (int)(empty.Y - 1), (int)(empty.Right - 2), (int)(empty.Y - 1));
                    return;
                }
            }
            using (Pen pen2 = new Pen(color))
            {
                graphics.DrawLine(pen2, empty.X, empty.Y, empty.X, empty.Bottom - 1);
                graphics.DrawLine(pen2, empty.X, empty.Y + 1, empty.X, empty.Bottom);
            }
        }