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;
}