/// <summary> /// Initialize a new instance of the PaletteRibbonTabContentInheritOverride class. /// </summary> /// <param name="primaryBack">First choice inheritence background.</param> /// <param name="primaryText">First choice inheritence text.</param> /// <param name="primaryContent">First choice inheritence content.</param> /// <param name="backupBack">Backup inheritence background.</param> /// <param name="backupText">Backup inheritence text.</param> /// <param name="backupContent">Backup inheritence content.</param> /// <param name="state">Palette state to override.</param> public PaletteRibbonTabContentInheritOverride(IPaletteRibbonBack primaryBack, IPaletteRibbonText primaryText, IPaletteContent primaryContent, IPaletteRibbonBack backupBack, IPaletteRibbonText backupText, IPaletteContent backupContent, PaletteState state) { Debug.Assert(primaryBack != null); Debug.Assert(primaryText != null); Debug.Assert(primaryContent != null); Debug.Assert(backupBack != null); Debug.Assert(backupText != null); Debug.Assert(backupContent != null); // Remember values _primaryBack = primaryBack; _primaryText = primaryText; _primaryContent = primaryContent; _backupBack = backupBack; _backupText = backupText; _backupContent = backupContent; // Default state _apply = false; _override = true; _state = state; }
/// <summary> /// Initialize a new instance of the PaletteRedirectRibbonDouble class. /// </summary> /// <param name="target">Initial palette target for redirection.</param> /// <param name="disabledBack">Redirection for back disabled state requests.</param> /// <param name="normalBack">Redirection for back normal state requests.</param> /// <param name="pressedBack">Redirection for back pressed state requests.</param> /// <param name="trackingBack">Redirection for back tracking state requests.</param> /// <param name="selectedBack">Redirection for selected states requests.</param> /// <param name="focusOverrideBack">Redirection for back focus override state requests.</param> /// <param name="disabledText">Redirection for text disabled state requests.</param> /// <param name="normalText">Redirection for text normal state requests.</param> /// <param name="pressedText">Redirection for text pressed state requests.</param> /// <param name="trackingText">Redirection for text tracking state requests.</param> /// <param name="selectedText">Redirection for text selected states requests.</param> /// <param name="focusOverrideText">Redirection for text focus override state requests.</param> public PaletteRedirectRibbonDouble(IPalette target, IPaletteRibbonBack disabledBack, IPaletteRibbonBack normalBack, IPaletteRibbonBack pressedBack, IPaletteRibbonBack trackingBack, IPaletteRibbonBack selectedBack, IPaletteRibbonBack focusOverrideBack, IPaletteRibbonText disabledText, IPaletteRibbonText normalText, IPaletteRibbonText pressedText, IPaletteRibbonText trackingText, IPaletteRibbonText selectedText, IPaletteRibbonText focusOverrideText ) : base(target) { // Remember state specific inheritance _disabledBack = disabledBack; _normalBack = normalBack; _pressedBack = pressedBack; _trackingBack = trackingBack; _selectedBack = selectedBack; _focusOverrideBack = focusOverrideBack; _disabledText = disabledText; _normalText = normalText; _pressedText = pressedText; _trackingText = trackingText; _selectedText = selectedText; _focusOverrideText = focusOverrideText; }
/// <summary> /// Initialize a new instance of the ViewDrawRibbonContextTitle class. /// </summary> /// <param name="ribbon">Source ribbon control.</param> /// <param name="inherit">Source for inheriting the ribbon bacgkground colors.</param> public ViewDrawRibbonContextTitle(KryptonRibbon ribbon, IPaletteRibbonBack inherit) { Debug.Assert(ribbon != null); Debug.Assert(inherit != null); // Remember incoming references _inherit = inherit; _ribbon = ribbon; // Use a class to convert from ribbon tab to content interface _contentProvider = new ContextToContent(ribbon.StateCommon.RibbonGeneral); }
/// <summary> /// Initialize a new instance of the PaletteRibbonTabContent class. /// </summary> /// <param name="paletteBack">Source for inheriting palette ribbon background.</param> /// <param name="paletteText">Source for inheriting palette ribbon text.</param> /// <param name="paletteContent">Source for inheriting palette content.</param> /// <param name="needPaint">Delegate for notifying paint requests.</param> public PaletteRibbonTabContent(IPaletteRibbonBack paletteBack, IPaletteRibbonText paletteText, IPaletteContent paletteContent, NeedPaintHandler needPaint) { Debug.Assert(paletteBack != null); Debug.Assert(paletteText != null); Debug.Assert(paletteContent != null); // Store the provided paint notification delegate NeedPaint = needPaint; // Create storage that maps onto the inherit instances _paletteTabDraw = new PaletteRibbonDouble(paletteBack, paletteText, needPaint); _paletteContent = new PaletteNavContent(paletteContent, needPaint); }
/// <summary> /// Initialize a new instance of the PaletteRedirectRibbonBack class. /// </summary> /// <param name="target">Initial palette target for redirection.</param> /// <param name="disabledBack">Redirection for back disabled state requests.</param> /// <param name="normalBack">Redirection for back normal state requests.</param> /// <param name="pressedBack">Redirection for back pressed state requests.</param> /// <param name="trackingBack">Redirection for back tracking state requests.</param> /// <param name="selectedBack">Redirection for selected states requests.</param> /// <param name="focusOverrideBack">Redirection for back focus override state requests.</param> public PaletteRedirectRibbonBack(IPalette target, IPaletteRibbonBack disabledBack, IPaletteRibbonBack normalBack, IPaletteRibbonBack pressedBack, IPaletteRibbonBack trackingBack, IPaletteRibbonBack selectedBack, IPaletteRibbonBack focusOverrideBack) : base(target) { // Remember state specific inheritance _disabledBack = disabledBack; _normalBack = normalBack; _pressedBack = pressedBack; _trackingBack = trackingBack; _selectedBack = selectedBack; _focusOverrideBack = focusOverrideBack; }
/// <summary> /// Initialize a new instance of the PaletteRibbonBack class. /// </summary> /// <param name="inheritBack">Source for inheriting background values.</param> /// <param name="needPaint">Delegate for notifying changes in value.</param> public PaletteRibbonBack(IPaletteRibbonBack inheritBack, NeedPaintHandler needPaint) { Debug.Assert(inheritBack != null); // Remember inheritance _inheritBack = inheritBack; // Store the provided paint notification delegate NeedPaint = needPaint; // Define default values _backColor1 = Color.Empty; _backColor2 = Color.Empty; _backColor3 = Color.Empty; _backColor4 = Color.Empty; _backColor5 = Color.Empty; }
/// <summary> /// Sets the inheritence parent. /// </summary> public void SetInherit(IPaletteRibbonBack inherit) { _inherit = inherit; }
/// <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 == null) || !(memento is MementoRibbonTabContextOffice)) { if (memento != null) { 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); 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(106, 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 - 2, rect.Right - 2, rect.Bottom - 2); } 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; }
/// <summary> /// Sets the inheritence parent. /// </summary> public void SetInherit(IPaletteRibbonBack paletteBack, IPaletteRibbonText paletteText, IPaletteContent paletteContent) { _paletteTabDraw.SetInherit(paletteBack, paletteText); _paletteContent.SetInherit(paletteContent); }
/// <summary> /// Internal rendering method. /// </summary> 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; }
/// <summary> /// Internal rendering method. /// </summary> 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; }
/// <summary> /// Internal rendering method. /// </summary> protected virtual IDisposable DrawRibbonQATOverflow(PaletteRibbonShape shape, RenderContext context, Rectangle rect, PaletteState state, IPaletteRibbonBack palette, IDisposable memento) { if ((rect.Width > 0) && (rect.Height > 0)) { Color c1 = palette.GetRibbonBackColor1(state); Color c2 = palette.GetRibbonBackColor2(state); bool generate = true; MementoRibbonQATOverflow cache; // Access a cache instance and decide if cache resources need generating if ((memento == null) || !(memento is MementoRibbonQATOverflow)) { if (memento != null) memento.Dispose(); cache = new MementoRibbonQATOverflow(rect, c1, c2); memento = cache; } else { cache = (MementoRibbonQATOverflow)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.backBrush = new SolidBrush(c1); cache.borderPen = new Pen(c2); } // Draw a gradient for the inside of the area context.Graphics.FillRectangle(cache.backBrush, rect); using (AntiAlias aa = new AntiAlias(context.Graphics)) { if (shape == PaletteRibbonShape.Office2010) { context.Graphics.DrawPolygon(cache.borderPen, new Point[]{ new Point(rect.Left + 1, rect.Top), new Point(rect.Right - 2, rect.Top), new Point(rect.Right - 1, rect.Top + 1), new Point(rect.Right - 1, rect.Bottom - 2), new Point(rect.Right - 2, rect.Bottom - 1), new Point(rect.Left + 1, rect.Bottom - 1), new Point(rect.Left, rect.Bottom - 2), new Point(rect.Left, rect.Top + 1) } ); } else { context.Graphics.DrawLine(cache.borderPen, rect.Left + 1f, rect.Top, rect.Right - 2f, rect.Top); context.Graphics.DrawLine(cache.borderPen, rect.Right - 2f, rect.Top, rect.Right - 1f, rect.Top + 2f); context.Graphics.DrawLine(cache.borderPen, rect.Right - 1f, rect.Top + 2f, rect.Right - 1f, rect.Bottom - 2f); context.Graphics.DrawLine(cache.borderPen, rect.Right - 1f, rect.Bottom - 2f, rect.Right - 2f, rect.Bottom - 1f); context.Graphics.DrawLine(cache.borderPen, rect.Right - 2f, rect.Bottom - 1f, rect.Left + 1f, rect.Bottom - 1f); context.Graphics.DrawLine(cache.borderPen, rect.Left + 1f, rect.Bottom - 1f, rect.Left, rect.Bottom - 2f); context.Graphics.DrawLine(cache.borderPen, rect.Left, rect.Bottom - 2f, rect.Left, rect.Top + 1f); context.Graphics.DrawLine(cache.borderPen, rect.Left, rect.Top + 1f, rect.Left + 1f, rect.Top); } } } return memento; }
/// <summary> /// Internal rendering method. /// </summary> protected virtual IDisposable DrawRibbonTabContextSelected(PaletteRibbonShape shape, 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); bool generate = true; MementoRibbonTabContextSelected cache; // Access a cache instance and decide if cache resources need generating if ((memento == null) || !(memento is MementoRibbonTabContextSelected)) { if (memento != null) memento.Dispose(); cache = new MementoRibbonTabContextSelected(rect, c1, c2, orientation); memento = cache; } else { cache = (MementoRibbonTabContextSelected)memento; generate = !cache.UseCachedValues(rect, c1, c2, orientation); } // Do we need to generate the contents of the cache? if (generate) { // Dispose of existing values cache.Dispose(); switch (orientation) { case VisualOrientation.Top: DrawRibbonTabContextSelectedTop(rect, c2, cache); break; case VisualOrientation.Left: DrawRibbonTabContextSelectedLeft(rect, c2, cache); break; case VisualOrientation.Right: DrawRibbonTabContextSelectedRight(rect, c2, cache); break; case VisualOrientation.Bottom: DrawRibbonTabContextSelectedBottom(rect, c2, cache); break; } cache.outsidePen = new Pen(c1); cache.l1 = new Pen(Color.FromArgb(100, c2)); cache.l2 = new Pen(Color.FromArgb(75, c2)); cache.l3 = new Pen(Color.FromArgb(48, c2)); cache.bottomInnerPen = new Pen(Color.FromArgb(70, c2)); cache.bottomOuterPen = new Pen(Color.FromArgb(100, c2)); } // Fill the interior using a gradient brush context.Graphics.FillRectangle(Brushes.White, cache.interiorRect); context.Graphics.FillRectangle(cache.insideBrush, cache.interiorRect); // Draw the actual border using (AntiAlias aa = new AntiAlias(context.Graphics)) context.Graphics.DrawPath(cache.outsidePen, cache.outsidePath); switch (orientation) { case VisualOrientation.Top: DrawRibbonTabContextSelectedTopDraw(rect, cache, context.Graphics); break; case VisualOrientation.Left: DrawRibbonTabContextSelectedLeftDraw(rect, cache, context.Graphics); break; case VisualOrientation.Right: DrawRibbonTabContextSelectedRightDraw(rect, cache, context.Graphics); break; case VisualOrientation.Bottom: DrawRibbonTabContextSelectedBottomDraw(rect, cache, context.Graphics); break; } } return memento; }
/// <summary> /// Initialize a new instance of the PaletteRedirectRibbonBack class. /// </summary> /// <param name="target">Initial palette target for redirection.</param> /// <param name="disabledBack">Redirection for back disabled state requests.</param> /// <param name="normalBack">Redirection for back normal state requests.</param> public PaletteRedirectRibbonBack(IPalette target, IPaletteRibbonBack disabledBack, IPaletteRibbonBack normalBack) : this(target, disabledBack, normalBack, null, null, null, null) { }
/// <summary> /// Internal rendering method. /// </summary> protected virtual IDisposable DrawRibbonQATFullbarSquare(RenderContext context, Rectangle rect, PaletteState state, IPaletteRibbonBack palette, IDisposable memento) { if ((rect.Width > 0) && (rect.Height > 0)) { Color c1 = palette.GetRibbonBackColor1(state); Color c2 = palette.GetRibbonBackColor2(state); Color c3 = palette.GetRibbonBackColor3(state); bool generate = true; MementoRibbonQATFullbarSquare cache; // Access a cache instance and decide if cache resources need generating if ((memento == null) || !(memento is MementoRibbonQATFullbarSquare)) { if (memento != null) memento.Dispose(); cache = new MementoRibbonQATFullbarSquare(rect, c1, c2, c3); memento = cache; } else { cache = (MementoRibbonQATFullbarSquare)memento; generate = !cache.UseCachedValues(rect, c1, c2, c3); } // Do we need to generate the contents of the cache? if (generate) { // Dispose of existing values cache.Dispose(); cache.lightPen = new Pen(c1); cache.mediumBrush = new SolidBrush(c2); cache.darkPen = new Pen(c3); } // Fill entire area in background brush context.Graphics.FillRectangle(cache.mediumBrush, rect); // Draw the outside border context.Graphics.DrawRectangle(cache.darkPen, rect.X, rect.Y, rect.Width - 1, rect.Height - 1); // Draw ligher top and bottom lines context.Graphics.DrawLine(cache.lightPen, rect.X + 1, rect.Y + 1, rect.Width - 2, rect.Y + 1); context.Graphics.DrawLine(cache.lightPen, rect.X + 1, rect.Bottom - 2, rect.Width - 2, rect.Bottom - 2); } return memento; }
/// <summary> /// Gets the fifth background color for the ribbon item. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <param name="style">Style of the ribbon color requested.</param> /// <returns>Color value.</returns> public override Color GetRibbonBackColor5(PaletteRibbonBackStyle style, PaletteState state) { IPaletteRibbonBack inherit = GetBackInherit(state); return(inherit?.GetRibbonBackColor5(state) ?? Target.GetRibbonBackColor5(style, 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 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 override 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.FillRectangle(cache.centerBrush, cache.rect); //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); context.Graphics.DrawRectangle(cache.outsidePen, cache.rect); //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); }
private void CheckPaletteState(ViewContext context) { // Default to using this element calculated state PaletteState buttonState = State; // If the actual control is not enabled, force to disabled state if (!IsFixed && !context.Control.Enabled) { buttonState = PaletteState.Disabled; } else if (buttonState == PaletteState.Disabled) { buttonState = PaletteState.Normal; } if (!IsFixed) { if (Checked) { switch (buttonState) { case PaletteState.Normal: case PaletteState.CheckedNormal: buttonState = PaletteState.CheckedNormal; break; case PaletteState.Tracking: case PaletteState.CheckedTracking: buttonState = PaletteState.CheckedTracking; break; case PaletteState.Pressed: case PaletteState.CheckedPressed: buttonState = PaletteState.CheckedPressed; break; } } else { switch (buttonState) { case PaletteState.Normal: case PaletteState.CheckedNormal: buttonState = PaletteState.Normal; break; case PaletteState.Tracking: case PaletteState.CheckedTracking: buttonState = PaletteState.Tracking; break; case PaletteState.Pressed: case PaletteState.CheckedPressed: buttonState = PaletteState.Pressed; break; } } } // Set the correct palette based on state switch (buttonState) { case PaletteState.Disabled: _currentText = Navigator.StateDisabled.RibbonTab.TabDraw; _currentBack = Navigator.StateDisabled.RibbonTab.TabDraw; _currentContent = Navigator.StateDisabled.RibbonTab.Content; break; case PaletteState.Normal: _currentText = _overrideStateNormal; _currentBack = _overrideStateNormal; _currentContent = _overrideStateNormal; break; case PaletteState.Tracking: _currentText = _overrideStateTracking; _currentBack = _overrideStateTracking; _currentContent = _overrideStateTracking; break; case PaletteState.Pressed: _currentText = _overrideStatePressed; _currentBack = _overrideStatePressed; _currentContent = _overrideStatePressed; break; case PaletteState.CheckedNormal: case PaletteState.CheckedTracking: case PaletteState.CheckedPressed: _currentText = _overrideStateSelected; _currentBack = _overrideStateSelected; _currentContent = _overrideStateSelected; break; default: // Should never happen! Debug.Assert(false); break; } // Switch the child elements over to correct state ElementState = buttonState; this[0][0].ElementState = buttonState; // Update content palette with the current ribbon text palette _contentProvider.PaletteRibbonText = _currentText; _contentProvider.PaletteContent = _currentContent; }
/// <summary> /// Internal rendering method. /// </summary> protected virtual IDisposable DrawRibbonQATMinibarSingle(RenderContext context, Rectangle rect, PaletteState state, IPaletteRibbonBack palette, bool composition, 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; MementoRibbonQATMinibar cache; // Access a cache instance and decide if cache resources need generating if ((memento == null) || !(memento is MementoRibbonQATMinibar)) { if (memento != null) memento.Dispose(); cache = new MementoRibbonQATMinibar(rect, c1, c2, c3, c4, c5); memento = cache; } else { cache = (MementoRibbonQATMinibar)memento; generate = !cache.UseCachedValues(rect, c1, c2, c3, c4, c5); } // Do we need to generate the contents of the cache? if (generate) { // Dispose of existing values cache.Dispose(); GraphicsPath borderPath = new GraphicsPath(); GraphicsPath topRight1 = new GraphicsPath(); GraphicsPath bottomLeft1 = new GraphicsPath(); // Find values needed for drawing the main border int left = rect.X + 1; int right = rect.Right - 3; int top = rect.Y + 2; int bottom = rect.Bottom - 3; int middle = top + (bottom - top) / 2; // Construct closed path for the main border borderPath.AddLine(right - 8, bottom, left + 10.75f, bottom); borderPath.AddLine(left + 10.75f, bottom, left + 10, bottom - 8f); borderPath.AddLine(left + 10, bottom - 8f, left + 9, bottom - 11f); borderPath.AddLine(left + 9, bottom - 11f, left + 8, bottom - 13f); borderPath.AddLine(left + 8, bottom - 13f, left + 7, bottom - 15f); borderPath.AddLine(left + 7, bottom - 15f, left + 1, top + 0.25f); borderPath.AddLine(left + 1, top + 0.25f, left - 1, top + 0.25f); borderPath.AddLine(left - 1, top + 0.25f, right - 8, top + 0.25f); borderPath.AddLine(right - 8, top + 0.25f, right - 5, top + 1); borderPath.AddLine(right - 5, top + 1, right - 1, top + 5); borderPath.AddLine(right - 1, top + 5, right, top + 8); borderPath.AddLine(right, top + 8, right + 0.40f, middle); borderPath.AddLine(right + 0.40f, middle, right, bottom - 8.25f); borderPath.AddLine(right, bottom - 8.25f, right - 1, bottom - 5.25f); borderPath.AddLine(right - 1, bottom - 5.25f, right - 5, bottom - 1.25f); borderPath.AddLine(right - 5, bottom - 1.25f, right - 8, bottom); // Create the top right light paths topRight1.AddLine(rect.Left - 1, rect.Top + 1.25f, rect.Right - 11, rect.Top + 1.25f); topRight1.AddLine(rect.Right - 11, rect.Top + 1.5f, rect.Right - 8, rect.Top + 2.25f); topRight1.AddLine(rect.Right - 8, rect.Top + 2.25f, rect.Right - 5, rect.Top + 5.75f); // Create the bottom left light paths bottomLeft1.AddLine(rect.Left + 10.75f, rect.Bottom - 11, rect.Left + 10.75f, rect.Bottom - 5); bottomLeft1.AddLine(rect.Left + 10.75f, rect.Bottom - 5, rect.Left + 13, rect.Bottom - 2); bottomLeft1.AddLine(rect.Left + 13, rect.Bottom - 2, rect.Right - 11, rect.Bottom - 2); bottomLeft1.AddLine(rect.Right - 11, rect.Bottom - 2, rect.Right - 8.5f, rect.Bottom - 3); bottomLeft1.AddLine(rect.Right - 8.5f, rect.Bottom - 3, rect.Right - 4.5f, rect.Bottom - 7); bottomLeft1.AddLine(rect.Right - 4.5f, rect.Bottom - 7, rect.Right - 2.5f, rect.Bottom - 9); bottomLeft1.AddLine(rect.Right - 2.5f, rect.Bottom - 9, rect.Right - 2, rect.Bottom - 11); bottomLeft1.AddLine(rect.Right - 2, rect.Bottom - 11, rect.Right - 2, rect.Bottom - 15); RectangleF gradientRect = rect; gradientRect.Y += 1.5f; gradientRect.Height *= 1.25f; cache.innerBrush = new LinearGradientBrush(gradientRect, c2, c3, 90f); cache.innerBrush.SetSigmaBellShape(0.5f); cache.borderPath = borderPath; cache.topRight1 = topRight1; cache.bottomLeft1 = bottomLeft1; cache.lightPen = new Pen(c4, 2f); cache.borderPen = new Pen(c1); cache.whitenPen = new Pen(c5); } using (AntiAlias aa = new AntiAlias(context.Graphics)) { if (!composition) { // Draw the light borders context.Graphics.DrawPath(cache.lightPen, cache.topRight1); context.Graphics.DrawPath(cache.lightPen, cache.bottomLeft1); // Draw the inside background and main border context.Graphics.FillPath(cache.innerBrush, cache.borderPath); context.Graphics.DrawPath(cache.borderPen, cache.borderPath); // Overdraw top for lighter effect context.Graphics.DrawLine(cache.whitenPen, rect.Left + 10, rect.Top + 2, rect.Right - 10, rect.Top + 2); context.Graphics.DrawLine(cache.whitenPen, rect.Left + 12, rect.Top + 3, rect.Right - 8, rect.Top + 3); context.Graphics.DrawLine(cache.whitenPen, rect.Left + 14, rect.Top + 4, rect.Right - 7, rect.Top + 4); } else { // Fill with a semi-transparent background/border context.Graphics.FillPath(_compositionBrush, cache.borderPath); context.Graphics.DrawPath(_compositionPen, cache.borderPath); } } } return memento; }
/// <summary> /// Sets the inheritence parent. /// </summary> public void SetInherit(IPaletteRibbonBack inheritBack, IPaletteRibbonText inheritText) { _inheritBack = inheritBack; _inheritText = inheritText; }
/// <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; }
/// <summary> /// Sets the inheritence parent. /// </summary> public void SetInherit(IPaletteRibbonBack inheritBack) { _inheritBack = inheritBack; }
/// <summary> /// Internal rendering method. /// </summary> protected virtual IDisposable DrawRibbonTabGlowing(PaletteRibbonShape shape, 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 insideColor = Color.FromArgb(36, c2); bool generate = true; MementoRibbonTabGlowing cache; // Access a cache instance and decide if cache resources need generating if ((memento == null) || !(memento is MementoRibbonTabGlowing)) { if (memento != null) memento.Dispose(); cache = new MementoRibbonTabGlowing(rect, c1, c2, insideColor, orientation); memento = cache; } else { cache = (MementoRibbonTabGlowing)memento; generate = !cache.UseCachedValues(rect, c1, c2, insideColor, orientation); } // Do we need to generate the contents of the cache? if (generate) { // Dispose of existing values cache.Dispose(); switch (orientation) { case VisualOrientation.Top: DrawRibbonTabGlowingTop(rect, c1, c2, insideColor, cache); break; case VisualOrientation.Left: DrawRibbonTabGlowingLeft(rect, c1, c2, insideColor, cache); break; case VisualOrientation.Right: DrawRibbonTabGlowingRight(rect, c1, c2, insideColor, cache); break; case VisualOrientation.Bottom: DrawRibbonTabGlowingBottom(rect, c1, c2, insideColor, cache); break; } } // Fill the path area with inside color context.Graphics.FillPath(cache.insideBrush, cache.outsidePath); switch (orientation) { case VisualOrientation.Top: // Draw the missing line from the bottom of the inside area context.Graphics.DrawLine(cache.insidePen, rect.Left + 1, rect.Bottom - 2, rect.Right - 2, rect.Bottom - 2); break; case VisualOrientation.Left: // Draw the missing line from the right of the inside area context.Graphics.DrawLine(cache.insidePen, rect.Right - 2, rect.Top + 1, rect.Right - 2, rect.Bottom - 2); break; } // Draw the border over the edge of the inside color using (AntiAlias aa = new AntiAlias(context.Graphics)) context.Graphics.DrawPath(cache.outsidePen, cache.outsidePath); // Draw the top glass effect context.Graphics.FillPath(cache.topBrush, cache.topPath); // Cannot draw a path that contains a zero sized element if ((cache.ellipseRect.Width > 0) && (cache.ellipseRect.Height > 0)) context.Graphics.FillRectangle(cache.ellipseBrush, cache.fullRect); } return memento; }
/// <summary> /// Internal rendering method. /// </summary> protected virtual IDisposable DrawRibbonGroupNormalBorder(RenderContext context, Rectangle rect, PaletteState state, IPaletteRibbonBack palette, bool tracking, bool lightInside, IDisposable memento) { if ((rect.Width > 0) && (rect.Height > 0)) { Color c1 = palette.GetRibbonBackColor1(state); Color c2 = palette.GetRibbonBackColor2(state); bool generate = true; MementoRibbonGroupNormalBorder cache; // Access a cache instance and decide if cache resources need generating if ((memento == null) || !(memento is MementoRibbonGroupNormalBorder)) { if (memento != null) memento.Dispose(); cache = new MementoRibbonGroupNormalBorder(rect, c1, c2); memento = cache; } else { cache = (MementoRibbonGroupNormalBorder)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(); GraphicsPath solidPath = new GraphicsPath(); GraphicsPath insidePath = new GraphicsPath(); GraphicsPath outsidePath = new GraphicsPath(); GraphicsPath lightPath = new GraphicsPath(); // Create the rounded complete border solidPath.AddLine(rect.Left + 2, rect.Top, rect.Right - 4, rect.Top); solidPath.AddLine(rect.Right - 4, rect.Top, rect.Right - 2, rect.Top + 2); solidPath.AddLine(rect.Right - 2, rect.Top + 2, rect.Right - 2, rect.Bottom - 4); solidPath.AddLine(rect.Right - 2, rect.Bottom - 4, rect.Right - 4, rect.Bottom - 2); solidPath.AddLine(rect.Right - 4, rect.Bottom - 2, rect.Left + 2, rect.Bottom - 2); solidPath.AddLine(rect.Left + 2, rect.Bottom - 2, rect.Left, rect.Bottom - 4); solidPath.AddLine(rect.Left, rect.Bottom - 4, rect.Left, rect.Top + 2); solidPath.AddLine(rect.Left, rect.Top + 2, rect.Left + 2, rect.Top); // Create the inside top and left path insidePath.AddLine(rect.Right - 4, rect.Top + 1, rect.Left + 2, rect.Top + 1); insidePath.AddLine(rect.Left + 2, rect.Top + 1, rect.Left + 1, rect.Top + 2); insidePath.AddLine(rect.Left + 1, rect.Top + 2, rect.Left + 1, rect.Bottom - 4); // Create the outside right and bottom path outsidePath.AddLine(rect.Right - 1, rect.Top + 2, rect.Right - 1, rect.Bottom - 3); outsidePath.AddLine(rect.Right - 1, rect.Bottom - 3, rect.Right - 3, rect.Bottom - 1); outsidePath.AddLine(rect.Right - 3, rect.Bottom - 1, rect.Left + 3, rect.Bottom - 1); // Optional path for lightening area lightPath.AddLine(rect.Left + 2, rect.Top + 1, rect.Right - 4, rect.Top + 1); lightPath.AddLine(rect.Right - 4, rect.Top + 1, rect.Right - 3, rect.Top + 2); lightPath.AddLine(rect.Right - 3, rect.Top + 2, rect.Right - 3, rect.Bottom - 4); lightPath.AddLine(rect.Right - 3, rect.Bottom - 4, rect.Right - 4, rect.Bottom - 3); lightPath.AddLine(rect.Right - 4, rect.Bottom - 3, rect.Left + 2, rect.Bottom - 3); lightPath.AddLine(rect.Left + 2, rect.Bottom - 3, rect.Left + 1, rect.Bottom - 4); lightPath.AddLine(rect.Left + 1, rect.Bottom - 4, rect.Left + 1, rect.Top + 2); lightPath.AddLine(rect.Left + 1, rect.Top + 2, rect.Left + 2, rect.Top + 1); RectangleF solidRectF = new RectangleF(rect.Left - 1, rect.Top - 1, rect.Width + 2, rect.Height + 2); LinearGradientBrush solidBrush = new LinearGradientBrush(solidRectF, c1, c2, 90f); cache.solidPen = new Pen(solidBrush); cache.backRect = new Rectangle(rect.Left + 2, rect.Top + 1, rect.Width - 4, rect.Height - 4); cache.solidPath = solidPath; cache.insidePath = insidePath; cache.outsidePath = outsidePath; cache.lightPath = lightPath; } // If tracking, lighten the background if (tracking) context.Graphics.FillRectangle(lightInside ? _whitenLightLBrush : _whitenLightBrush, cache.backRect); using (AntiAlias aa = new AntiAlias(context.Graphics)) { // Draw the solid border context.Graphics.DrawPath(cache.solidPen, cache.solidPath); // Do now draw the inside and outside paths if ligtening the inside anyway if (!lightInside) { // Draw the two areas that make a lighter shadow to the right and bottom of border context.Graphics.DrawPath(_whitenMediumPen, cache.insidePath); context.Graphics.DrawPath(_whitenMediumPen, cache.outsidePath); } } if (lightInside) context.Graphics.DrawPath(Pens.White, cache.lightPath); } return memento; }
/// <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; }
/// <summary> /// Internal rendering method. /// </summary> protected virtual IDisposable DrawRibbonGroupNormalBorderSep(bool showingInPopup, RenderContext context, Rectangle rect, PaletteState state, IPaletteRibbonBack palette, IDisposable memento, bool pressed, bool tracking, bool dark) { 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; MementoRibbonGroupNormalBorderSep cache; // Access a cache instance and decide if cache resources need generating if ((memento == null) || !(memento is MementoRibbonGroupNormalBorderSep)) { if (memento != null) memento.Dispose(); cache = new MementoRibbonGroupNormalBorderSep(rect, c1, c2, c3, c4, c5, tracking, dark); memento = cache; } else { cache = (MementoRibbonGroupNormalBorderSep)memento; generate = !cache.UseCachedValues(rect, c1, c2, c3, c4, c5, tracking, dark); } // Do we need to generate the contents of the cache? if (generate) { // Dispose of existing values cache.Dispose(); RectangleF rectF = new RectangleF(rect.X - 1, rect.Y - 1, rect.Width + 2, rect.Height + 2); cache.totalBrush = new LinearGradientBrush(rectF, c2, c1, 90f); cache.innerBrush = new LinearGradientBrush(rectF, c4, c3, 90f); cache.trackSepBrush = new LinearGradientBrush(rectF, c5, c2, 90f); cache.totalBrush.Blend = _ribbonGroup9Blend; cache.innerBrush.Blend = _ribbonGroup9Blend; cache.trackSepBrush.Blend = _ribbonGroup9Blend; cache.innerPen = new Pen(cache.innerBrush); cache.trackSepPen = new Pen(cache.trackSepBrush); cache.trackBottomPen = new Pen(c5); GraphicsPath trackingPath = new GraphicsPath(); trackingPath.AddEllipse(new Rectangle(rect.X, rect.Y + (rect.Height / 2), rect.Width - 3, rect.Height)); cache.trackHighlightBrush = new PathGradientBrush(trackingPath); cache.trackHighlightBrush.SurroundColors = new Color[] { Color.Transparent }; cache.trackHighlightBrush.CenterColor = (dark ? (rect.Width > 50 ? _whiten60 : _whiten45) : _whiten160); cache.trackHighlightBrush.CenterPoint = new PointF(rect.X + (rect.Width - 3) / 2, rect.Height); cache.trackFillBrush = new LinearGradientBrush(new RectangleF(rect.X - 1, rect.Y - 1, rect.Width + 2, rect.Height + 1), (dark ? _whiten5 : _whiten10), (dark ? _whiten5 : _darken5), 90f); cache.pressedFillBrush = new LinearGradientBrush(new RectangleF(rect.X - 1, rect.Y - 1, rect.Width + 2, rect.Height + 2), (dark ? Color.Empty : _whiten10), (dark ? _darken38 : _darken16), 90f); cache.trackFillBrush.Blend = _linear50Blend; } if (!showingInPopup) { context.Graphics.FillRectangle(cache.totalBrush, rect.Right - 3, rect.Top, 3, rect.Height); context.Graphics.DrawLine(cache.innerPen, rect.Right - 2, rect.Top, rect.Right - 2, rect.Bottom - 1); } if (tracking || pressed) { if (pressed) { // Lighent the top and darken the bottom of the fill area context.Graphics.FillRectangle(cache.pressedFillBrush, rect.X, rect.Y, rect.Width - 2, rect.Height); } else if (tracking) { // Lighten the top and darken the bottom of the fill area context.Graphics.FillRectangle(cache.trackFillBrush, rect.X, rect.Y, rect.Width - 1, rect.Height - 1); // Draw the tracking highlight at bottom of area context.Graphics.FillRectangle(cache.trackHighlightBrush, rect.X, rect.Y, rect.Width - 1, rect.Height - 1); } if (!showingInPopup && !pressed && !dark) { // Lighten the right inner edge context.Graphics.DrawLine(cache.trackSepPen, rect.Right - 3, rect.Top, rect.Right - 3, rect.Bottom - 1); } if (!showingInPopup && tracking) { // Lighten the bottom inner edge context.Graphics.DrawLine(cache.trackBottomPen, rect.Right - 3, rect.Bottom - 1, rect.Left, rect.Bottom - 1); } } } return memento; }
/// <summary> /// Internal rendering method. /// </summary> protected virtual IDisposable DrawRibbonTabTracking2007(PaletteRibbonShape shape, 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); bool generate = true; MementoRibbonTabTracking2007 cache; // Access a cache instance and decide if cache resources need generating if ((memento == null) || !(memento is MementoRibbonTabTracking2007)) { if (memento != null) memento.Dispose(); cache = new MementoRibbonTabTracking2007(rect, c1, c2, orientation); memento = cache; } else { cache = (MementoRibbonTabTracking2007)memento; generate = !cache.UseCachedValues(rect, c1, c2, orientation); } // Do we need to generate the contents of the cache? if (generate) { // Dispose of existing values cache.Dispose(); switch (orientation) { case VisualOrientation.Top: DrawRibbonTabTrackingTop2007(rect, c1, c2, cache); break; case VisualOrientation.Left: DrawRibbonTabTrackingLeft2007(rect, c1, c2, cache); break; case VisualOrientation.Right: DrawRibbonTabTrackingRight2007(rect, c1, c2, cache); break; case VisualOrientation.Bottom: DrawRibbonTabTrackingBottom2007(rect, c1, c2, cache); break; } } // Draw the left and right sides with light version of tracking color context.Graphics.FillRectangle(cache.half1LeftBrush, cache.half1Rect); context.Graphics.FillRectangle(cache.half1RightBrush, cache.half1Rect); // Draw over with glassy effect context.Graphics.FillRectangle(cache.half1LightBrush, cache.half1Rect); //// Use a solid fill for the bottom half context.Graphics.FillRectangle(cache.half2Brush, cache.half2Rect); // Cannot draw a path that contains a zero sized element if ((cache.ellipseRect.Width > 0) && (cache.ellipseRect.Height > 0)) { // Draw twice to get a deeper color effect, once is to pale context.Graphics.FillRectangle(cache.ellipseBrush, cache.half2RectF); context.Graphics.FillRectangle(cache.ellipseBrush, cache.half2RectF); } // Draw the actual border using (AntiAlias aa = new AntiAlias(context.Graphics)) context.Graphics.DrawPath(cache.outsidePen, cache.outsidePath); switch (orientation) { case VisualOrientation.Top: DrawRibbonTabTrackingTopDraw2007(rect, cache, context.Graphics); break; case VisualOrientation.Left: DrawRibbonTabTrackingLeftDraw2007(rect, cache, context.Graphics); break; case VisualOrientation.Right: DrawRibbonTabTrackingRightDraw2007(rect, cache, context.Graphics); break; case VisualOrientation.Bottom: DrawRibbonTabTrackingBottomDraw2007(rect, cache, context.Graphics); break; } context.Graphics.DrawPath(cache.topPen, cache.topPath); } return memento; }
/// <summary> /// Reset the redirection states to null. /// </summary> public virtual void ResetRedirectStates() { _disabledBack = null; _normalBack = null; _pressedBack = null; _trackingBack = null; _selectedBack = null; _focusOverrideBack = null; _disabledText = null; _normalText = null; _pressedText = null; _trackingText = null; _selectedText = null; _focusOverrideText = null; }
/// <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> /// Draw the background of a ribbon element. /// </summary> /// <param name="shape">Ribbon shape.</param> /// <param name="context">Rendering context.</param> /// <param name="rect">Target rectangle.</param> /// <param name="state">State associated with rendering.</param> /// <param name="palette">Palette used for sourcing settings.</param> /// <param name="orientation">Orientation for drawing.</param> /// <param name="composition">Drawing onto a composition element.</param> /// <param name="memento">Cached values to use when drawing.</param> public abstract IDisposable DrawRibbonBack(PaletteRibbonShape shape, RenderContext context, Rectangle rect, PaletteState state, IPaletteRibbonBack palette, VisualOrientation orientation, bool composition, IDisposable memento);
/// <summary> /// Internal rendering method. /// </summary> protected virtual IDisposable DrawRibbonGroupNormalTitle(RenderContext context, Rectangle rect, PaletteState state, IPaletteRibbonBack palette, IDisposable memento) { if ((rect.Width > 0) && (rect.Height > 0)) { Color c1 = palette.GetRibbonBackColor1(state); Color c2 = palette.GetRibbonBackColor2(state); bool generate = true; MementoRibbonGroupNormalTitle cache; // Access a cache instance and decide if cache resources need generating if ((memento == null) || !(memento is MementoRibbonGroupNormalTitle)) { if (memento != null) memento.Dispose(); cache = new MementoRibbonGroupNormalTitle(rect, c1, c2); memento = cache; } else { cache = (MementoRibbonGroupNormalTitle)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(); GraphicsPath titlePath = new GraphicsPath(); // Create the rounded bottom edge to fit inside a group border titlePath.AddLine(rect.Left, rect.Top, rect.Right - 1, rect.Top); titlePath.AddLine(rect.Right - 1, rect.Top, rect.Right - 1, rect.Bottom - 3); titlePath.AddLine(rect.Right - 1, rect.Bottom - 3, rect.Right - 3, rect.Bottom - 1); titlePath.AddLine(rect.Right - 3, rect.Bottom - 1, rect.Left + 2, rect.Bottom - 1); titlePath.AddLine(rect.Left + 2, rect.Bottom - 1, rect.Left, rect.Bottom - 3); titlePath.AddLine(rect.Left, rect.Bottom - 3, rect.Left, rect.Top); RectangleF rectF = new RectangleF(rect.Left - 0.5f, rect.Top - 0.5f, rect.Width + 1, rect.Height + 1); cache.titleBrush = new LinearGradientBrush(rectF, c1, c2, 90f); cache.titlePath = titlePath; } // Fill path area with a gradient brush context.Graphics.FillPath(cache.titleBrush, cache.titlePath); } return memento; }
private void RenderCollapsedPressedBefore(RenderContext context) { switch (_lastRibbonShape) { default: case PaletteRibbonShape.Office2007: { IPaletteBack paletteBack = _ribbon.StateCommon.RibbonGroupCollapsedButton.PaletteBack; IPaletteBorder paletteBorder = _ribbon.StateCommon.RibbonGroupCollapsedButton.PaletteBorder; // Do we need to draw the background? if (paletteBack.GetBackDraw(PaletteState.Pressed) == InheritBool.True) { // Get the border path which the background is clipped to drawing within using (GraphicsPath borderPath = context.Renderer.RenderStandardBorder.GetBackPath(context, ClientRectangle, paletteBorder, VisualOrientation.Top, PaletteState.Pressed)) { Padding borderPadding = context.Renderer.RenderStandardBorder.GetBorderRawPadding(paletteBorder, PaletteState.Pressed, VisualOrientation.Top); // Apply the padding depending on the orientation Rectangle enclosingRect = CommonHelper.ApplyPadding(VisualOrientation.Top, ClientRectangle, borderPadding); // Render the background inside the border path _mementoStandardBack = context.Renderer.RenderStandardBack.DrawBack(context, enclosingRect, borderPath, paletteBack, VisualOrientation.Top, PaletteState.Pressed, _mementoStandardBack); } } // Do we need to draw the border? if (paletteBorder.GetBorderDraw(PaletteState.Pressed) == InheritBool.True) { context.Renderer.RenderStandardBorder.DrawBorder(context, ClientRectangle, paletteBorder, VisualOrientation.Top, PaletteState.Pressed); } } break; case PaletteRibbonShape.Office2010: { Rectangle drawRect = ClientRectangle; IPaletteRibbonBack paletteBack = _ribbon.StatePressed.RibbonGroupCollapsedBack; IPaletteRibbonBack paletteBorder = _ribbon.StatePressed.RibbonGroupCollapsedBorder; PaletteState state = PaletteState.Pressed; // Are we a group inside a context tab? if ((_ribbon.SelectedTab != null) && !string.IsNullOrEmpty(_ribbon.SelectedTab.ContextName)) { state = PaletteState.ContextPressed; } // Draw the group border _paletteContextBack.SetInherit(paletteBorder); _mementoRibbonBack1 = context.Renderer.RenderRibbon.DrawRibbonBack(_ribbon.RibbonShape, context, drawRect, state, _paletteContextBack, VisualOrientation.Top, false, _mementoRibbonBack1); Rectangle backRect = drawRect; backRect.Inflate(-2, -2); // Draw the inside background _mementoRibbonBack2 = context.Renderer.RenderRibbon.DrawRibbonBack(_ribbon.RibbonShape, context, backRect, state, paletteBack, VisualOrientation.Top, false, _mementoRibbonBack2); } break; } }
/// <summary> /// Set the redirection states. /// </summary> /// <param name="disabledBack">Redirection for back disabled state requests.</param> /// <param name="normalBack">Redirection for back normal state requests.</param> /// <param name="pressedBack">Redirection for back pressed state requests.</param> /// <param name="trackingBack">Redirection for back tracking state requests.</param> /// <param name="selectedBack">Redirection for selected states requests.</param> /// <param name="focusOverrideBack">Redirection for back focus override state requests.</param> /// <param name="disabledText">Redirection for text disabled state requests.</param> /// <param name="normalText">Redirection for text normal state requests.</param> /// <param name="pressedText">Redirection for text pressed state requests.</param> /// <param name="trackingText">Redirection for text tracking state requests.</param> /// <param name="selectedText">Redirection for text selected states requests.</param> /// <param name="focusOverrideText">Redirection for text focus override state requests.</param> public virtual void SetRedirectStates(IPaletteRibbonBack disabledBack, IPaletteRibbonBack normalBack, IPaletteRibbonBack pressedBack, IPaletteRibbonBack trackingBack, IPaletteRibbonBack selectedBack, IPaletteRibbonBack focusOverrideBack, IPaletteRibbonText disabledText, IPaletteRibbonText normalText, IPaletteRibbonText pressedText, IPaletteRibbonText trackingText, IPaletteRibbonText selectedText, IPaletteRibbonText focusOverrideText) { _disabledBack = disabledBack; _normalBack = normalBack; _pressedBack = pressedBack; _trackingBack = trackingBack; _selectedBack = selectedBack; _focusOverrideBack = focusOverrideBack; _disabledText = disabledText; _normalText = normalText; _pressedText = pressedText; _trackingText = trackingText; _selectedText = selectedText; _focusOverrideText = focusOverrideText; }
/// <summary> /// Internal rendering method. /// </summary> protected virtual IDisposable DrawRibbonLinear(RenderContext context, Rectangle rect, PaletteState state, IPaletteRibbonBack palette, IDisposable memento) { if ((rect.Width > 0) && (rect.Height > 0)) { Color c1 = palette.GetRibbonBackColor1(state); Color c2 = palette.GetRibbonBackColor2(state); bool generate = true; MementoRibbonLinear cache; // Access a cache instance and decide if cache resources need generating if ((memento == null) || !(memento is MementoRibbonLinear)) { if (memento != null) memento.Dispose(); cache = new MementoRibbonLinear(rect, c1, c2); memento = cache; } else { cache = (MementoRibbonLinear)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.linearBrush = new LinearGradientBrush(new RectangleF(rect.X - 1, rect.Y - 1, rect.Width + 2, rect.Height + 2), c1, c2, 90f); } context.Graphics.FillRectangle(cache.linearBrush, rect); } return memento; }
/// <summary> /// Draw the application button. /// </summary> /// <param name="shape">Ribbon shape.</param> /// <param name="context">Rendering context.</param> /// <param name="rect">Target rectangle.</param> /// <param name="state">State associated with rendering.</param> /// <param name="palette">Palette used for sourcing settings.</param> /// <param name="memento">Cached storage for drawing objects.</param> public abstract IDisposable DrawRibbonApplicationButton(PaletteRibbonShape shape, RenderContext context, Rectangle rect, PaletteState state, IPaletteRibbonBack palette, IDisposable memento);
/// <summary> /// Internal rendering method. /// </summary> protected virtual IDisposable DrawRibbonLinearBorder(RenderContext context, Rectangle rect, PaletteState state, IPaletteRibbonBack palette, IDisposable memento) { if ((rect.Width > 0) && (rect.Height > 0)) { Color c1 = palette.GetRibbonBackColor1(state); Color c2 = palette.GetRibbonBackColor2(state); bool generate = true; MementoRibbonLinearBorder cache; // Access a cache instance and decide if cache resources need generating if ((memento == null) || !(memento is MementoRibbonLinearBorder)) { if (memento != null) memento.Dispose(); cache = new MementoRibbonLinearBorder(rect, c1, c2); memento = cache; } else { cache = (MementoRibbonLinearBorder)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.linearBrush = new LinearGradientBrush(new RectangleF(rect.X - 1, rect.Y - 1, rect.Width + 2, rect.Height + 2), c1, c2, 90f); cache.linearPen = new Pen(cache.linearBrush); // Create the rounded complete border GraphicsPath borderPath = new GraphicsPath(); borderPath.AddLine(rect.Left + 2, rect.Top, rect.Right - 3, rect.Top); borderPath.AddLine(rect.Right - 3, rect.Top, rect.Right - 1, rect.Top + 2); borderPath.AddLine(rect.Right - 1, rect.Top + 2, rect.Right - 1, rect.Bottom - 3); borderPath.AddLine(rect.Right - 1, rect.Bottom - 3, rect.Right - 3, rect.Bottom - 1); borderPath.AddLine(rect.Right - 3, rect.Bottom - 1, rect.Left + 2, rect.Bottom - 1); borderPath.AddLine(rect.Left + 2, rect.Bottom - 1, rect.Left, rect.Bottom - 3); borderPath.AddLine(rect.Left, rect.Bottom - 3, rect.Left, rect.Top + 2); borderPath.AddLine(rect.Left, rect.Top + 2, rect.Left + 2, rect.Top); cache.borderPath = borderPath; } context.Graphics.DrawPath(cache.linearPen, cache.borderPath); } return memento; }
/// <summary> /// Draw a context ribbon tab title. /// </summary> /// <param name="shape">Ribbon shape.</param> /// <param name="context">Rendering context.</param> /// <param name="rect">Target rectangle.</param> /// <param name="paletteGeneral">Palette used for general ribbon settings.</param> /// <param name="paletteBack">Palette used for background ribbon settings.</param> /// <param name="memento">Cached values to use when drawing.</param> public abstract IDisposable DrawRibbonTabContextTitle(PaletteRibbonShape shape, RenderContext context, Rectangle rect, IPaletteRibbonGeneral paletteGeneral, IPaletteRibbonBack paletteBack, IDisposable memento);
/// <summary> /// Internal rendering method. /// </summary> protected virtual IDisposable DrawRibbonQATFullbarRound(RenderContext context, Rectangle rect, PaletteState state, IPaletteRibbonBack palette, IDisposable memento) { // We never draw the top line rect.Y++; rect.Height--; if ((rect.Width > 0) && (rect.Height > 0)) { Color c1 = palette.GetRibbonBackColor1(state); Color c2 = palette.GetRibbonBackColor2(state); Color c3 = palette.GetRibbonBackColor3(state); bool generate = true; MementoRibbonQATFullbarRound cache; // Access a cache instance and decide if cache resources need generating if ((memento == null) || !(memento is MementoRibbonQATFullbarRound)) { if (memento != null) memento.Dispose(); cache = new MementoRibbonQATFullbarRound(rect, c1, c2, c3); memento = cache; } else { cache = (MementoRibbonQATFullbarRound)memento; generate = !cache.UseCachedValues(rect, c1, c2, c3); } // Do we need to generate the contents of the cache? if (generate) { // Dispose of existing values cache.Dispose(); cache.innerRect = new Rectangle(rect.X + 1, rect.Y + 1, rect.Width - 2, rect.Height - 2); cache.innerBrush = new LinearGradientBrush(rect, c1, c2, 90f); cache.darkPen = new Pen(c3); GraphicsPath darkPath = new GraphicsPath(); GraphicsPath lightPath1 = new GraphicsPath(); GraphicsPath lightPath2 = new GraphicsPath(); // Create the dark border darkPath.AddLine(rect.Left, rect.Top + 0.75f, rect.Left + 1, rect.Top); darkPath.AddLine(rect.Left + 1, rect.Top, rect.Right - 3.5f, rect.Top); darkPath.AddLine(rect.Right - 3.5f, rect.Top, rect.Right - 2, rect.Top + 2); darkPath.AddLine(rect.Right - 2, rect.Top + 2, rect.Right - 2, rect.Bottom - 3.25f); darkPath.AddLine(rect.Right - 2, rect.Bottom - 3.25f, rect.Right - 3.25f, rect.Bottom - 2); darkPath.AddLine(rect.Right - 3.25f, rect.Bottom - 2, rect.Left, rect.Bottom - 2); // Create the first light border lightPath1.AddLine(rect.Left, rect.Bottom - 3, rect.Left, rect.Top + 2.5f); lightPath1.AddLine(rect.Left, rect.Top + 2.5f, rect.Left + 1, rect.Top + 1); lightPath1.AddLine(rect.Left + 1, rect.Top + 1, rect.Right - 4, rect.Top + 1); // Create the second light border lightPath2.AddLine(rect.Right - 1, rect.Top + 2, rect.Right - 1, rect.Bottom - 2); lightPath2.AddLine(rect.Right - 1, rect.Bottom - 2, rect.Right - 2, rect.Bottom - 1); lightPath2.AddLine(rect.Right - 2, rect.Bottom - 1, rect.Left + 1, rect.Bottom - 1); cache.darkPath = darkPath; cache.lightPath1 = lightPath1; cache.lightPath2 = lightPath2; } // Draw a gradient for the inside of the area context.Graphics.FillRectangle(cache.innerBrush, cache.innerRect); // Draw the dark/light lines using (AntiAlias aa = new AntiAlias(context.Graphics)) { context.Graphics.DrawPath(cache.darkPen, cache.darkPath); context.Graphics.DrawPath(_light1Pen, cache.lightPath1); context.Graphics.DrawPath(_light2Pen, cache.lightPath2); } } return memento; }