示例#1
0
        private void RenderBefore2007ContextTab(RenderContext context, ContextTabSet cts)
        {
            // We only draw side separators on the first and last tab of the contexts
            if (cts.IsFirstOrLastTab(this))
            {
                // Grab the color we draw the context separator in
                Color sepColor = _paletteGeneral.GetRibbonTabSeparatorContextColor(PaletteState.Normal);

                Rectangle parentRect   = Parent.ClientRectangle;
                Rectangle contextRect  = new Rectangle(ClientRectangle.X - 1, parentRect.Y, ClientRectangle.Width + 2, parentRect.Height);
                Rectangle gradientRect = new Rectangle(ClientRectangle.X - 1, parentRect.Y - 1, ClientRectangle.Width + 2, parentRect.Height + 2);

                using (LinearGradientBrush sepBrush = new LinearGradientBrush(gradientRect, sepColor, Color.Transparent, 90f))
                {
                    // We need to customize the way the color blends over the background
                    sepBrush.Blend = _contextBlend2007;

                    using (Pen sepPen = new Pen(sepBrush))
                    {
                        if (cts.IsFirstTab(this))
                        {
                            context.Graphics.DrawLine(sepPen, contextRect.X, contextRect.Y, contextRect.X, contextRect.Bottom - 1);
                        }

                        if (cts.IsLastTab(this))
                        {
                            context.Graphics.DrawLine(sepPen, contextRect.Right - 1, contextRect.Y, contextRect.Right - 1, contextRect.Bottom - 1);
                        }
                    }
                }
            }
        }
示例#2
0
        private void RenderBefore2010ContextTab(RenderContext context, ContextTabSet cts)
        {
            // Grab the colors we draw the context separators and background in
            Color c1      = _paletteGeneral.GetRibbonTabSeparatorContextColor(PaletteState.Normal);
            Color c2      = cts.ContextColor;
            Color lightC2 = ControlPaint.Light(c2);
            Color c3      = CommonHelper.MergeColors(Color.Black, 0.1f, c2, 0.9f);

            Rectangle contextRect = new Rectangle(ClientRectangle.X - 1, ClientRectangle.Y - 1, ClientRectangle.Width + 2, ClientRectangle.Height + 1);
            Rectangle fillRect    = new Rectangle(ClientRectangle.X - 2, ClientRectangle.Y - 1, ClientRectangle.Width + 4, ClientRectangle.Height);

            using (LinearGradientBrush outerBrush = new LinearGradientBrush(contextRect, c1, Color.Transparent, 90f),
                   innerBrush = new LinearGradientBrush(contextRect, c3, Color.Transparent, 90f),
                   fillBrush = new LinearGradientBrush(contextRect, Color.FromArgb(64, lightC2), Color.Transparent, 90f))
            {
                fillBrush.Blend = _contextBlend2010;

                using (Pen outerPen = new Pen(outerBrush),
                       innerPen = new Pen(innerBrush))
                {
                    if (cts.IsFirstTab(this))
                    {
                        // Draw left separators
                        context.Graphics.DrawLine(outerPen, contextRect.X, contextRect.Y, contextRect.X, contextRect.Bottom - 2);
                        context.Graphics.DrawLine(innerPen, contextRect.X + 1, contextRect.Y, contextRect.X + 1, contextRect.Bottom - 2);
                        fillRect.X     += 2;
                        fillRect.Width -= 2;

                        if (cts.IsLastTab(this))
                        {
                            // Draw right separators
                            context.Graphics.DrawLine(outerPen, contextRect.Right - 1, contextRect.Y, contextRect.Right - 1, contextRect.Bottom - 2);
                            context.Graphics.DrawLine(innerPen, contextRect.Right - 2, contextRect.Y, contextRect.Right - 2, contextRect.Bottom - 2);
                            fillRect.Width -= 2;
                        }
                    }
                    else if (cts.IsLastTab(this))
                    {
                        // Draw right separators
                        context.Graphics.DrawLine(outerPen, contextRect.Right - 1, contextRect.Y, contextRect.Right - 1, contextRect.Bottom - 2);
                        context.Graphics.DrawLine(innerPen, contextRect.Right - 2, contextRect.Y, contextRect.Right - 2, contextRect.Bottom - 2);
                        fillRect.Width -= 2;
                    }

                    // Draw the background gradient
                    context.Graphics.FillRectangle(fillBrush, fillRect);
                }
            }
        }