Example #1
0
        public void RenderOverflowBackground(ToolStripItemRenderEventArgs e, bool rightToLeft)
        {
            bool      flag2;
            Color     empty              = Color.Empty;
            Graphics  g                  = e.Graphics;
            ToolStrip toolStrip          = e.ToolStrip;
            ToolStripOverflowButton item = e.Item as ToolStripOverflowButton;
            Rectangle bounds             = new Rectangle(Point.Empty, item.Size);
            Rectangle withinBounds       = bounds;
            bool      flag               = !(item.GetCurrentParent() is MenuStrip);

            if (flag2 = toolStrip.Orientation == Orientation.Horizontal)
            {
                bounds.X    += (bounds.Width - 12) + 1;
                bounds.Width = 12;
                if (rightToLeft)
                {
                    bounds = LayoutUtils.RTLTranslate(bounds, withinBounds);
                }
            }
            else
            {
                bounds.Y      = (bounds.Height - 12) + 1;
                bounds.Height = 12;
            }
            if (item.Pressed)
            {
                empty = this.ColorTable.ItemPressed;
            }
            else if (item.Selected)
            {
                empty = this.ColorTable.ItemHover;
            }
            else
            {
                empty = this.ColorTable.Base;
            }
            if (flag)
            {
                using (Pen pen = new Pen(this.ColorTable.Base))
                {
                    Point point  = new Point(bounds.Left - 1, bounds.Height - 2);
                    Point point2 = new Point(bounds.Left, bounds.Height - 2);
                    if (rightToLeft)
                    {
                        point.X  = bounds.Right + 1;
                        point2.X = bounds.Right;
                    }
                    g.DrawLine(pen, point, point2);
                }
            }
            LinearGradientMode mode = flag2 ? LinearGradientMode.Vertical : LinearGradientMode.Horizontal;

            RenderHelperStrip.RenderBackgroundInternal(g, bounds, empty, this.ColorTable.ItemBorder, this.ColorTable.Back, RoundStyle.None, 0, 0.35f, false, false, mode);
            if (flag)
            {
                using (Brush brush = new SolidBrush(this.ColorTable.Base))
                {
                    if (flag2)
                    {
                        Point point3 = new Point(bounds.X - 2, 0);
                        Point point4 = new Point(bounds.X - 1, 1);
                        if (rightToLeft)
                        {
                            point3.X = bounds.Right + 1;
                            point4.X = bounds.Right;
                        }
                        g.FillRectangle(brush, point3.X, point3.Y, 1, 1);
                        g.FillRectangle(brush, point4.X, point4.Y, 1, 1);
                    }
                    else
                    {
                        g.FillRectangle(brush, bounds.Width - 3, bounds.Top - 1, 1, 1);
                        g.FillRectangle(brush, bounds.Width - 2, bounds.Top - 2, 1, 1);
                    }
                }
                using (Brush brush2 = new SolidBrush(this.ColorTable.Base))
                {
                    if (flag2)
                    {
                        Rectangle rect = new Rectangle(bounds.X - 1, 0, 1, 1);
                        if (rightToLeft)
                        {
                            rect.X = bounds.Right;
                        }
                        g.FillRectangle(brush2, rect);
                    }
                    else
                    {
                        g.FillRectangle(brush2, bounds.X, bounds.Top - 1, 1, 1);
                    }
                }
            }
        }
Example #2
0
        internal void RenderOverflowBackground(ToolStripItemRenderEventArgs e, bool rightToLeft)
        {
            Color     color              = Color.Empty;
            Graphics  graphics           = e.Graphics;
            ToolStrip toolStrip          = e.ToolStrip;
            ToolStripOverflowButton item = e.Item as ToolStripOverflowButton;
            Rectangle bounds             = new Rectangle(Point.Empty, item.Size);
            Rectangle withinBounds       = bounds;
            bool      bParentIsMenuStrip = !(item.GetCurrentParent() is MenuStrip);
            bool      bHorizontal        = toolStrip.Orientation == Orientation.Horizontal;

            if (bHorizontal)
            {
                bounds.X    += (bounds.Width - 12) + 1;
                bounds.Width = 12;
                if (rightToLeft)
                {
                    bounds = GraphicsHelper.RTLTranslate(bounds, withinBounds);
                }
            }
            else
            {
                bounds.Y      = (bounds.Height - 12) + 1;
                bounds.Height = 12;
            }

            if (item.Pressed)
            {
                color = StyleSheet.HeadToolStripItemPressedBackColor;
            }
            else if (item.Selected)
            {
                color = StyleSheet.HeadToolStripItemHoveringBackColor;
            }
            else
            {
                color = StyleSheet.HeadToolStripBackColor;
            }
            if (bParentIsMenuStrip)
            {
                using (Pen pen = new Pen(StyleSheet.HeadToolStripBackColor))
                {
                    Point point  = new Point(bounds.Left - 1, bounds.Height - 2);
                    Point point2 = new Point(bounds.Left, bounds.Height - 2);
                    if (rightToLeft)
                    {
                        point.X  = bounds.Right + 1;
                        point2.X = bounds.Right;
                    }
                    graphics.DrawLine(pen, point, point2);
                }
            }

            LinearGradientMode mode = bHorizontal ? LinearGradientMode.Vertical : LinearGradientMode.Horizontal;

            GraphicsHelper.DrawBackground(
                graphics,
                bounds,
                color,
                StyleSheet.HeadToolStripItemBorderColor,
                StyleSheet.HeadToolStripItemInnerBorderColor,
                RoundStyle.None,
                0,
                .35f,
                false,
                false,
                mode);

            if (bParentIsMenuStrip)
            {
                using (Brush brush = new SolidBrush(StyleSheet.HeadToolStripBackColor))
                {
                    if (bHorizontal)
                    {
                        Point point3 = new Point(bounds.X - 2, 0);
                        Point point4 = new Point(bounds.X - 1, 1);
                        if (rightToLeft)
                        {
                            point3.X = bounds.Right + 1;
                            point4.X = bounds.Right;
                        }
                        graphics.FillRectangle(brush, point3.X, point3.Y, 1, 1);
                        graphics.FillRectangle(brush, point4.X, point4.Y, 1, 1);
                    }
                    else
                    {
                        graphics.FillRectangle(brush, bounds.Width - 3, bounds.Top - 1, 1, 1);
                        graphics.FillRectangle(brush, bounds.Width - 2, bounds.Top - 2, 1, 1);
                    }
                }
                using (Brush brush = new SolidBrush(StyleSheet.HeadToolStripBackColor))
                {
                    if (bHorizontal)
                    {
                        Rectangle rect = new Rectangle(bounds.X - 1, 0, 1, 1);
                        if (rightToLeft)
                        {
                            rect.X = bounds.Right;
                        }
                        graphics.FillRectangle(brush, rect);
                    }
                    else
                    {
                        graphics.FillRectangle(brush, bounds.X, bounds.Top - 1, 1, 1);
                    }
                }
            }
        }