/// <summary> /// Internal rendering method. /// </summary> protected virtual void DrawRibbonTabSelectedTop2007(Rectangle rect, Color c4, Color c5, MementoRibbonTabSelected2007 cache) { GraphicsPath outsidePath = 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.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 - 3); outsidePath.AddLine(rect.Right - 2, rect.Bottom - 3, rect.Right - 1, rect.Bottom - 2); cache.centerRect = new Rectangle(rect.Left + 4, rect.Top + 4, rect.Width - 8, rect.Height - 4); RectangleF centerRectF = new RectangleF(cache.centerRect.Left - 1, cache.centerRect.Top - 1, cache.centerRect.Width + 2, cache.centerRect.Height + 2); cache.centerBrush = new LinearGradientBrush(centerRectF, c4, c5, 90f); cache.outsidePath = outsidePath; }
/// <summary> /// Internal rendering method. /// </summary> protected virtual void DrawRibbonTabSelectedTopDraw2007(Rectangle rect, MementoRibbonTabSelected2007 cache, Graphics g) { // Fill in the bottom two lines that the 'FillPath' above missed g.DrawLine(cache.insidePen, rect.Left + 1, rect.Bottom - 1, rect.Right - 2, rect.Bottom - 1); g.DrawLine(cache.insidePen, rect.Left + 2, rect.Bottom - 2, rect.Right - 3, rect.Bottom - 2); g.DrawLine(cache.centerPen, rect.Left + 3, rect.Bottom - 1, rect.Right - 4, rect.Bottom - 1); using (AntiAlias aa = new AntiAlias(g)) { // Draw a line on the inside of the left and right border edges g.DrawLine(cache.middlePen, rect.Left + 0.5f, rect.Bottom - 1, rect.Left + 2, rect.Bottom - 3); g.DrawLine(cache.middlePen, rect.Left + 2, rect.Bottom - 3, rect.Left + 2, rect.Top + 2); g.DrawLine(cache.middlePen, rect.Right - 1.5f, rect.Bottom - 1, rect.Right - 3, rect.Bottom - 3); g.DrawLine(cache.middlePen, rect.Right - 3, rect.Bottom - 3, rect.Right - 3, rect.Top + 2); // Draw shadow lines on the outside of the left and right edges g.DrawLine(_paleShadowPen, rect.Left - 1, rect.Bottom - 2, rect.Left - 1, rect.Top + 8); g.DrawLine(_lightShadowPen, rect.Left, rect.Bottom - 3, rect.Left, rect.Top + 5); g.DrawLine(_darkShadowPen, rect.Right - 1, rect.Bottom - 3, rect.Right - 1, rect.Top + 3); g.DrawLine(_mediumShadowPen, rect.Right, rect.Bottom - 2, rect.Right, rect.Top + 7); } }
/// <summary> /// Internal rendering method. /// </summary> 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; }