protected virtual IDisposable DrawRibbonTabSelected2007(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);
Color c3 = palette.GetRibbonBackColor3(state);
Color c4 = palette.GetRibbonBackColor4(state);
Color c5 = palette.GetRibbonBackColor5(state);
bool generate = true;
MementoRibbonTabSelected2007 cache;
// Access a cache instance and decide if cache resources need generating
if ((memento == null) || !(memento is MementoRibbonTabSelected2007))
{
if (memento != null)
memento.Dispose();
cache = new MementoRibbonTabSelected2007(rect, c1, c2, c3, c4, c5, orientation);
memento = cache;
}
else
{
cache = (MementoRibbonTabSelected2007)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();
switch (orientation)
{
case VisualOrientation.Top:
DrawRibbonTabSelectedTop2007(rect, c4, c5, cache);
break;
case VisualOrientation.Left:
DrawRibbonTabSelectedLeft2007(rect, c4, c5, cache);
break;
case VisualOrientation.Right:
DrawRibbonTabSelectedRight2007(rect, c4, c5, cache);
break;
case VisualOrientation.Bottom:
DrawRibbonTabSelectedBottom2007(rect, c4, c5, cache);
break;
}
cache.insideBrush = new SolidBrush(c3);
cache.outsidePen = new Pen(c1);
cache.middlePen = new Pen(c2);
cache.insidePen = new Pen(c3);
cache.centerPen = new Pen(c5);
}
// Fill the inside of the border
context.Graphics.FillPath(cache.insideBrush, cache.outsidePath);
// Draw the actual border
using (AntiAlias aa = new AntiAlias(context.Graphics))
context.Graphics.DrawPath(cache.outsidePen, cache.outsidePath);
switch (orientation)
{
case VisualOrientation.Top:
DrawRibbonTabSelectedTopDraw2007(rect, cache, context.Graphics);
break;
case VisualOrientation.Left:
DrawRibbonTabSelectedLeftDraw2007(rect, cache, context.Graphics);
break;
case VisualOrientation.Right:
DrawRibbonTabSelectedRightDraw2007(rect, cache, context.Graphics);
break;
case VisualOrientation.Bottom:
DrawRibbonTabSelectedBottomDraw2007(rect, cache, context.Graphics);
break;
}
// Fill in the center as a vertical gradient from tto bottom
context.Graphics.FillRectangle(cache.centerBrush, cache.centerRect);
}
return memento;
}