/// <summary> /// Internal rendering method. /// </summary> protected override IDisposable DrawRibbonTabSelected2010(RenderContext context, Rectangle rect, PaletteState state, IPaletteRibbonBack palette, VisualOrientation orientation, IDisposable memento, bool standard) { if ((rect.Width > 0) && (rect.Height > 0)) { Color c1 = palette.GetRibbonBackColor1(state); Color c2 = palette.GetRibbonBackColor2(state); Color c3 = palette.GetRibbonBackColor3(state); Color c4 = palette.GetRibbonBackColor4(state); Color c5 = palette.GetRibbonBackColor5(state); bool generate = true; MementoRibbonTabSelected2010 cache; // Access a cache instance and decide if cache resources need generating if ((memento == null) || !(memento is MementoRibbonTabSelected2010)) { if (memento != null) { memento.Dispose(); } cache = new MementoRibbonTabSelected2010(rect, c1, c2, c3, c4, c5, orientation); memento = cache; } else { cache = (MementoRibbonTabSelected2010)memento; generate = !cache.UseCachedValues(rect, c1, c2, c3, c4, c5, orientation); } // Do we need to generate the contents of the cache? if (generate) { // Dispose of existing values cache.Dispose(); // If we have a context color to use then modify the drawing colors if (c5 != Color.Empty) { if (!standard) { c5 = CommonHelper.MergeColors(c5, 0.65f, Color.Black, 0.35f); } c1 = Color.FromArgb(196, c5); } switch (orientation) { case VisualOrientation.Top: DrawRibbonTabSelectedTop2010(rect, c2, c3, c5, cache); break; case VisualOrientation.Left: DrawRibbonTabSelectedLeft2010(rect, c2, c3, c5, cache); break; case VisualOrientation.Right: DrawRibbonTabSelectedRight2010(rect, c2, c3, c5, cache); break; case VisualOrientation.Bottom: DrawRibbonTabSelectedBottom2010(rect, c2, c3, c5, cache); break; } cache.outsidePen = new Pen(c1); cache.centerPen = new Pen(c4); } context.Graphics.FillRectangle(cache.centerBrush, cache.rect); //context.Graphics.FillPath(cache.centerBrush, cache.outsidePath); //if (c5 != Color.Empty) // context.Graphics.FillPath(cache.insideBrush, cache.insidePath); //using (AntiAlias aa = new AntiAlias(context.Graphics)) // context.Graphics.DrawPath(cache.outsidePen, cache.outsidePath); context.Graphics.DrawRectangle(cache.outsidePen, cache.rect); //switch (orientation) //{ // case VisualOrientation.Top: // DrawRibbonTabSelectedTopDraw2010(rect, cache, context.Graphics); // break; // case VisualOrientation.Left: // DrawRibbonTabSelectedLeftDraw2010(rect, cache, context.Graphics); // break; // case VisualOrientation.Right: // DrawRibbonTabSelectedRightDraw2010(rect, cache, context.Graphics); // break; // case VisualOrientation.Bottom: // DrawRibbonTabSelectedBottomDraw2010(rect, cache, context.Graphics); // break; //} } return(memento); }
/// <summary> /// Internal rendering method. /// </summary> protected virtual void DrawRibbonTabSelectedTop2010(Rectangle rect, Color c2, Color c3, Color c5, MementoRibbonTabSelected2010 cache) { GraphicsPath outsidePath = new GraphicsPath(); GraphicsPath insidePath = new GraphicsPath(); // Create path for a curved dark border around the tab outsidePath.AddLine(rect.Left, rect.Bottom - 2, rect.Left + 1, rect.Bottom - 3); outsidePath.AddLine(rect.Left + 1, rect.Bottom - 3, rect.Left + 1, rect.Top + 1); outsidePath.AddLine(rect.Left + 1, rect.Top + 1, 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); outsidePath.AddLine(rect.Right - 2, rect.Top + 1, rect.Right - 2, rect.Bottom - 3); outsidePath.AddLine(rect.Right - 2, rect.Bottom - 3, rect.Right - 1, rect.Bottom - 2); RectangleF centerRectF = new RectangleF(rect.Left - 1, rect.Top - 1, rect.Width + 2, rect.Height + 2); cache.centerBrush = new LinearGradientBrush(centerRectF, c2, c3, 90f); cache.centerBrush.Blend = _ribbonTabSelected1Blend; cache.outsidePath = outsidePath; // Reduce rectangle to the inside fill area rect.X += 2; rect.Y += 2; rect.Width -= 3; rect.Height -= 2; // Create path for a curved inside border insidePath.AddLine(rect.Left, rect.Bottom - 2, rect.Left + 1, rect.Bottom - 3); insidePath.AddLine(rect.Left + 1, rect.Bottom - 3, rect.Left + 1, rect.Top + 1); insidePath.AddLine(rect.Left + 1, rect.Top + 1, rect.Left + 2, rect.Top); insidePath.AddLine(rect.Left + 2, rect.Top, rect.Right - 3, rect.Top); insidePath.AddLine(rect.Right - 3, rect.Top, rect.Right - 2, rect.Top + 1); insidePath.AddLine(rect.Right - 2, rect.Top + 1, rect.Right - 2, rect.Bottom - 3); insidePath.AddLine(rect.Right - 2, rect.Bottom - 3, rect.Right - 1, rect.Bottom - 2); RectangleF insideRectF = new RectangleF(rect.Left - 1, rect.Top - 1, rect.Width + 2, rect.Height + 2); cache.insideBrush = new LinearGradientBrush(insideRectF, Color.FromArgb(32, c5), Color.Transparent, 90f); cache.insideBrush.Blend = _ribbonTabSelected2Blend; cache.insidePath = insidePath; }
/// <summary> /// Internal rendering method. /// </summary> protected virtual void DrawRibbonTabSelectedTopDraw2010(Rectangle rect, MementoRibbonTabSelected2010 cache, Graphics g) { // Fill in the bottom two lines that the 'FillPath' above missed g.DrawLine(cache.centerPen, rect.Left + 2, rect.Bottom - 2, rect.Right - 3, rect.Bottom - 2); g.DrawLine(cache.centerPen, rect.Left + 1, rect.Bottom - 1, rect.Right - 2, rect.Bottom - 1); using (AntiAlias aa = new AntiAlias(g)) { // Draw shadow lines on the outside of the left and right edges g.DrawLine(_mediumShadowPen, rect.Left, rect.Bottom - 3, rect.Left, rect.Top + 2); g.DrawLine(_mediumShadowPen, rect.Right - 1, rect.Bottom - 3, rect.Right - 1, rect.Top + 2); } }
/// <summary> /// Internal rendering method. /// </summary> protected virtual IDisposable DrawRibbonTabSelected2010(RenderContext context, Rectangle rect, PaletteState state, IPaletteRibbonBack palette, VisualOrientation orientation, IDisposable memento, bool standard) { if ((rect.Width > 0) && (rect.Height > 0)) { Color c1 = palette.GetRibbonBackColor1(state); Color c2 = palette.GetRibbonBackColor2(state); Color c3 = palette.GetRibbonBackColor3(state); Color c4 = palette.GetRibbonBackColor4(state); Color c5 = palette.GetRibbonBackColor5(state); bool generate = true; MementoRibbonTabSelected2010 cache; // Access a cache instance and decide if cache resources need generating if ((memento == null) || !(memento is MementoRibbonTabSelected2010)) { if (memento != null) memento.Dispose(); cache = new MementoRibbonTabSelected2010(rect, c1, c2, c3, c4, c5, orientation); memento = cache; } else { cache = (MementoRibbonTabSelected2010)memento; generate = !cache.UseCachedValues(rect, c1, c2, c3, c4, c5, orientation); } // Do we need to generate the contents of the cache? if (generate) { // Dispose of existing values cache.Dispose(); // If we have a context color to use then modify the drawing colors if (c5 != Color.Empty) { if (!standard) c5 = CommonHelper.MergeColors(c5, 0.65f, Color.Black, 0.35f); c1 = Color.FromArgb(196, c5); } switch (orientation) { case VisualOrientation.Top: DrawRibbonTabSelectedTop2010(rect, c2, c3, c5, cache); break; case VisualOrientation.Left: DrawRibbonTabSelectedLeft2010(rect, c2, c3, c5, cache); break; case VisualOrientation.Right: DrawRibbonTabSelectedRight2010(rect, c2, c3, c5, cache); break; case VisualOrientation.Bottom: DrawRibbonTabSelectedBottom2010(rect, c2, c3, c5, cache); break; } cache.outsidePen = new Pen(c1); cache.centerPen = new Pen(c4); } context.Graphics.FillPath(cache.centerBrush, cache.outsidePath); if (c5 != Color.Empty) context.Graphics.FillPath(cache.insideBrush, cache.insidePath); using (AntiAlias aa = new AntiAlias(context.Graphics)) context.Graphics.DrawPath(cache.outsidePen, cache.outsidePath); switch (orientation) { case VisualOrientation.Top: DrawRibbonTabSelectedTopDraw2010(rect, cache, context.Graphics); break; case VisualOrientation.Left: DrawRibbonTabSelectedLeftDraw2010(rect, cache, context.Graphics); break; case VisualOrientation.Right: DrawRibbonTabSelectedRightDraw2010(rect, cache, context.Graphics); break; case VisualOrientation.Bottom: DrawRibbonTabSelectedBottomDraw2010(rect, cache, context.Graphics); break; } } return memento; }