/// <summary> /// Internal rendering method. /// </summary> protected override IDisposable DrawRibbonTabContext(RenderContext context, Rectangle rect, IPaletteRibbonGeneral paletteGeneral, IPaletteRibbonBack paletteBack, IDisposable memento) { if ((rect.Width > 0) && (rect.Height > 0)) { Color c1 = paletteGeneral.GetRibbonTabSeparatorContextColor(PaletteState.Normal); Color c2 = paletteBack.GetRibbonBackColor5(PaletteState.ContextCheckedNormal); bool generate = true; MementoRibbonTabContextOffice2010 cache; // Access a cache instance and decide if cache resources need generating if ((memento == null) || !(memento is MementoRibbonTabContextOffice2010)) { if (memento != null) { memento.Dispose(); } cache = new MementoRibbonTabContextOffice2010(rect, c1, c2); memento = cache; } else { cache = (MementoRibbonTabContextOffice2010)memento; generate = !cache.UseCachedValues(rect, c1, c2); } // Do we need to generate the contents of the cache? if (generate) { // Dispose of existing values cache.Dispose(); cache.borderOuterPen = new Pen(c1); cache.borderInnerPen = new Pen(CommonHelper.MergeColors(Color.Black, 0.1f, c2, 0.9f)); cache.topBrush = new SolidBrush(c2); Color lightC2 = ControlPaint.Light(c2); cache.bottomBrush = new LinearGradientBrush(new RectangleF(rect.X - 1, rect.Y, rect.Width + 2, rect.Height + 1), Color.FromArgb(128, lightC2), Color.FromArgb(64, lightC2), 90f); } // Draw the left and right borders context.Graphics.DrawLine(cache.borderOuterPen, rect.X, rect.Y, rect.X, rect.Bottom); context.Graphics.DrawLine(cache.borderInnerPen, rect.X + 1, rect.Y, rect.X + 1, rect.Bottom - 1); context.Graphics.DrawLine(cache.borderOuterPen, rect.Right - 1, rect.Y, rect.Right - 1, rect.Bottom - 1); context.Graphics.DrawLine(cache.borderInnerPen, rect.Right - 2, rect.Y, rect.Right - 2, rect.Bottom - 1); // Draw the solid block of colour at the top context.Graphics.FillRectangle(cache.topBrush, rect.X + 2, rect.Y, rect.Width - 4, 4); // Draw the gradient to the bottom context.Graphics.FillRectangle(cache.bottomBrush, rect.X + 2, rect.Y + 4, rect.Width - 4, rect.Height - 4); } return(memento); }
/// <summary> /// Gets the color for the tab context separator. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color value.</returns> public Color GetRibbonTabSeparatorContextColor(PaletteState state) { if (TabSeparatorColor != Color.Empty) { return(TabSeparatorContextColor); } else { return(_inherit.GetRibbonTabSeparatorContextColor(state)); } }
/// <summary> /// Gets the color for the tab context separators. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color value.</returns> public override Color GetRibbonTabSeparatorContextColor(PaletteState state) { IPaletteRibbonGeneral inherit = GetInherit(state); if (inherit != null) { return(inherit.GetRibbonTabSeparatorContextColor(state)); } else { return(Target.GetRibbonTabSeparatorContextColor(state)); } }
/// <summary> /// Internal rendering method. /// </summary> protected override IDisposable DrawRibbonTabContext(RenderContext context, Rectangle rect, IPaletteRibbonGeneral paletteGeneral, IPaletteRibbonBack paletteBack, IDisposable memento) { if ((rect.Width > 0) && (rect.Height > 0)) { Color c1 = paletteGeneral.GetRibbonTabSeparatorContextColor(PaletteState.Normal); Color c2 = paletteBack.GetRibbonBackColor5(PaletteState.ContextCheckedNormal); bool generate = true; MementoRibbonTabContextOffice cache; // Access a cache instance and decide if cache resources need generating if (!(memento is MementoRibbonTabContextOffice)) { memento?.Dispose(); cache = new MementoRibbonTabContextOffice(rect, c1, c2); memento = cache; } else { cache = (MementoRibbonTabContextOffice)memento; generate = !cache.UseCachedValues(rect, c1, c2); } // Do we need to generate the contents of the cache? if (generate) { // Dispose of existing values cache.Dispose(); Rectangle borderRect = new Rectangle(rect.X - 1, rect.Y - 1, rect.Width + 2, rect.Height + 2); cache.fillRect = new Rectangle(rect.X + 1, rect.Y, rect.Width - 2, rect.Height - 1); LinearGradientBrush borderBrush = new LinearGradientBrush(borderRect, c1, Color.Transparent, 270f) { Blend = _ribbonGroup5Blend }; cache.borderPen = new Pen(borderBrush); LinearGradientBrush underlineBrush = new LinearGradientBrush(borderRect, Color.Transparent, Color.FromArgb(200, c2), 0f) { Blend = _ribbonGroup7Blend }; cache.underlinePen = new Pen(underlineBrush); cache.fillBrush = new LinearGradientBrush(borderRect, Color.FromArgb(106, c2), Color.Transparent, 270f) { Blend = _ribbonGroup6Blend }; } // Draw the left and right border lines context.Graphics.DrawLine(cache.borderPen, rect.X, rect.Y, rect.X, rect.Bottom - 1); context.Graphics.DrawLine(cache.borderPen, rect.Right - 1, rect.Y, rect.Right - 1, rect.Bottom - 1); // Fill the inner area with a gradient context specific color context.Graphics.FillRectangle(cache.fillBrush, cache.fillRect); // Overdraw the brighter line at bottom context.Graphics.DrawLine(cache.underlinePen, rect.X + 1, rect.Bottom - 2, rect.Right - 2, rect.Bottom - 2); } return(memento); }
/// <summary> /// Gets the color for the tab context separators. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color value.</returns> public override Color GetRibbonTabSeparatorContextColor(PaletteState state) { IPaletteRibbonGeneral inherit = GetInherit(state); return(inherit?.GetRibbonTabSeparatorContextColor(state) ?? Target.GetRibbonTabSeparatorContextColor(state)); }
/// <summary> /// Internal rendering method. /// </summary> protected override IDisposable DrawRibbonTabContext(RenderContext context, Rectangle rect, IPaletteRibbonGeneral paletteGeneral, IPaletteRibbonBack paletteBack, IDisposable memento) { if ((rect.Width > 0) && (rect.Height > 0)) { Color c1 = paletteGeneral.GetRibbonTabSeparatorContextColor(PaletteState.Normal); Color c2 = paletteBack.GetRibbonBackColor5(PaletteState.ContextCheckedNormal); bool generate = true; MementoRibbonTabContextOffice2010 cache; // Access a cache instance and decide if cache resources need generating if ((memento == null) || !(memento is MementoRibbonTabContextOffice2010)) { if (memento != null) memento.Dispose(); cache = new MementoRibbonTabContextOffice2010(rect, c1, c2); memento = cache; } else { cache = (MementoRibbonTabContextOffice2010)memento; generate = !cache.UseCachedValues(rect, c1, c2); } // Do we need to generate the contents of the cache? if (generate) { // Dispose of existing values cache.Dispose(); cache.borderOuterPen = new Pen(c1); cache.borderInnerPen = new Pen(CommonHelper.MergeColors(Color.Black, 0.1f, c2, 0.9f)); cache.topBrush = new SolidBrush(c2); Color lightC2 = ControlPaint.Light(c2); cache.bottomBrush = new LinearGradientBrush(new RectangleF(rect.X - 1, rect.Y, rect.Width + 2, rect.Height + 1), Color.FromArgb(128, lightC2), Color.FromArgb(64, lightC2), 90f); } // Draw the left and right borders context.Graphics.DrawLine(cache.borderOuterPen, rect.X, rect.Y, rect.X, rect.Bottom); context.Graphics.DrawLine(cache.borderInnerPen, rect.X + 1, rect.Y, rect.X + 1, rect.Bottom - 1); context.Graphics.DrawLine(cache.borderOuterPen, rect.Right - 1, rect.Y, rect.Right - 1, rect.Bottom - 1); context.Graphics.DrawLine(cache.borderInnerPen, rect.Right - 2, rect.Y, rect.Right - 2, rect.Bottom - 1); // Draw the solid block of colour at the top context.Graphics.FillRectangle(cache.topBrush, rect.X + 2, rect.Y, rect.Width - 4, 4); // Draw the gradient to the bottom context.Graphics.FillRectangle(cache.bottomBrush, rect.X + 2, rect.Y + 4, rect.Width - 4, rect.Height - 4); } return memento; }
/// <summary> /// Internal rendering method. /// </summary> protected virtual IDisposable DrawRibbonTabContext(RenderContext context, Rectangle rect, IPaletteRibbonGeneral paletteGeneral, IPaletteRibbonBack paletteBack, IDisposable memento) { if ((rect.Width > 0) && (rect.Height > 0)) { Color c1 = paletteGeneral.GetRibbonTabSeparatorContextColor(PaletteState.Normal); Color c2 = paletteBack.GetRibbonBackColor5(PaletteState.ContextCheckedNormal); bool generate = true; MementoRibbonTabContext cache; // Access a cache instance and decide if cache resources need generating if ((memento == null) || !(memento is MementoRibbonTabContext)) { if (memento != null) memento.Dispose(); cache = new MementoRibbonTabContext(rect, c1, c2); memento = cache; } else { cache = (MementoRibbonTabContext)memento; generate = !cache.UseCachedValues(rect, c1, c2); } // Do we need to generate the contents of the cache? if (generate) { // Dispose of existing values cache.Dispose(); Rectangle borderRect = new Rectangle(rect.X - 1, rect.Y - 1, rect.Width + 2, rect.Height + 2); cache.fillRect = new Rectangle(rect.X + 1, rect.Y, rect.Width - 2, rect.Height - 1); LinearGradientBrush borderBrush = new LinearGradientBrush(borderRect, c1, Color.Transparent, 270f); borderBrush.Blend = _ribbonGroup5Blend; cache.borderPen = new Pen(borderBrush); LinearGradientBrush underlineBrush = new LinearGradientBrush(borderRect, Color.Transparent, Color.FromArgb(200, c2), 0f); underlineBrush.Blend = _ribbonGroup7Blend; cache.underlinePen = new Pen(underlineBrush); cache.fillBrush = new LinearGradientBrush(borderRect, Color.FromArgb(196, c2), Color.Transparent, 270f); cache.fillBrush.Blend = _ribbonGroup6Blend; } // Draw the left and right border lines context.Graphics.DrawLine(cache.borderPen, rect.X, rect.Y, rect.X, rect.Bottom - 1); context.Graphics.DrawLine(cache.borderPen, rect.Right - 1, rect.Y, rect.Right - 1, rect.Bottom - 1); // Fill the inner area with a gradient context specific color context.Graphics.FillRectangle(cache.fillBrush, cache.fillRect); // Overdraw the brighter line at bottom context.Graphics.DrawLine(cache.underlinePen, rect.X + 1, rect.Bottom - 1, rect.Right - 2, rect.Bottom - 1); } return memento; }