/// <summary> /// Perform a layout of the elements. /// </summary> /// <param name="context">Layout context.</param> public override void Layout(ViewLayoutContext context) { Debug.Assert(context != null); // Validate incoming reference if (context == null) { throw new ArgumentNullException("context"); } // We take on all the available display area ClientRectangle = context.DisplayRectangle; // Do we have a metric source for additional padding? if ((_paletteMetric != null) && (_metricPadding != PaletteMetricPadding.None)) { // Get the padding to be applied before the canvas drawing Padding outerPadding = _paletteMetric.GetMetricPadding(State, _metricPadding); // Apply the padding to the client rectangle ClientRectangle = CommonHelper.ApplyPadding(Orientation, ClientRectangle, outerPadding); } Padding padding; // Calculate how much space the border takes up if (DrawTabBorder) { padding = context.Renderer.RenderTabBorder.GetTabBorderDisplayPadding(context, _paletteBorder, State, Orientation, TabBorderStyle); } else { padding = context.Renderer.RenderStandardBorder.GetBorderDisplayPadding(_paletteBorder, State, Orientation); } // Apply the padding to the client rectangle context.DisplayRectangle = CommonHelper.ApplyPadding(Orientation, ClientRectangle, padding); // Ensure any content children have correct composition setting foreach (ViewBase child in this) { if (child is ViewDrawContent) { // Do we need to draw the background? bool drawBackground = _drawCanvas && (_paletteBack.GetBackDraw(State) == InheritBool.True); // Update the content accordingly ViewDrawContent viewContent = (ViewDrawContent)child; viewContent.DrawContentOnComposition = DrawCanvasOnComposition && !drawBackground; viewContent.Glowing = viewContent.DrawContentOnComposition; } } // Let child elements layout base.Layout(context); // Put back the original display value now we have finished context.DisplayRectangle = ClientRectangle; }
/// <summary> /// Perform drawing of a separator glyph. /// </summary> /// <param name="context">Render context.</param> /// <param name="displayRect">Display area available for drawing.</param> /// <param name="paletteBack">Background palette details.</param> /// <param name="paletteBorder">Border palette details.</param> /// <param name="orientation">Visual orientation of the content.</param> /// <param name="state">State associated with rendering.</param> /// <param name="canMove">Can the separator be moved.</param> public override void DrawSeparator(RenderContext context, Rectangle displayRect, IPaletteBack paletteBack, IPaletteBorder paletteBorder, Orientation orientation, PaletteState state, bool canMove) { // Let base class perform standard processing base.DrawSeparator(context, displayRect, paletteBack, paletteBorder, orientation, state, canMove); // If we are drawing the background then draw grab handles on top if (paletteBack.GetBackDraw(state) == InheritBool.True) { // Only draw grab handle if the user can move the separator if (canMove) DrawGrabHandleGlyph(context, displayRect, orientation, state); } }
/// <summary> /// Perform rendering before child elements are rendered. /// </summary> /// <param name="context">Rendering context.</param> public override void RenderBefore(RenderContext context) { Debug.Assert(context != null); // Validate incoming reference if (context == null) { throw new ArgumentNullException("context"); } if (!IgnoreRender) { // Do we need to draw the background? if (_paletteBack.GetBackDraw(State) == InheritBool.True) { // Render the background using (GraphicsPath panelPath = new GraphicsPath()) { // The path encloses the entire panel area panelPath.AddRectangle(ClientRectangle); // Perform actual panel drawing _memento = context.Renderer.RenderStandardBack.DrawBack(context, ClientRectangle, panelPath, _paletteBack, VisualOrientation, State, _memento); } } } }
/// <summary> /// Perform drawing of a separator glyph. /// </summary> /// <param name="context">Render context.</param> /// <param name="displayRect">Display area available for drawing.</param> /// <param name="paletteBack">Background palette details.</param> /// <param name="paletteBorder">Border palette details.</param> /// <param name="orientation">Visual orientation of the content.</param> /// <param name="state">State associated with rendering.</param> /// <param name="canMove">Can the separator be moved.</param> public override void DrawSeparator(RenderContext context, Rectangle displayRect, IPaletteBack paletteBack, IPaletteBorder paletteBorder, Orientation orientation, PaletteState state, bool canMove) { // Let base class perform standard processing base.DrawSeparator(context, displayRect, paletteBack, paletteBorder, orientation, state, canMove); // If we are drawing the background then draw grab handles on top if (paletteBack.GetBackDraw(state) == InheritBool.True) { // Only draw grab handle if the user can move the separator if (canMove) { DrawGrabHandleGlyph(context, displayRect, orientation, state); } } }
/// <summary> /// Gets a value indicating if background should be drawn. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>InheritBool value.</returns> public override InheritBool GetBackDraw(PaletteState state) { if (Apply) { InheritBool ret = _primary.GetBackDraw(Override ? OverrideState : state); if (ret == InheritBool.Inherit) { ret = _backup.GetBackDraw(state); } return(ret); } else { return(_backup.GetBackDraw(state)); } }
/// <summary> /// Gets the actual background draw value. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>InheritBool value.</returns> public InheritBool GetBackDraw(PaletteState state) { if (Draw != InheritBool.Inherit) { return(Draw); } else { return(_inherit.GetBackDraw(state)); } }
/// <summary> /// Gets a value indicating if background should be drawn. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>InheritBool value.</returns> public override InheritBool GetBackDraw(PaletteState state) { if ((TreeNode != null) && (TreeNode.BackColor != Color.Empty)) { return(InheritBool.True); } else { return(_inherit.GetBackDraw(state)); } }
/// <summary> /// Gets a value indicating if background should be drawn. /// </summary> /// <param name="style">Background style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>InheritBool value.</returns> public override InheritBool GetBackDraw(PaletteBackStyle style, PaletteState state) { IPaletteBack inherit = GetInherit(state); if (inherit != null) { return(inherit.GetBackDraw(state)); } else { return(Target.GetBackDraw(style, state)); } }
/// <summary> /// Perform rendering before child elements are rendered. /// </summary> /// <param name="context">Rendering context.</param> public override void RenderBefore(RenderContext context) { // Update the enabled state of the button Enabled = _ribbon.Enabled; IPaletteBack paletteBack = _ribbon.StateCommon.RibbonGroupDialogButton.PaletteBack; IPaletteBorder paletteBorder = _ribbon.StateCommon.RibbonGroupDialogButton.PaletteBorder; IPaletteRibbonGeneral paletteGeneral = _ribbon.StateCommon.RibbonGeneral; // Do we need to draw the background? if (paletteBack.GetBackDraw(State) == 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, State)) { Padding borderPadding = context.Renderer.RenderStandardBorder.GetBorderRawPadding(paletteBorder, State, VisualOrientation.Top); // Apply the padding depending on the orientation Rectangle enclosingRect = CommonHelper.ApplyPadding(VisualOrientation.Top, ClientRectangle, borderPadding); // Render the background inside the border path _mementoBack = context.Renderer.RenderStandardBack.DrawBack(context, enclosingRect, borderPath, paletteBack, VisualOrientation.Top, State, _mementoBack); } } // Do we need to draw the border? if (paletteBorder.GetBorderDraw(State) == InheritBool.True) { context.Renderer.RenderStandardBorder.DrawBorder(context, ClientRectangle, paletteBorder, VisualOrientation.Top, State); } // Find the content area inside the button rectangle Rectangle contentRect = ClientRectangle; contentRect.Inflate(_contentSize); // Decide if we are drawing an overflow or context arrow image if (Overflow) { context.Renderer.RenderGlyph.DrawRibbonOverflow(_ribbon.RibbonShape, context, contentRect, paletteGeneral, State); } else { context.Renderer.RenderGlyph.DrawRibbonContextArrow(_ribbon.RibbonShape, context, contentRect, paletteGeneral, State); } }
/// <summary> /// Gets a value indicating if background should be drawn. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>InheritBool value.</returns> public override InheritBool GetBackDraw(PaletteState state) { if (_forceDraw != InheritBool.Inherit) { return(_forceDraw); } else { if (_borderIgnoreNormal && (state == PaletteState.Normal)) { return(InheritBool.False); } else { return(_inherit.GetBackDraw(state)); } } }
/// <summary> /// Gets a value indicating if background should be drawn. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>InheritBool value.</returns> public override InheritBool GetBackDraw(PaletteState state) { if (ForceDraw != InheritBool.Inherit) { return ForceDraw; } else { if (BorderIgnoreNormal && (state == PaletteState.Normal)) { return InheritBool.False; } else { return _inherit.GetBackDraw(state); } } }
/// <summary> /// Perform rendering before child elements are rendered. /// </summary> /// <param name="context">Rendering context.</param> public override void RenderBefore(RenderContext context) { // Make sure we reflect the current enabled state if (!Enabled && _ribbon.InDesignHelperMode) { ElementState = PaletteState.Disabled; } IPaletteBack paletteBack = _ribbon.StateCommon.RibbonQATButton.PaletteBack; IPaletteBorder paletteBorder = _ribbon.StateCommon.RibbonQATButton.PaletteBorder; IPaletteRibbonGeneral paletteGeneral = _ribbon.StateCommon.RibbonGeneral; // Do we need to draw the background? if (paletteBack.GetBackDraw(State) == 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, State)) { Padding borderPadding = context.Renderer.RenderStandardBorder.GetBorderRawPadding(paletteBorder, State, VisualOrientation.Top); // Apply the padding depending on the orientation Rectangle enclosingRect = CommonHelper.ApplyPadding(VisualOrientation.Top, ClientRectangle, borderPadding); // Render the background inside the border path _mementoBack = context.Renderer.RenderStandardBack.DrawBack(context, enclosingRect, borderPath, paletteBack, VisualOrientation.Top, State, _mementoBack); } } // Do we need to draw the border? if (paletteBorder.GetBorderDraw(State) == InheritBool.True) { context.Renderer.RenderStandardBorder.DrawBorder(context, ClientRectangle, paletteBorder, VisualOrientation.Top, State); } base.RenderBefore(context); }
private void DrawBackground(IPaletteBack paletteBack, RenderContext context, Rectangle rect, PaletteState state) { // Do we need to draw the background? if (paletteBack.GetBackDraw(state) == InheritBool.True) { // Get the border path which the background is clipped to drawing within using (GraphicsPath borderPath = context.Renderer.RenderStandardBorder.GetBackPath(context, rect, _paletteBorder, VisualOrientation.Top, state)) { Padding borderPadding = context.Renderer.RenderStandardBorder.GetBorderRawPadding(_paletteBorder, state, VisualOrientation.Top); // Apply the padding depending on the orientation Rectangle enclosingRect = CommonHelper.ApplyPadding(VisualOrientation.Top, rect, borderPadding); // Render the background inside the border path _mementoBack = context.Renderer.RenderStandardBack.DrawBack(context, enclosingRect, borderPath, paletteBack, VisualOrientation.Top, state, _mementoBack); } } }
/// <summary> /// Perform rendering before child elements are rendered. /// </summary> /// <param name="context">Rendering context.</param> public override void RenderBefore(RenderContext context) { IPaletteBack paletteBack = _ribbon.StateCommon.RibbonGroupDialogButton.PaletteBack; IPaletteBorder paletteBorder = _ribbon.StateCommon.RibbonGroupDialogButton.PaletteBorder; IPaletteRibbonGeneral paletteGeneral = _ribbon.StateCommon.RibbonGeneral; // Do we need to draw the background? if (paletteBack.GetBackDraw(State) == 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, State); Padding borderPadding = context.Renderer.RenderStandardBorder.GetBorderRawPadding(paletteBorder, State, VisualOrientation.Top); // Apply the padding depending on the orientation Rectangle enclosingRect = CommonHelper.ApplyPadding(VisualOrientation.Top, ClientRectangle, borderPadding); // Render the background inside the border path _mementoBack = context.Renderer.RenderStandardBack.DrawBack(context, enclosingRect, borderPath, paletteBack, VisualOrientation.Top, State, _mementoBack); } // Do we need to draw the border? if (paletteBorder.GetBorderDraw(State) == InheritBool.True) { context.Renderer.RenderStandardBorder.DrawBorder(context, ClientRectangle, paletteBorder, VisualOrientation.Top, State); } // Find the content area inside the button rectangle Rectangle contentRect = ClientRectangle; contentRect.Inflate(_contentSize); // Draw the dialog box launcher glyph in the center context.Renderer.RenderGlyph.DrawRibbonDialogBoxLauncher(_ribbon.RibbonShape, context, contentRect, paletteGeneral, State); }
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> /// Gets a value indicating if background should be drawn. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>InheritBool value.</returns> public override InheritBool GetBackDraw(PaletteState state) { return(_inherit.GetBackDraw(state)); }
/// <summary> /// Evaluate if transparent painting is needed for background palette. /// </summary> /// <param name="paletteBack">Background palette to test.</param> /// <param name="state">Element state associated with palette.</param> /// <returns>True if transparent painting required.</returns> public override bool EvalTransparentPaint(IPaletteBack paletteBack, PaletteState state) { // If the background is not being painted, then has transparency if (paletteBack.GetBackDraw(state) == InheritBool.False) return true; else { // If the first color has alpha channel then has transparency if (paletteBack.GetBackColor1(state).A < 255) return true; else { // Does the draw style require use of the second color? if (paletteBack.GetBackColorStyle(state) != PaletteColorStyle.Solid) { // If the second color has alpha channel then has transparency if (paletteBack.GetBackColor2(state).A < 255) return true; } } } // Cannot find any transparent areas return false; }
/// <summary> /// Perform drawing of a separator glyph. /// </summary> /// <param name="context">Render context.</param> /// <param name="displayRect">Display area available for drawing.</param> /// <param name="paletteBack">Background palette details.</param> /// <param name="paletteBorder">Border palette details.</param> /// <param name="orientation">Visual orientation of the content.</param> /// <param name="state">State associated with rendering.</param> /// <param name="canMove">Can the separator be moved.</param> public override void DrawSeparator(RenderContext context, Rectangle displayRect, IPaletteBack paletteBack, IPaletteBorder paletteBorder, Orientation orientation, PaletteState state, bool canMove) { Debug.Assert(context != null); Debug.Assert(paletteBack != null); Debug.Assert(paletteBorder != null); // Validate parameter references if (context == null) throw new ArgumentNullException("context"); if (paletteBack == null) throw new ArgumentNullException("paletteBack"); if (paletteBorder == null) throw new ArgumentNullException("paletteBorder"); Debug.Assert(context.Control != null); Debug.Assert(!context.Control.IsDisposed); // Do we need to draw the background? if (paletteBack.GetBackDraw(state) == InheritBool.True) { // Convert from separator orientation to border orientation value VisualOrientation borderOrientation = (orientation == Orientation.Horizontal ? VisualOrientation.Top : VisualOrientation.Left); // Ask the border renderer for a path that encloses the border using (GraphicsPath borderPath = context.Renderer.RenderStandardBorder.GetBackPath(context, displayRect, paletteBorder, borderOrientation, state)) { // Get the padding needed for the drawing area inside the border Padding borderPadding = context.Renderer.RenderStandardBorder.GetBorderRawPadding(paletteBorder, state, borderOrientation); // The area available for border drawing if the client rectangle with padding applied Rectangle enclosingRect = CommonHelper.ApplyPadding(borderOrientation, displayRect, borderPadding); // Convert from the two state orientation to our four state orientation VisualOrientation vo = (orientation == Orientation.Horizontal) ? VisualOrientation.Top : VisualOrientation.Left; // Render the background inside the border path context.Renderer.RenderStandardBack.DrawBack(context, enclosingRect, borderPath, paletteBack, vo, state, null); } } // Do we need to draw the border? if (paletteBorder.GetBorderDraw(state) == InheritBool.True) { // Convert from the two state orientation to our four state orientation VisualOrientation vo = (orientation == Orientation.Horizontal) ? VisualOrientation.Top : VisualOrientation.Left; // Render the border over the background and children context.Renderer.RenderStandardBorder.DrawBorder(context, displayRect, paletteBorder, vo, state); } }
/// <summary> /// Gets a value indicating if background should be drawn. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>InheritBool value.</returns> public override InheritBool GetBackDraw(PaletteState state) => _inherit.GetBackDraw(state);
/// <summary> /// Gets a value indicating if background should be drawn. /// </summary> /// <param name="style">Background style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>InheritBool value.</returns> public override InheritBool GetBackDraw(PaletteBackStyle style, PaletteState state) { IPaletteBack inherit = GetInherit(state); return(inherit?.GetBackDraw(state) ?? Target.GetBackDraw(style, state)); }
/// <summary> /// Gets a value indicating if background should be drawn. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>InheritBool value.</returns> public override InheritBool GetBackDraw(PaletteState state) => (TreeNode != null) && (TreeNode.BackColor != Color.Empty) ? InheritBool.True : _inherit.GetBackDraw(state);