コード例 #1
0
ファイル: RenderStandard.cs プロジェクト: Cocotteseb/Krypton
 /// <summary>
 /// Internal rendering method.
 /// </summary>
 protected virtual void DrawRibbonTabTrackingTopDraw2007(Rectangle rect,
                                                         MementoRibbonTabTracking2007 cache,
                                                         Graphics g)
 {
     g.FillRectangle(cache.outsideBrush, rect.Left, rect.Top + 3, 1, rect.Height - 4);
     g.FillRectangle(cache.insideBrush, rect.Left + 2, rect.Top + 3, 1, rect.Height - 4);
     g.FillRectangle(cache.outsideBrush, rect.Right - 1, rect.Top + 3, 1, rect.Height - 4);
     g.FillRectangle(cache.insideBrush, rect.Right - 3, rect.Top + 3, 1, rect.Height - 4);
 }
コード例 #2
0
ファイル: RenderStandard.cs プロジェクト: Cocotteseb/Krypton
 /// <summary>
 /// Internal rendering method.
 /// </summary>
 protected virtual void DrawRibbonTabTrackingRightDraw2007(Rectangle rect,
                                                           MementoRibbonTabTracking2007 cache,
                                                           Graphics g)
 {
     g.FillRectangle(cache.outsideBrush, rect.Left + 1, rect.Top, rect.Width - 4, 1);
     g.FillRectangle(cache.insideBrush, rect.Left + 1, rect.Top + 2, rect.Width - 4, 1);
     g.FillRectangle(cache.outsideBrush, rect.Left + 1, rect.Bottom - 1, rect.Width - 4, 1);
     g.FillRectangle(cache.insideBrush, rect.Left + 1, rect.Bottom - 3, rect.Width - 4, 1);
 }
コード例 #3
0
ファイル: RenderStandard.cs プロジェクト: Cocotteseb/Krypton
        /// <summary>
        /// Internal rendering method.
        /// </summary>
        protected virtual void DrawRibbonTabTrackingTop2007(Rectangle rect, 
                                                            Color c1, Color c2,
                                                            MementoRibbonTabTracking2007 cache)
        {
            GraphicsPath outsidePath = new GraphicsPath();
            GraphicsPath topPath = new GraphicsPath();
            GraphicsPath ellipsePath = new GraphicsPath();
            RectangleF half1RectF, vertRectF, horzRectF;
            int full, half1, half2;
            Rectangle fullRect;

            // Create path for a curved border around the tab
            outsidePath.AddLine(rect.Left + 1, rect.Bottom - 2, rect.Left + 1, rect.Top + 1.5f);
            outsidePath.AddLine(rect.Left + 1, rect.Top + 1.5f, rect.Left + 3, rect.Top);
            outsidePath.AddLine(rect.Left + 3, rect.Top, rect.Right - 4, rect.Top);
            outsidePath.AddLine(rect.Right - 4, rect.Top, rect.Right - 2, rect.Top + 1.5f);
            outsidePath.AddLine(rect.Right - 2, rect.Top + 1.5f, rect.Right - 2, rect.Bottom - 2);

            // Create path for the top hightlight line
            topPath.AddLine(rect.Left + 3, rect.Top + 2, rect.Left + 4, rect.Top + 1);
            topPath.AddLine(rect.Left + 4, rect.Top + 1, rect.Right - 5, rect.Top + 1);
            topPath.AddLine(rect.Right - 5, rect.Top + 1, rect.Right - 4, rect.Top + 2);

            // Create the top and bottom half rectangles
            full = rect.Height - 3;
            half1 = full / 2;
            half2 = full - half1;
            cache.half1Rect = new Rectangle(rect.Left + 3, rect.Top + 2, rect.Width - 6, half1);
            cache.half2Rect = new Rectangle(rect.Left + 3, rect.Top + 2 + half1, rect.Width - 6, half2);
            fullRect = new Rectangle(rect.Left + 3, rect.Top + 2, rect.Width - 6, half1 + half2);
            half1RectF = new RectangleF(cache.half1Rect.Left - 1, cache.half1Rect.Top - 0.5f, cache.half1Rect.Width + 2, cache.half1Rect.Height + 1);
            cache.half2RectF = new RectangleF(cache.half2Rect.Left - 1, cache.half2Rect.Top - 0.5f, cache.half2Rect.Width + 2, cache.half2Rect.Height + 1);

            cache.half1LeftBrush = new LinearGradientBrush(half1RectF, Color.FromArgb(85, c2), Color.Transparent, 0f);
            cache.half1LeftBrush.Blend = _ribbonTabTopBlend;
            cache.half1RightBrush = new LinearGradientBrush(half1RectF, Color.FromArgb(85, c2), Color.Transparent, 180f);
            cache.half1RightBrush.Blend = _ribbonTabTopBlend;
            cache.half1LightBrush = new LinearGradientBrush(half1RectF, Color.FromArgb(28, Color.White), Color.FromArgb(125, Color.White), 90f);
            cache.half2Brush = new SolidBrush(Color.FromArgb(85, c2));

            // Create ellipse information for lightening the bottom half
            cache.ellipseRect = new RectangleF(fullRect.Left - (fullRect.Width / 8), fullRect.Top, fullRect.Width * 1.25f, fullRect.Height);

            // Cannot draw a path that contains a zero sized element
            if ((cache.ellipseRect.Width > 0) && (cache.ellipseRect.Height > 0))
            {
                ellipsePath.AddEllipse(cache.ellipseRect);
                cache.ellipseBrush = new PathGradientBrush(ellipsePath);
                cache.ellipseBrush.CenterColor = Color.FromArgb(92, Color.White);
                PointF centerPoint = new PointF(cache.ellipseRect.Left + (cache.ellipseRect.Width / 2), cache.ellipseRect.Top + (cache.ellipseRect.Height / 2));
                cache.ellipseBrush.CenterPoint = centerPoint;
                cache.ellipseBrush.SurroundColors = new Color[] { Color.Transparent };
            }

            vertRectF = new RectangleF(rect.Left - 1, rect.Top + 2, rect.Width + 2, rect.Height - 2);
            horzRectF = new RectangleF(rect.Left + 1, rect.Top, rect.Width - 2, rect.Height);
            cache.outsideBrush = new LinearGradientBrush(vertRectF, Color.Transparent, _whiten128, 90f);
            cache.outsideBrush.Blend = _ribbonOutBlend;
            cache.insideBrush = new LinearGradientBrush(vertRectF, Color.Transparent, _whiten200, 90f);
            cache.insideBrush.Blend = _ribbonInBlend;
            cache.topBrush = new LinearGradientBrush(horzRectF, _whiten92, _whiten128, 0f);
            cache.topBrush.Blend = _ribbonTopBlend;
            cache.topPen = new Pen(cache.topBrush);

            cache.outsidePen = new Pen(c1);
            cache.outsidePath = outsidePath;
            cache.topPath = topPath;
            cache.ellipsePath = ellipsePath;
        }
コード例 #4
0
ファイル: RenderStandard.cs プロジェクト: Cocotteseb/Krypton
        /// <summary>
        /// Internal rendering method.
        /// </summary>
        protected virtual IDisposable DrawRibbonTabTracking2007(PaletteRibbonShape shape,
                                                                RenderContext context, 
                                                                Rectangle rect,
                                                                PaletteState state,
                                                                IPaletteRibbonBack palette,
                                                                VisualOrientation orientation,
                                                                IDisposable memento)
        {
            if ((rect.Width > 0) && (rect.Height > 0))
            {
                Color c1 = palette.GetRibbonBackColor1(state);
                Color c2 = palette.GetRibbonBackColor2(state);

                bool generate = true;
                MementoRibbonTabTracking2007 cache;

                // Access a cache instance and decide if cache resources need generating
                if ((memento == null) || !(memento is MementoRibbonTabTracking2007))
                {
                    if (memento != null)
                        memento.Dispose();

                    cache = new MementoRibbonTabTracking2007(rect, c1, c2, orientation);
                    memento = cache;
                }
                else
                {
                    cache = (MementoRibbonTabTracking2007)memento;
                    generate = !cache.UseCachedValues(rect, c1, c2, orientation);
                }

                // Do we need to generate the contents of the cache?
                if (generate)
                {
                    // Dispose of existing values
                    cache.Dispose();

                    switch (orientation)
                    {
                        case VisualOrientation.Top:
                            DrawRibbonTabTrackingTop2007(rect, c1, c2, cache);
                            break;
                        case VisualOrientation.Left:
                            DrawRibbonTabTrackingLeft2007(rect, c1, c2, cache);
                            break;
                        case VisualOrientation.Right:
                            DrawRibbonTabTrackingRight2007(rect, c1, c2, cache);
                            break;
                        case VisualOrientation.Bottom:
                            DrawRibbonTabTrackingBottom2007(rect, c1, c2, cache);
                            break;
                    }
                }

                // Draw the left and right sides with light version of tracking color
                context.Graphics.FillRectangle(cache.half1LeftBrush, cache.half1Rect);
                context.Graphics.FillRectangle(cache.half1RightBrush, cache.half1Rect);

                // Draw over with glassy effect
                context.Graphics.FillRectangle(cache.half1LightBrush, cache.half1Rect);

                //// Use a solid fill for the bottom half
                context.Graphics.FillRectangle(cache.half2Brush, cache.half2Rect);

                // Cannot draw a path that contains a zero sized element
                if ((cache.ellipseRect.Width > 0) && (cache.ellipseRect.Height > 0))
                {
                    // Draw twice to get a deeper color effect, once is to pale
                    context.Graphics.FillRectangle(cache.ellipseBrush, cache.half2RectF);
                    context.Graphics.FillRectangle(cache.ellipseBrush, cache.half2RectF);
                }

                // Draw the actual border
                using (AntiAlias aa = new AntiAlias(context.Graphics))
                    context.Graphics.DrawPath(cache.outsidePen, cache.outsidePath);

                switch (orientation)
                {
                    case VisualOrientation.Top:
                        DrawRibbonTabTrackingTopDraw2007(rect, cache, context.Graphics);
                        break;
                    case VisualOrientation.Left:
                        DrawRibbonTabTrackingLeftDraw2007(rect, cache, context.Graphics);
                        break;
                    case VisualOrientation.Right:
                        DrawRibbonTabTrackingRightDraw2007(rect, cache, context.Graphics);
                        break;
                    case VisualOrientation.Bottom:
                        DrawRibbonTabTrackingBottomDraw2007(rect, cache, context.Graphics);
                        break;
                }

                context.Graphics.DrawPath(cache.topPen, cache.topPath);
            }

            return memento;
        }