Beispiel #1
0
        private void RenderBefore2007ContextTab(RenderContext context, ContextTabSet cts)
        {
            // We only draw side separators on the first and last tab of the contexts
            if (cts.IsFirstOrLastTab(this))
            {
                // Grab the color we draw the context separator in
                Color sepColor = _paletteGeneral.GetRibbonTabSeparatorContextColor(PaletteState.Normal);

                Rectangle parentRect   = Parent.ClientRectangle;
                Rectangle contextRect  = new Rectangle(ClientRectangle.X - 1, parentRect.Y, ClientRectangle.Width + 2, parentRect.Height);
                Rectangle gradientRect = new Rectangle(ClientRectangle.X - 1, parentRect.Y - 1, ClientRectangle.Width + 2, parentRect.Height + 2);

                using (LinearGradientBrush sepBrush = new LinearGradientBrush(gradientRect, sepColor, Color.Transparent, 90f))
                {
                    // We need to customize the way the color blends over the background
                    sepBrush.Blend = _contextBlend2007;

                    using (Pen sepPen = new Pen(sepBrush))
                    {
                        if (cts.IsFirstTab(this))
                        {
                            context.Graphics.DrawLine(sepPen, contextRect.X, contextRect.Y, contextRect.X, contextRect.Bottom - 1);
                        }

                        if (cts.IsLastTab(this))
                        {
                            context.Graphics.DrawLine(sepPen, contextRect.Right - 1, contextRect.Y, contextRect.Right - 1, contextRect.Bottom - 1);
                        }
                    }
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Perform rendering before child elements are rendered.
        /// </summary>
        /// <param name="context">Rendering context.</param>
        public override void RenderBefore(RenderContext context)
        {
            // Ensure that child elements have correct palette state
            CheckPaletteState(context);

            // Grab the context tab set that relates to this tab
            ContextTabSet cts = ViewLayoutRibbonTabs.ContextTabSets[RibbonTab.ContextName];

            switch (_ribbon.RibbonShape)
            {
            default:
            case PaletteRibbonShape.NeoAxis:
            case PaletteRibbonShape.Office2007:
                if (cts != null)
                {
                    RenderBefore2007ContextTab(context, cts);
                }

                _paletteContextCurrent.LightBackground = false;
                break;
                //case PaletteRibbonShape.Office2010:
                //    if (cts != null)
                //        RenderBefore2010ContextTab(context, cts);

                //    //_paletteContextCurrent.LightBackground = _ribbon.CaptionArea.DrawCaptionOnComposition;
                //    _paletteContextCurrent.LightBackground = _ribbon.CaptionArea.DrawCaptionOnComposition && (KryptonManager.CurrentGlobalPalette != KryptonManager.PaletteOffice2010Black);
                //    break;
            }

            // Use renderer to draw the tab background
            int mementoIndex = StateIndex(State);

            _mementos[mementoIndex] = context.Renderer.RenderRibbon.DrawRibbonBack(_ribbon.RibbonShape, context, ClientRectangle, State, _paletteContextCurrent, VisualOrientation.Top, false, _mementos[mementoIndex]);
        }
Beispiel #3
0
 private void RenderAfter2010ContextTab(RenderContext context, ContextTabSet cts)
 {
     switch (State)
     {
     case PaletteState.ContextCheckedNormal:
     case PaletteState.ContextCheckedTracking:
         // Add ellipses highlight to the selected context tab
         break;
     }
 }
Beispiel #4
0
        private void AddTabsWithContextName(string contextName)
        {
            ContextTabSet cts = null;

            // Remove the ribbon tab reference from the draw tab
            // (Must do this for all tabs before setting them to the corret value)
            for (int i = 0; i < _ribbon.RibbonTabs.Count; i++)
            {
                KryptonRibbonTab ribbonTab = _ribbon.RibbonTabs[i];
                if (IsRibbonVisible(ribbonTab, contextName))
                {
                    _tabCache[i].RibbonTab = null;
                }
            }

            // Add child elements appropriate for each ribbon tab
            for (int i = 0; i < _ribbon.RibbonTabs.Count; i++)
            {
                KryptonRibbonTab ribbonTab = _ribbon.RibbonTabs[i];
                if (IsRibbonVisible(ribbonTab, contextName))
                {
                    // Get the matching indexed items
                    ViewDrawRibbonTab drawTab = _tabCache[i];

                    // Every tab needs a draw tab element followed by a separator
                    Add(drawTab);
                    Add(_tabSepCache[i]);

                    // Associate the draw element with matching ribbon tab
                    drawTab.RibbonTab = ribbonTab;

                    // If we are dealing with a real context and not the empty one
                    if (!string.IsNullOrEmpty(contextName))
                    {
                        // Create tab set when first needed, otherwise this tab must be the last one
                        if (cts == null)
                        {
                            cts = new ContextTabSet(drawTab, _ribbon.RibbonContexts[ribbonTab.ContextName]);
                        }
                        else
                        {
                            cts.UpdateLastTab(drawTab);
                        }
                    }
                }
            }

            // If we created a new tab set, then add to the collection
            if (cts != null)
            {
                ContextTabSets.Add(cts);
            }
        }
Beispiel #5
0
        private void RenderBefore2010ContextTab(RenderContext context, ContextTabSet cts)
        {
            // Grab the colors we draw the context separators and background in
            Color c1      = _paletteGeneral.GetRibbonTabSeparatorContextColor(PaletteState.Normal);
            Color c2      = cts.ContextColor;
            Color lightC2 = ControlPaint.Light(c2);
            Color c3      = CommonHelper.MergeColors(Color.Black, 0.1f, c2, 0.9f);

            Rectangle contextRect = new Rectangle(ClientRectangle.X - 1, ClientRectangle.Y - 1, ClientRectangle.Width + 2, ClientRectangle.Height + 1);
            Rectangle fillRect    = new Rectangle(ClientRectangle.X - 2, ClientRectangle.Y - 1, ClientRectangle.Width + 4, ClientRectangle.Height);

            using (LinearGradientBrush outerBrush = new LinearGradientBrush(contextRect, c1, Color.Transparent, 90f),
                   innerBrush = new LinearGradientBrush(contextRect, c3, Color.Transparent, 90f),
                   fillBrush = new LinearGradientBrush(contextRect, Color.FromArgb(64, lightC2), Color.Transparent, 90f))
            {
                fillBrush.Blend = _contextBlend2010;

                using (Pen outerPen = new Pen(outerBrush),
                       innerPen = new Pen(innerBrush))
                {
                    if (cts.IsFirstTab(this))
                    {
                        // Draw left separators
                        context.Graphics.DrawLine(outerPen, contextRect.X, contextRect.Y, contextRect.X, contextRect.Bottom - 2);
                        context.Graphics.DrawLine(innerPen, contextRect.X + 1, contextRect.Y, contextRect.X + 1, contextRect.Bottom - 2);
                        fillRect.X     += 2;
                        fillRect.Width -= 2;

                        if (cts.IsLastTab(this))
                        {
                            // Draw right separators
                            context.Graphics.DrawLine(outerPen, contextRect.Right - 1, contextRect.Y, contextRect.Right - 1, contextRect.Bottom - 2);
                            context.Graphics.DrawLine(innerPen, contextRect.Right - 2, contextRect.Y, contextRect.Right - 2, contextRect.Bottom - 2);
                            fillRect.Width -= 2;
                        }
                    }
                    else if (cts.IsLastTab(this))
                    {
                        // Draw right separators
                        context.Graphics.DrawLine(outerPen, contextRect.Right - 1, contextRect.Y, contextRect.Right - 1, contextRect.Bottom - 2);
                        context.Graphics.DrawLine(innerPen, contextRect.Right - 2, contextRect.Y, contextRect.Right - 2, contextRect.Bottom - 2);
                        fillRect.Width -= 2;
                    }

                    // Draw the background gradient
                    context.Graphics.FillRectangle(fillBrush, fillRect);
                }
            }
        }
Beispiel #6
0
        /// <summary>
        /// Perform rendering after child elements are rendered.
        /// </summary>
        /// <param name="context">Rendering context.</param>
        public override void RenderAfter(RenderContext context)
        {
            // Grab the context tab set that relates to this tab
            ContextTabSet cts = ViewLayoutRibbonTabs.ContextTabSets[RibbonTab.ContextName];

            // Is this tab part of a context?
            if (cts != null)
            {
                switch (_ribbon.RibbonShape)
                {
                case PaletteRibbonShape.Office2010:
                    RenderAfter2010ContextTab(context, cts);
                    break;
                }
            }
        }
        /// <summary>
        /// Perform a layout of the elements.
        /// </summary>
        /// <param name="context">Layout context.</param>
        public override void Layout(ViewLayoutContext context)
        {
            Debug.Assert(context != null);

            // Sync children to match the current context tabs
            SyncChildrenToContexts();

            // We take on all the available display area
            ClientRectangle = context.DisplayRectangle;

            // Find any filler child
            ViewBase filler = null;

            foreach (ViewBase child in this)
            {
                if (GetDock(child) == ViewDockStyle.Fill)
                {
                    filler = child;
                    break;
                }
            }

            int xLeftMost  = ClientRectangle.Right;
            int xRightMost = ClientRectangle.Left;

            // Find the correct position for each child context set
            foreach (ViewBase child in this)
            {
                // Only interested in visible children
                if (child.Visible)
                {
                    // We are only interested in laying out context titles
                    if (child is ViewDrawRibbonContextTitle)
                    {
                        ViewDrawRibbonContextTitle childContextTitle = child as ViewDrawRibbonContextTitle;

                        // Get the context set it is representing
                        ContextTabSet tabContext = childContextTitle.ContextTabSet;

                        // Get the screen position of the left and right hand positions
                        Point leftTab  = tabContext.GetLeftScreenPosition();
                        Point rightTab = tabContext.GetRightScreenPosition();

                        // If our position is above the ribbon control we must be in the chrome
                        if (_captionArea.UsingCustomChrome && !_captionArea.KryptonForm.ApplyComposition)
                        {
                            int leftPadding = _captionArea.RealWindowBorders.Left;
                            leftTab.X  += leftPadding;
                            rightTab.X += leftPadding;
                        }

                        // Convert the screen to our own coordinates
                        leftTab  = context.TopControl.PointToClient(leftTab);
                        rightTab = context.TopControl.PointToClient(rightTab);

                        // Calculate the position of the child and layout
                        context.DisplayRectangle = new Rectangle(leftTab.X, ClientLocation.Y, rightTab.X - leftTab.X, ClientHeight);
                        childContextTitle.Layout(context);

                        // Track the left and right most positions
                        xLeftMost  = Math.Min(xLeftMost, leftTab.X);
                        xRightMost = Math.Max(xRightMost, rightTab.X);
                    }
                }
            }

            // Do we need to position a filler element?
            if (filler != null)
            {
                // How much space available on the left side
                int leftSpace  = xLeftMost - ClientRectangle.Left;
                int rightSpace = ClientRectangle.Right - xRightMost;

                if (CenterLayout)
                {
                    //TODO: test with xLeftMost/xRightMost, with ViewDrawRibbonContextTitle type
                    leftSpace  = this.Parent.ClientSize.Width - ClientRectangle.Left * 2;
                    rightSpace = this.Parent.ClientSize.Width - xRightMost * 2;
                }

                // Use the side with the most space
                if (leftSpace >= rightSpace)
                {
                    context.DisplayRectangle = new Rectangle(ClientLocation.X, ClientLocation.Y, leftSpace, ClientHeight);
                }
                else
                {
                    context.DisplayRectangle = new Rectangle(xRightMost, ClientLocation.Y, rightSpace, ClientHeight);
                }

                filler.Layout(context);
            }

            // Put the original value back again
            context.DisplayRectangle = ClientRectangle;
        }