protected virtual IDisposable DrawRibbonTabHighlight(PaletteRibbonShape shape,
RenderContext context,
Rectangle rect,
PaletteState state,
IPaletteRibbonBack palette,
VisualOrientation orientation,
IDisposable memento,
bool alternate)
{
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;
MementoRibbonTabHighlight cache;
// Access a cache instance and decide if cache resources need generating
if ((memento == null) || !(memento is MementoRibbonTabHighlight))
{
if (memento != null)
memento.Dispose();
cache = new MementoRibbonTabHighlight(rect, c1, c2, c3, c4, c5, orientation);
memento = cache;
}
else
{
cache = (MementoRibbonTabHighlight)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:
DrawRibbonTabHighlightTop(rect, c4, c5, cache);
break;
case VisualOrientation.Left:
DrawRibbonTabHighlightLeft(rect, c4, c5, cache);
break;
case VisualOrientation.Right:
DrawRibbonTabHighlightRight(rect, c4, c5, cache);
break;
case VisualOrientation.Bottom:
DrawRibbonTabHighlightBottom(rect, c4, c5, cache);
break;
}
cache.innerVertPen = new Pen(c1);
cache.innerHorzPen = new Pen(c2);
cache.borderHorzPen = new Pen(c3);
}
// First of all draw as selected
cache.selectedMemento = (MementoRibbonTabSelected2007)DrawRibbonTabSelected2007(context, rect, PaletteState.CheckedNormal, palette, orientation, cache.selectedMemento);
switch (orientation)
{
case VisualOrientation.Top:
DrawRibbonTabHighlightTopDraw(rect, c1, c2, c3, c4, c5, cache, context.Graphics, alternate);
break;
case VisualOrientation.Left:
DrawRibbonTabHighlightLeftDraw(rect, c1, c2, c3, c4, c5, cache, context.Graphics, alternate);
break;
case VisualOrientation.Right:
DrawRibbonTabHighlightRightDraw(rect, c1, c2, c3, c4, c5, cache, context.Graphics, alternate);
break;
case VisualOrientation.Bottom:
DrawRibbonTabHighlightBottomDraw(rect, c1, c2, c3, c4, c5, cache, context.Graphics, alternate);
break;
}
}
return memento;
}