/// <summary> /// Internal rendering method. /// </summary> protected virtual void DrawRibbonTabTrackingTop2010(Rectangle rect, Color c3, Color c4, MementoRibbonTabTracking2010 cache) { GraphicsPath borderPath = new GraphicsPath(); GraphicsPath outsidePath = new GraphicsPath(); GraphicsPath insidePath = new GraphicsPath(); // Create path for a border pen borderPath.AddLine(rect.Left, rect.Bottom - 2, rect.Left, rect.Top + 1.75f); borderPath.AddLine(rect.Left, rect.Top + 1.75f, rect.Left + 1, rect.Top); borderPath.AddLine(rect.Left + 1, rect.Top, rect.Right - 2, rect.Top); borderPath.AddLine(rect.Right - 2, rect.Top, rect.Right - 1, rect.Top + 1.75f); borderPath.AddLine(rect.Right - 1, rect.Top + 1.75f, rect.Right - 1, rect.Bottom - 2); // Create path for a inside fill outsidePath.AddLine(rect.Left, rect.Bottom - 1, rect.Left, rect.Top + 1.5f); outsidePath.AddLine(rect.Left, rect.Top + 1.5f, rect.Left + 1, rect.Top); outsidePath.AddLine(rect.Left + 1, rect.Top, rect.Right - 2, rect.Top); outsidePath.AddLine(rect.Right - 2, rect.Top, rect.Right - 1, rect.Top + 1.5f); outsidePath.AddLine(rect.Right - 1, rect.Top + 1.5f, rect.Right - 1, rect.Bottom - 1); // 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 fill area insidePath.AddLine(rect.Left, rect.Bottom - 1, rect.Left, rect.Top + 1f); insidePath.AddLine(rect.Left, rect.Top + 1f, rect.Left + 1, rect.Top); insidePath.AddLine(rect.Left + 1, rect.Top, rect.Right - 2, rect.Top); insidePath.AddLine(rect.Right - 2, rect.Top, rect.Right - 1, rect.Top + 1f); insidePath.AddLine(rect.Right - 1, rect.Top + 1f, rect.Right - 1, rect.Bottom - 1); cache.borderPath = borderPath; cache.outsidePath = outsidePath; cache.insidePath = insidePath; cache.insideBrush = new LinearGradientBrush(new RectangleF(rect.X - 1, rect.Y - 1, rect.Width + 2, rect.Height + 2), c4, c3, 270f); cache.insideBrush.Blend = _linear50Blend; }
/// <summary> /// Internal rendering method. /// </summary> protected override IDisposable DrawRibbonTabTracking2010(PaletteRibbonShape shape, 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; MementoRibbonTabTracking2010 cache; // Access a cache instance and decide if cache resources need generating if ((memento == null) || !(memento is MementoRibbonTabTracking2010)) { if (memento != null) { memento.Dispose(); } cache = new MementoRibbonTabTracking2010(rect, c1, c2, c3, c4, orientation); memento = cache; } else { cache = (MementoRibbonTabTracking2010)memento; generate = !cache.UseCachedValues(rect, c1, c2, c3, c4, orientation); } // Do we need to generate the contents of the cache? if (generate) { // Dispose of existing values cache.Dispose(); // If c5 has a colour then use that to highlight the tab if (c5 != Color.Empty) { if (!standard) { c5 = CommonHelper.MergeColors(c5, 0.65f, Color.Black, 0.35f); } c1 = c5; c2 = CommonHelper.MergeColors(c2, 0.8f, ControlPaint.Light(c5), 0.2f); c3 = CommonHelper.MergeColors(c3, 0.7f, c5, 0.3f); } switch (orientation) { case VisualOrientation.Top: DrawRibbonTabTrackingTop2010(rect, c3, c4, cache); break; case VisualOrientation.Left: DrawRibbonTabTrackingLeft2010(rect, c3, c4, cache); break; case VisualOrientation.Right: DrawRibbonTabTrackingRight2010(rect, c3, c4, cache); break; case VisualOrientation.Bottom: DrawRibbonTabTrackingBottom2010(rect, c3, c4, cache); break; } cache.outsidePen = new Pen(c1); cache.outsideBrush = new SolidBrush(c2); } // Fill the full background //context.Graphics.FillPath(cache.outsideBrush, cache.outsidePath); context.Graphics.FillRectangle(cache.outsideBrush, cache.rect); // Draw the border //using (AntiAlias aa = new AntiAlias(context.Graphics)) // context.Graphics.DrawPath(cache.outsidePen, cache.borderPath); context.Graphics.DrawRectangle(cache.outsidePen, cache.rect); // Fill the inside area //context.Graphics.FillPath(cache.insideBrush, cache.insidePath); } return(memento); }
/// <summary> /// Internal rendering method. /// </summary> protected virtual IDisposable DrawRibbonTabTracking2010(PaletteRibbonShape shape, 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; MementoRibbonTabTracking2010 cache; // Access a cache instance and decide if cache resources need generating if ((memento == null) || !(memento is MementoRibbonTabTracking2010)) { if (memento != null) memento.Dispose(); cache = new MementoRibbonTabTracking2010(rect, c1, c2, c3, c4, orientation); memento = cache; } else { cache = (MementoRibbonTabTracking2010)memento; generate = !cache.UseCachedValues(rect, c1, c2, c3, c4, orientation); } // Do we need to generate the contents of the cache? if (generate) { // Dispose of existing values cache.Dispose(); // If c5 has a colour then use that to highlight the tab if (c5 != Color.Empty) { if (!standard) c5 = CommonHelper.MergeColors(c5, 0.65f, Color.Black, 0.35f); c1 = c5; c2 = CommonHelper.MergeColors(c2, 0.8f, ControlPaint.Light(c5), 0.2f); c3 = CommonHelper.MergeColors(c3, 0.7f, c5, 0.3f); } switch (orientation) { case VisualOrientation.Top: DrawRibbonTabTrackingTop2010(rect, c3, c4, cache); break; case VisualOrientation.Left: DrawRibbonTabTrackingLeft2010(rect, c3, c4, cache); break; case VisualOrientation.Right: DrawRibbonTabTrackingRight2010(rect, c3, c4, cache); break; case VisualOrientation.Bottom: DrawRibbonTabTrackingBottom2010(rect, c3, c4, cache); break; } cache.outsidePen = new Pen(c1); cache.outsideBrush = new SolidBrush(c2); } // Fill the full background context.Graphics.FillPath(cache.outsideBrush, cache.outsidePath); // Draw the border using (AntiAlias aa = new AntiAlias(context.Graphics)) context.Graphics.DrawPath(cache.outsidePen, cache.borderPath); // Fill the inside area context.Graphics.FillPath(cache.insideBrush, cache.insidePath); } return memento; }