private void RenderBorder(RenderContext context, Rectangle rect)
        {
            Debug.Assert(context != null);

            // Do we need to draw the border?
            if (_paletteBorder.GetBorderDraw(State) == InheritBool.True)
            {
                if (Splitter)
                {
                    bool mouseInSplit = MouseInSplit;
                    switch (State)
                    {
                    case PaletteState.Tracking:
                        DrawBorder(context, rect, _paletteBorder, PaletteState.Tracking);
                        break;

                    case PaletteState.Pressed:
                        DrawBorder(context, rect, _paletteBorder, PaletteState.Tracking);

                        using (Clipping clipToSplitter = new Clipping(context.Graphics, (mouseInSplit ? _splitRectangle : _nonSplitRectangle)))
                            DrawBorder(context, rect, _paletteBorder, PaletteState.Pressed);
                        break;

                    default:
                        DrawBorder(context, rect, _paletteBorder, State);
                        break;
                    }
                }
                else
                {
                    DrawBorder(context, rect, _paletteBorder, State);
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Gets a value indicating if border should be drawn.
        /// </summary>
        /// <param name="state">Palette value should be applicable to this state.</param>
        /// <returns>InheritBool value.</returns>
        public override InheritBool GetBorderDraw(PaletteState state)
        {
            if (Apply)
            {
                InheritBool ret = _primary.GetBorderDraw(Override ? OverrideState : state);

                if (ret == InheritBool.Inherit)
                {
                    ret = _backup.GetBorderDraw(state);
                }

                return(ret);
            }
            else
            {
                return(_backup.GetBorderDraw(state));
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Gets the actual border draw value.
 /// </summary>
 /// <param name="state">Palette value should be applicable to this state.</param>
 /// <returns>InheritBool value.</returns>
 public InheritBool GetBorderDraw(PaletteState state)
 {
     if (Draw != InheritBool.Inherit)
     {
         return(Draw);
     }
     else
     {
         return(_inherit.GetBorderDraw(state));
     }
 }
 private void DrawBorder(IPaletteBorder paletteBorder,
                         RenderContext context,
                         Rectangle rect,
                         PaletteState state)
 {
     // Do we need to draw the border?
     if (paletteBorder.GetBorderDraw(state) == InheritBool.True)
     {
         context.Renderer.RenderStandardBorder.DrawBorder(context, rect, paletteBorder,
                                                          VisualOrientation.Top, state);
     }
 }
        /// <summary>
        /// Gets a value indicating if border should be drawn.
        /// </summary>
        /// <param name="style">Border style.</param>
        /// <param name="state">Palette value should be applicable to this state.</param>
        /// <returns>InheritBool value.</returns>
        public override InheritBool GetBorderDraw(PaletteBorderStyle style, PaletteState state)
        {
            IPaletteBorder inherit = GetInherit(state);

            if (inherit != null)
            {
                return(inherit.GetBorderDraw(state));
            }
            else
            {
                return(Target.GetBorderDraw(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);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Draw the canvas border.
        /// </summary>
        /// <param name="context"></param>
        public virtual void RenderBorder(RenderContext context)
        {
            Debug.Assert(context != null);

            // Do we need to draw the border?
            if (_paletteBorder.GetBorderDraw(State) == InheritBool.True)
            {
                // Render the border over the background and children
                if (DrawTabBorder)
                {
                    context.Renderer.RenderTabBorder.DrawTabBorder(context, ClientRectangle, _paletteBorder, Orientation, State, TabBorderStyle);
                }
                else
                {
                    context.Renderer.RenderStandardBorder.DrawBorder(context, ClientRectangle, _paletteBorder, Orientation, State);
                }
            }
        }
Esempio n. 8
0
        /// <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);
        }
Esempio n. 9
0
        /// <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);
        }
        /// <summary>
        /// Gets a value indicating if border should be drawn.
        /// </summary>
        /// <param name="style">Border style.</param>
        /// <param name="state">Palette value should be applicable to this state.</param>
        /// <returns>InheritBool value.</returns>
        public override InheritBool GetBorderDraw(PaletteBorderStyle style, PaletteState state)
        {
            IPaletteBorder inherit = GetInherit(state);

            return(inherit?.GetBorderDraw(state) ?? Target.GetBorderDraw(style, state));
        }
 private void DrawBorder(IPaletteBorder paletteBorder,
                         RenderContext context,
                         Rectangle rect,
                         PaletteState state)
 {
     // Do we need to draw the border?
     if (paletteBorder.GetBorderDraw(state) == InheritBool.True)
         context.Renderer.RenderStandardBorder.DrawBorder(context, rect, paletteBorder,
                                                          VisualOrientation.Top, state);
 }
 /// <summary>
 /// Gets a value indicating if border should be drawn.
 /// </summary>
 /// <param name="state">Palette value should be applicable to this state.</param>
 /// <returns>InheritBool value.</returns>
 public override InheritBool GetBorderDraw(PaletteState state) => _inherit.GetBorderDraw(state);
Esempio n. 13
0
        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;
            }
        }
Esempio n. 14
0
        /// <summary>
        /// Evaluate if transparent painting is needed for background or border palettes.
        /// </summary>
        /// <param name="paletteBack">Background palette to test.</param>
        /// <param name="paletteBorder">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,
                                                  IPaletteBorder paletteBorder,
                                                  PaletteState state)
        {
            int rounding = paletteBorder.GetBorderRounding(state);

            // If the border takes up some visual space
            if (paletteBorder.GetBorderWidth(state) > 0)
            {
                // If the border is not being painted then it must be transparent
                if (paletteBorder.GetBorderDraw(state) == InheritBool.False)
                    return true;
                else
                {
                    // If there is rounding causing transparent corners
                    if (paletteBorder.GetBorderRounding(state) > 0)
                        return true;
                    else
                    {
                        // If the first color has alpha channel then has transparency
                        if (paletteBorder.GetBorderColor1(state).A < 255)
                            return true;
                        else
                        {
                            // Does the draw style require use of the second color?
                            if (paletteBorder.GetBorderColorStyle(state) != PaletteColorStyle.Solid)
                            {
                                // If the second color has alpha channel then has transparency
                                if (paletteBorder.GetBorderColor2(state).A < 255)
                                    return true;
                            }
                        }
                    }
                }
            }

            // The border does not cause transparency, check the background
            return EvalTransparentPaint(paletteBack, state);
        }
Esempio n. 15
0
        /// <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 the actual border draw value.
 /// </summary>
 /// <param name="state">Palette value should be applicable to this state.</param>
 /// <returns>InheritBool value.</returns>
 public InheritBool GetBorderDraw(PaletteState state)
 {
     return(_inherit.GetBorderDraw(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)
 {
     return(_parent.GetBorderDraw(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) => _parent.GetBorderDraw(state);