Exemplo n.º 1
0
        /// <summary>
        /// Initialize a new instance of the VisualPopupGroup class.
        /// </summary>
        /// <param name="ribbon">Reference to owning ribbon control.</param>
        /// <param name="ribbonGroup">Reference to ribbon group for display.</param>
        /// <param name="renderer">Drawing renderer.</param>
        public VisualPopupGroup(KryptonRibbon ribbon,
                                KryptonRibbonGroup ribbonGroup,
                                IRenderer renderer)
            : base(renderer, true)
        {
            Debug.Assert(ribbon != null);
            Debug.Assert(ribbonGroup != null);

            // Remember references needed later
            _ribbon      = ribbon;
            _ribbonGroup = ribbonGroup;

            // Create a view element for drawing the group
            ViewGroup = new ViewDrawRibbonGroup(ribbon, ribbonGroup, NeedPaintDelegate)
            {
                Collapsed = false
            };

            // Create the background that will contain the actual group instance
            _viewBackground = new ViewDrawRibbonGroupsBorder(ribbon, true, NeedPaintDelegate)
            {
                ViewGroup
            };

            // Attach the root to the view manager instance
            ViewManager = new ViewRibbonPopupGroupManager(this, ribbon, _viewBackground, ViewGroup, NeedPaintDelegate);

            // Create and add a hidden button to act as the focus target
            _hiddenFocusTarget = new Button
            {
                TabStop = false
            };
            _hiddenFocusTarget.Location = new Point(-_hiddenFocusTarget.Width, -_hiddenFocusTarget.Height);
            CommonHelper.AddControlToParent(this, _hiddenFocusTarget);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Paint the provided rectangle.
        /// </summary>
        /// <param name="g">Graphics to use for drawing.</param>
        /// <param name="rect">Rectangle to be drawn.</param>
        /// <param name="edges">True if the edges needs to be drawn.</param>
        /// <param name="sender">Sender of the message..</param>
        public void PaintRectangle(Graphics g, Rectangle rect, bool edges, Control sender)
        {
            // If we are rendering using desktop window composition and using the Office 2010 shape
            // of ribbon then we need to draw the tabs area as part of the window chrome
            // Not for 2013
            if (DrawOnComposition && (_ribbon.RibbonShape == PaletteRibbonShape.Office2010 || _ribbon.RibbonShape == PaletteRibbonShape.Office2013 || _ribbon.RibbonShape == PaletteRibbonShape.Office365))
            {
                if (edges)
                {
                    rect.X     += EDGE_GAP;
                    rect.Width -= EDGE_GAP * 2;
                }
                else if ((sender != null) && !_ribbon.MinimizedMode)
                {
                    using (ViewDrawRibbonGroupsBorder border = new ViewDrawRibbonGroupsBorder(_ribbon, false, _paintDelegate))
                    {
                        border.ClientRectangle = new Rectangle(-sender.Location.X, rect.Bottom - 1, _ribbon.Width, 10);
                        using (RenderContext context = new RenderContext(_ribbon, g, rect, _ribbon.Renderer))
                        {
                            border.Render(context);
                        }
                    }
                }

                if (_ribbon.RibbonShape == PaletteRibbonShape.Office2010)
                {
                    //Adjust Color of the gradient
                    Color gradientColor = KryptonManager.CurrentGlobalPalette == KryptonManager.PaletteOffice2010Black
                        ? Color.FromArgb(39, 39, 39)
                        : Color.White;

                    using (LinearGradientBrush backBrush = new LinearGradientBrush(new Rectangle(rect.X, rect.Y - 1, rect.Width, rect.Height + 1), Color.Transparent, gradientColor, 90f))
                    {
                        backBrush.Blend = _compBlend;
                        g.FillRectangle(backBrush, new Rectangle(rect.X, rect.Y, rect.Width, rect.Height - 1));
                    }
                }
                else if (_ribbon.RibbonShape == PaletteRibbonShape.Office2013)
                {
                    using (SolidBrush backBrush = new SolidBrush(Color.White))
                    {
                        g.FillRectangle(backBrush, new Rectangle(rect.X, rect.Y, rect.Width, rect.Height - 1));
                    }
                }
                else if (_ribbon.RibbonShape == PaletteRibbonShape.Office365)
                {
                    using (SolidBrush backBrush = new SolidBrush(Color.White))
                    {
                        g.FillRectangle(backBrush, new Rectangle(rect.X, rect.Y, rect.Width, rect.Height - 1));
                    }
                }
            }
        }