Ejemplo n.º 1
0
        private void UpdateShapeValues()
        {
            if (_ribbon != null)
            {
                if (_lastRibbonShape != _ribbon.RibbonShape)
                {
                    switch (_ribbon.RibbonShape)
                    {
                    default:
                    case PaletteRibbonShape.Office2007:
                        _totalBorders = TOTAL_LEFT_RIGHT_BORDERS_2007;
                        _layoutNormalMain.VertOffset                  = VERT_OFFSET_2007;
                        _layoutNormalSepTop.SeparatorSize             = new Size(NORMAL_BORDER_TOPLEFT2007, NORMAL_BORDER_TOPLEFT2007);
                        _layoutNormalSepLeft.SeparatorSize            = new Size(NORMAL_BORDER_TOPLEFT2007, NORMAL_BORDER_TOPLEFT2007);
                        _layoutNormalSepRight.SeparatorSize           = new Size(NORMAL_BORDER_RIGHT2007, NORMAL_BORDER_RIGHT2007);
                        _layoutCollapsedImagePadding.PreferredPadding = COLLAPSED_IMAGE_PADDING_2007;
                        _lastRibbonShape = PaletteRibbonShape.Office2007;
                        break;

                    case PaletteRibbonShape.Office2010:
                        _totalBorders = TOTAL_LEFT_RIGHT_BORDERS_2010;
                        _layoutNormalMain.VertOffset                  = VERT_OFFSET_2010;
                        _layoutNormalSepTop.SeparatorSize             = new Size(NORMAL_BORDER_TOP2010, NORMAL_BORDER_TOP2010);
                        _layoutNormalSepLeft.SeparatorSize            = new Size(NORMAL_BORDER_LEFT2010, NORMAL_BORDER_LEFT2010);
                        _layoutNormalSepRight.SeparatorSize           = new Size(NORMAL_BORDER_RIGHT2010, NORMAL_BORDER_RIGHT2010);
                        _layoutCollapsedImagePadding.PreferredPadding = COLLAPSED_IMAGE_PADDING_2010;
                        _lastRibbonShape = PaletteRibbonShape.Office2010;
                        break;
                    }
                }
            }
        }
        /// <summary>
        /// Initialize a new instance of the ViewDrawRibbonGroupSeparator class.
        /// </summary>
        /// <param name="ribbon">Reference to owning ribbon control.</param>
        /// <param name="ribbonSeparator">Reference to group separator definition.</param>
        /// <param name="needPaint">Delegate for notifying paint requests.</param>
        public ViewDrawRibbonGroupSeparator(KryptonRibbon ribbon,
                                            KryptonRibbonGroupSeparator ribbonSeparator,
                                            NeedPaintHandler needPaint)
        {
            Debug.Assert(ribbon != null);
            Debug.Assert(ribbonSeparator != null);
            Debug.Assert(needPaint != null);

            _ribbon = ribbon;
            _ribbonSeparator = ribbonSeparator;
            _needPaint = needPaint;

            // Associate this view with the source component (required for design time selection)
            Component = _ribbonSeparator;

            if (_ribbon.InDesignMode)
            {
                // At design time we need to know when the user right clicks the label
                ContextClickController controller = new ContextClickController();
                controller.ContextClick += new MouseEventHandler(OnContextClick);
                MouseController = controller;
            }

            // Define back reference to view for the separator definition
            _ribbonSeparator.SeparatorView = this;

            // Hook into changes in the ribbon separator definition
            _ribbonSeparator.PropertyChanged += new PropertyChangedEventHandler(OnSeparatorPropertyChanged);

            // Default the preferred size
            _lastShape = PaletteRibbonShape.Office2007;
            _preferredSize = _preferredSize2007;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initialize a new instance of the PaletteRibbonGeneral class.
        /// </summary>
        /// <param name="inherit">Source for inheriting general values.</param>
        /// <param name="needPaint">Delegate for notifying paint requests.</param>
        public PaletteRibbonGeneral(IPaletteRibbonGeneral inherit,
                                    NeedPaintHandler needPaint)
        {
            Debug.Assert(inherit != null);

            // Remember inheritance
            _inherit = inherit;

            // Store the provided paint notification delegate
            NeedPaint = needPaint;

            // Set default values
            _contextTextAlign         = PaletteRelativeAlign.Inherit;
            _contextTextColor         = Color.Empty;
            _contextTextFont          = null;
            _disabledDarkColor        = Color.Empty;
            _disabledLightColor       = Color.Empty;
            _dialogDarkColor          = Color.Empty;
            _dialogLightColor         = Color.Empty;
            _dropArrowLightColor      = Color.Empty;
            _dropArrowDarkColor       = Color.Empty;
            _groupSeparatorDark       = Color.Empty;
            _groupSeparatorLight      = Color.Empty;
            _minimizeBarDarkColor     = Color.Empty;
            _minimizeBarLightColor    = Color.Empty;
            _ribbonShape              = PaletteRibbonShape.Inherit;
            _tabSeparatorColor        = Color.Empty;
            _tabSeparatorContextColor = Color.Empty;
            _textFont            = null;
            _textHint            = PaletteTextHint.Inherit;
            _qatButtonDarkColor  = Color.Empty;
            _qatButtonLightColor = Color.Empty;
        }
        /// <summary>
        /// Initialize a new instance of the ViewDrawRibbonGroupSeparator class.
        /// </summary>
        /// <param name="ribbon">Reference to owning ribbon control.</param>
        /// <param name="ribbonSeparator">Reference to group separator definition.</param>
        /// <param name="needPaint">Delegate for notifying paint requests.</param>
        public ViewDrawRibbonGroupSeparator(KryptonRibbon ribbon,
                                            KryptonRibbonGroupSeparator ribbonSeparator,
                                            NeedPaintHandler needPaint)
        {
            Debug.Assert(ribbon != null);
            Debug.Assert(ribbonSeparator != null);
            Debug.Assert(needPaint != null);

            _ribbon          = ribbon;
            _ribbonSeparator = ribbonSeparator;
            _needPaint       = needPaint;

            // Associate this view with the source component (required for design time selection)
            Component = _ribbonSeparator;

            if (_ribbon.InDesignMode)
            {
                // At design time we need to know when the user right clicks the label
                ContextClickController controller = new ContextClickController();
                controller.ContextClick += OnContextClick;
                MouseController          = controller;
            }

            // Define back reference to view for the separator definition
            _ribbonSeparator.SeparatorView = this;

            // Hook into changes in the ribbon separator definition
            _ribbonSeparator.PropertyChanged += OnSeparatorPropertyChanged;

            // Default the preferred size
            _lastShape     = PaletteRibbonShape.Office2007;
            _preferredSize = _preferredSize2007;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Initialize a new instance of the CalculatedValues class.
        /// </summary>
        /// <param name="ribbon">Source control instance.</param>
        public CalculatedValues(KryptonRibbon ribbon)
        {
            Debug.Assert(ribbon != null);
            _ribbon = ribbon;

            _lastShape = PaletteRibbonShape.Inherit;
        }
        /// <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 override IDisposable DrawRibbonBack(PaletteRibbonShape shape,
                                                   RenderContext context,
                                                   Rectangle rect,
                                                   PaletteState state,
                                                   IPaletteRibbonBack palette,
                                                   VisualOrientation orientation,
                                                   bool composition,
                                                   IDisposable memento)
        {
            // Note is the incoming state is detailed we are drawing inside a popip
            bool showingInPopup = ((state & PaletteState.FocusOverride) == PaletteState.FocusOverride);

            if (showingInPopup)
            {
                state = state & ~PaletteState.FocusOverride;
            }

            switch (palette.GetRibbonBackColorStyle(state))
            {
            case PaletteRibbonColorStyle.RibbonGroupNormalBorderTracking:
                return(DrawRibbonGroupNormalBorder(context, rect, state, palette, true, false, memento));

            case PaletteRibbonColorStyle.RibbonGroupAreaBorder:
                return(DrawRibbonGroupAreaBorder1And2(context, rect, state, palette, false, true, memento));

            case PaletteRibbonColorStyle.RibbonGroupAreaBorder2:
                return(DrawRibbonGroupAreaBorder1And2(context, rect, state, palette, true, true, memento));

            default:
                return(base.DrawRibbonBack(shape, context, rect, state, palette, orientation, composition, memento));
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Recalculate all the values.
        /// </summary>
        public void Recalculate()
        {
            // Do we need to update the shape dependant values?
            if (_lastShape != _ribbon.RibbonShape)
            {
                _lastShape = _ribbon.RibbonShape;
                switch (_lastShape)
                {
                default:
                case PaletteRibbonShape.Office2007:
                    _groupHeightModifier  = 0;
                    _groupsHeightModifier = 0;
                    break;

                case PaletteRibbonShape.Office2013:
                case PaletteRibbonShape.Office365:
                case PaletteRibbonShape.Office2010:
                    _groupHeightModifier  = -3;
                    _groupsHeightModifier = -3;
                    break;
                }
            }

            // Get the font used by the ribbon
            Font font = _ribbon.StateCommon.RibbonGeneral.GetRibbonTextFont(PaletteState.Normal);

            // Cache common font height related values
            RawFontHeight = font.Height;

            DrawFontHeight = RawFontHeight + FONT_HEIGHT_EXTRA;

            // Height of all tabs in the tabs area
            TabHeight = DrawFontHeight + TABS_TOP_GAP;

            // Find the height of the group title area (must be minimum size to show the dialog launcher button)
            GroupTitleHeight = Math.Max(DrawFontHeight, DIALOG_MIN_HEIGHT);

            // Get the height needed for showing the content of a group line
            GroupLineContentHeight = Math.Max(DrawFontHeight, GROUP_LINE_CONTENT_MIN);

            // Group line height must be the content plus spacing gap and then border
            GroupLineHeight = GroupLineContentHeight + GROUP_LINE_CONTENT_EXTRA;

            // Group inside height is 3 group lines plus space at bottom of the lines
            GroupTripleHeight = (GroupLineHeight * 3);

            // The gap between lines is one of the lines divide by a gap above, between and below lines
            GroupLineGapHeight = (GroupLineHeight / 3);

            // Group height is the inside plus title area at bottom and the top border
            GroupHeight = GroupTripleHeight + GROUP_INSIDE_BOTTOM_GAP + GroupTitleHeight + GROUP_TOP_BORDER;

            // Size of the groups area (not including the top pixel that is placed in the tabs
            // area is the height of a group plus the bottom and top gaps).
            GroupsHeight = GroupHeight + GROUPS_BOTTOM_GAP + GROUPS_TOP_GAP;

            // Apply shape specific modifiers
            GroupHeight  += _groupHeightModifier;
            GroupsHeight += _groupsHeightModifier;
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Initialize a new instance of the CalculatedValues class.
        /// </summary>
        /// <param name="ribbon">Source control instance.</param>
        public CalculatedValues(KryptonRibbon ribbon)
        {
            Debug.Assert(ribbon != null);
            _ribbon = ribbon;

            _lastShape = PaletteRibbonShape.Inherit;
        }
 /// <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 storage for drawing objects.</param>
 public override IDisposable DrawRibbonTabContextTitle(PaletteRibbonShape shape,
                                                       RenderContext context,
                                                       Rectangle rect,
                                                       IPaletteRibbonGeneral paletteGeneral,
                                                       IPaletteRibbonBack paletteBack,
                                                       IDisposable memento)
 {
     return(DrawRibbonTabContext(context, rect, paletteGeneral, paletteBack, 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 override IDisposable DrawRibbonApplicationButton(PaletteRibbonShape shape,
                                                         RenderContext context,
                                                         Rectangle rect,
                                                         PaletteState state,
                                                         IPaletteRibbonBack palette,
                                                         IDisposable memento)
 {
     return(DrawRibbonAppButton(shape, context, rect, state, palette, true, memento));
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Perform drawing of a ribbon cluster edge.
        /// </summary>
        /// <param name="shape">Ribbon shape.</param>
        /// <param name="context">Render context.</param>
        /// <param name="displayRect">Display area available for drawing.</param>
        /// <param name="paletteBack">Palette used for recovering drawing details.</param>
        /// <param name="state">State associated with rendering.</param>
        public override void DrawRibbonClusterEdge(PaletteRibbonShape shape, RenderContext context, Rectangle displayRect, IPaletteBack paletteBack, PaletteState state)
        {
            Debug.Assert(context != null);

            Debug.Assert(paletteBack != null);

            // Get the first border color, and then lighten it by merging with white
            Color borderColour = paletteBack.GetBackColor1(state), lightColour = CommonHelper.MergeColors(borderColour, BORDER_PERCENT, Color.White, WHITE_PERCENT);

            // Draw inside of the border edge in a lighter version of the border
            using SolidBrush drawBrush = new(lightColour);
            context.Graphics.FillRectangle(drawBrush, displayRect);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Perform drawing of a ribbon context arrow glyph.
        /// </summary>
        /// <param name="shape">Ribbon shape.</param>
        /// <param name="context">Render context.</param>
        /// <param name="displayRect">Display area available for drawing.</param>
        /// <param name="paletteGeneral">General ribbon palette details.</param>
        /// <param name="state">State associated with rendering.</param>
        /// <param name="qatAbove"></param>
        public override void DrawRibbonContextArrow(PaletteRibbonShape shape,
                                                    RenderContext context,
                                                    Rectangle displayRect,
                                                    IPaletteRibbonGeneral paletteGeneral,
                                                    PaletteState state,
                                                    bool qatAbove)
        {
            Debug.Assert(context != null);
            Debug.Assert(paletteGeneral != null);

            // Validate parameter references
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (paletteGeneral == null)
            {
                throw new ArgumentNullException("paletteGeneral");
            }

            Color c1 = qatAbove ?   paletteGeneral.GetRibbonQATButtonLight(state) :
                       paletteGeneral.GetRibbonQATButtonDark(state);

            // If disabled then convert to black and white
            if (state == PaletteState.Disabled)
            {
                c1 = CommonHelper.ColorToBlackAndWhite(c1);
            }

            using (var pen = new Pen(c1))
            {
                if (DpiHelper.Default.DpiScaleFactor > 1.0 && DpiHelper.Default.EnableImagesScaling)
                {
                    context.Graphics.DrawLine(pen, displayRect.Left, displayRect.Top, displayRect.Left + 6, displayRect.Top);
                    context.Graphics.DrawLine(pen, displayRect.Left, displayRect.Top + 3, displayRect.Left + 6, displayRect.Top + 3);
                    context.Graphics.DrawLine(pen, displayRect.Left + 1, displayRect.Top + 4, displayRect.Left + 5, displayRect.Top + 4);
                    context.Graphics.DrawLine(pen, displayRect.Left + 2, displayRect.Top + 5, displayRect.Left + 4, displayRect.Top + 5);
                    pen.DashStyle = DashStyle.Dot; // draw one pixel!
                    context.Graphics.DrawLine(pen, displayRect.Left + 3, displayRect.Top + 6, displayRect.Left + 4, displayRect.Top + 6);
                }
                else
                {
                    context.Graphics.DrawLine(pen, displayRect.Left, displayRect.Top, displayRect.Left + 4, displayRect.Top);
                    context.Graphics.DrawLine(pen, displayRect.Left, displayRect.Top + 3, displayRect.Left + 4, displayRect.Top + 3);
                    context.Graphics.DrawLine(pen, displayRect.Left + 1, displayRect.Top + 4, displayRect.Left + 3, displayRect.Top + 4);
                    context.Graphics.DrawLine(pen, displayRect.Left + 2, displayRect.Top + 4, displayRect.Left + 2, displayRect.Top + 5);
                }
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Initialize a new instance of the ViewLayoutRibbonGroupCluster class.
        /// </summary>
        /// <param name="ribbon">Owning ribbon control instance.</param>
        /// <param name="ribbonCluster">Reference to cluster definition.</param>
        /// <param name="needPaint">Delegate for notifying paint requests.</param>
        public ViewLayoutRibbonGroupCluster(KryptonRibbon ribbon,
                                            KryptonRibbonGroupCluster ribbonCluster,
                                            NeedPaintHandler needPaint)
        {
            Debug.Assert(ribbon != null);
            Debug.Assert(ribbonCluster != null);
            Debug.Assert(needPaint != null);

            // Cache references
            _ribbon        = ribbon;
            _ribbonCluster = ribbonCluster;
            _needPaint     = needPaint;
            _currentSize   = GroupItemSize.Medium;

            // Associate the component with this view element for design time selection
            Component = _ribbonCluster;

            // Create the start and end separators
            _startSep        = new ViewDrawRibbonGroupClusterSeparator(_ribbon, true);
            _endSep          = new ViewDrawRibbonGroupClusterSeparator(_ribbon, false);
            _startSepVisible = false;
            _endSepVisible   = false;

            // Create palette used to supply a width to a border edge view
            PaletteBorderEdgeRedirect borderEdgeRedirect = new PaletteBorderEdgeRedirect(_ribbon.StateCommon.RibbonGroupClusterButton.Border, needPaint);

            _paletteBorderEdge = new PaletteBorderEdge(borderEdgeRedirect, needPaint);
            _lastShape         = PaletteRibbonShape.Office2007;

            // Use hashtable to store relationships
            _itemToView       = new ItemToView();
            _viewToEdge       = new ViewToEdge();
            _viewToSizeMedium = new ViewToSize();
            _viewToSizeSmall  = new ViewToSize();

            // Hook into changes in the ribbon cluster definition
            _ribbonCluster.PropertyChanged += new PropertyChangedEventHandler(OnClusterPropertyChanged);
            _ribbonCluster.ClusterView      = this;

            // At design time we want to track the mouse and show feedback
            if (_ribbon.InDesignMode)
            {
                ViewHightlightController controller = new ViewHightlightController(this, needPaint);
                controller.ContextClick += new MouseEventHandler(OnContextClick);
                MouseController          = controller;
            }
        }
Ejemplo n.º 14
0
        private void CreateNormalView()
        {
            // Create a layout for the main area
            _layoutNormalMain = new ViewLayoutRibbonTitle();

            if (_ribbon.InDesignMode)
            {
                // At design time we need to know when the user right clicks the group
                ContextClickController controller = new ContextClickController();
                controller.ContextClick          += new MouseEventHandler(OnContextClick);
                _layoutNormalMain.MouseController = controller;
            }

            // Create layout elements
            _layoutNormalTitle    = new ViewLayoutDocker();
            _layoutNormalContent  = new ViewLayoutRibbonGroupContent(_ribbon, _ribbonGroup, _needPaint);
            _layoutNormalSepTop   = new ViewLayoutRibbonSeparator(NORMAL_BORDER_TOPLEFT2007, true);
            _layoutNormalSepLeft  = new ViewLayoutRibbonSeparator(NORMAL_BORDER_TOPLEFT2007, true);
            _layoutNormalSepRight = new ViewLayoutRibbonSeparator(NORMAL_BORDER_RIGHT2007, true);

            // Add layout elements to correct areas of the normal group
            _layoutNormalMain.Add(_layoutNormalTitle, ViewDockStyle.Bottom);
            _layoutNormalMain.Add(_layoutNormalSepTop, ViewDockStyle.Top);
            _layoutNormalMain.Add(_layoutNormalSepLeft, ViewDockStyle.Left);
            _layoutNormalMain.Add(_layoutNormalSepRight, ViewDockStyle.Right);
            _layoutNormalMain.Add(_layoutNormalContent, ViewDockStyle.Fill);

            // Create and add the title string that fills remainder title area
            _viewNormalTitle = new ViewDrawRibbonGroupTitle(_ribbon, _ribbonGroup);
            _layoutNormalTitle.Add(_viewNormalTitle, ViewDockStyle.Fill);

            // Add the dialog box launcher button to the right side of title area
            _viewNormalDialog = new ViewLayoutRibbonGroupButton(_ribbon, _ribbonGroup, _needPaint);
            _layoutNormalContent.DialogView = _viewNormalDialog;
            _layoutNormalTitle.Add(_viewNormalDialog, ViewDockStyle.Right);

            // Use this class to return the context color for any null values
            _paletteContextBack = new PaletteRibbonContextBack(_ribbon);

            // All values are equal to a default of Office 2007 shape
            _lastRibbonShape = PaletteRibbonShape.Office2007;
            _totalBorders    = TOTAL_LEFT_RIGHT_BORDERS_2007;
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Perform drawing of a ribbon cluster edge.
        /// </summary>
        /// <param name="shape">Ribbon shape.</param>
        /// <param name="context">Render context.</param>
        /// <param name="displayRect">Display area available for drawing.</param>
        /// <param name="paletteBack">Palette used for recovering drawing details.</param>
        /// <param name="state">State associated with rendering.</param>
        public override void DrawRibbonClusterEdge(PaletteRibbonShape shape,
                                                   RenderContext context,
                                                   Rectangle displayRect,
                                                   IPaletteBack paletteBack,
                                                   PaletteState state)
        {
            Debug.Assert(context != null);
            Debug.Assert(paletteBack != null);

            // Get the first border color
            Color borderColor = paletteBack.GetBackColor1(state);

            // We want to lighten it by merging with white
            Color lightColor = CommonHelper.MergeColors(borderColor, BORDER_PERCENT,
                                                        Color.White, WHITE_PERCENT);

            // Draw inside of the border edge in a lighter version of the border
            using (SolidBrush drawBrush = new SolidBrush(lightColor))
                context.Graphics.FillRectangle(drawBrush, displayRect);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Perform a layout of the elements.
        /// </summary>
        /// <param name="context">Layout context.</param>
        public override void Layout(ViewLayoutContext context)
        {
            // Ensure we are using the correct palette
            CheckPaletteState(context);

            // Cache the ribbon shape
            _lastRibbonShape = (_navigator.Palette == null ? PaletteRibbonShape.Office2007 : _navigator.Palette.GetRibbonShape());

            // We take on all the provided size
            ClientRectangle = context.DisplayRectangle;

            Padding layoutPadding = Padding.Empty;

            switch (_borderBackOrient)
            {
            case VisualOrientation.Top:
                layoutPadding = _layoutBorderTop;
                break;

            case VisualOrientation.Left:
                layoutPadding = _layoutBorderLeft;
                break;

            case VisualOrientation.Right:
                layoutPadding = _layoutBorderRight;
                break;

            case VisualOrientation.Bottom:
                layoutPadding = _layoutBorderBottom;
                break;
            }

            // Reduce the display size by our border spacing
            context.DisplayRectangle = CommonHelper.ApplyPadding(_borderBackOrient, context.DisplayRectangle, layoutPadding);

            // Layout the content using the reduced size
            base.Layout(context);

            // Put back the original size before returning
            context.DisplayRectangle = ClientRectangle;
        }
        /// <summary>
        /// Gets an array of the allowed possible sizes of the container.
        /// </summary>
        /// <param name="context">Context used to calculate the sizes.</param>
        /// <returns>Array of size values.</returns>
        public ItemSizeWidth[] GetPossibleSizes(ViewLayoutContext context)
        {
            if (_lastShape != _ribbon.RibbonShape)
            {
                switch (_ribbon.RibbonShape)
                {
                default:
                case PaletteRibbonShape.Office2007:
                    _lastShape     = PaletteRibbonShape.Office2007;
                    _preferredSize = _preferredSize2007;
                    break;

                case PaletteRibbonShape.Office2010:
                    _lastShape     = PaletteRibbonShape.Office2010;
                    _preferredSize = _preferredSize2010;
                    break;
                }
            }

            // Return the one possible size allowed
            return(new ItemSizeWidth[] { new(GroupItemSize.Large, _preferredSize.Width) });
        /// <summary>
        /// Perform drawing of a ribbon drop arrow glyph.
        /// </summary>
        /// <param name="shape">Ribbon shape.</param>
        /// <param name="context">Render context.</param>
        /// <param name="displayRect">Display area available for drawing.</param>
        /// <param name="paletteGeneral">General ribbon palette details.</param>
        /// <param name="state">State associated with rendering.</param>
        /// <exception cref="ArgumentNullException"></exception>
        public override void DrawRibbonDropArrow(PaletteRibbonShape shape,
                                                 RenderContext context,
                                                 Rectangle displayRect,
                                                 IPaletteRibbonGeneral paletteGeneral,
                                                 PaletteState state)
        {
            Debug.Assert(context != null);
            Debug.Assert(paletteGeneral != null);

            // Validate parameter references
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (paletteGeneral == null)
            {
                throw new ArgumentNullException(nameof(paletteGeneral));
            }

            Color darkColor = (state == PaletteState.Disabled ? paletteGeneral.GetRibbonDisabledDark(state) :
                               paletteGeneral.GetRibbonGroupDialogDark(state));

            Color lightColor = (state == PaletteState.Disabled ? paletteGeneral.GetRibbonDisabledLight(state) :
                                paletteGeneral.GetRibbonGroupDialogLight(state));

            using (Pen darkPen = new Pen(darkColor),
                   lightPen = new Pen(lightColor))
            {
                context.Graphics.DrawLine(lightPen, displayRect.Left, displayRect.Top + 1, displayRect.Left + 2, displayRect.Top + 3);
                context.Graphics.DrawLine(lightPen, displayRect.Left + 2, displayRect.Top + 3, displayRect.Left + 4, displayRect.Top + 1);
                context.Graphics.DrawLine(lightPen, displayRect.Left + 4, displayRect.Top + 1, displayRect.Left + 1, displayRect.Top + 1);
                context.Graphics.DrawLine(lightPen, displayRect.Left + 1, displayRect.Top + 1, displayRect.Left + 2, displayRect.Top + 2);
                context.Graphics.DrawLine(darkPen, displayRect.Left, displayRect.Top + 2, displayRect.Left + 2, displayRect.Top + 4);
                context.Graphics.DrawLine(darkPen, displayRect.Left + 2, displayRect.Top + 4, displayRect.Left + 4, displayRect.Top + 2);
            }
        }
Ejemplo n.º 19
0
        /// <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 override IDisposable DrawRibbonBack(PaletteRibbonShape shape,
                                                   RenderContext context,
                                                   Rectangle rect,
                                                   PaletteState state,
                                                   IPaletteRibbonBack palette,
                                                   VisualOrientation orientation,
                                                   bool composition,
                                                   IDisposable memento)
        {
            // Note is the incoming state is detailed we are drawing inside a popup
            var showingInPopup = (state & PaletteState.FocusOverride) == PaletteState.FocusOverride;

            if (showingInPopup)
            {
                state &= ~PaletteState.FocusOverride;
            }

            return(palette.GetRibbonBackColorStyle(state) switch
            {
                PaletteRibbonColorStyle.RibbonGroupNormalBorderTracking => DrawRibbonGroupNormalBorder(context, rect, state, palette, true, false, memento),
                PaletteRibbonColorStyle.RibbonGroupAreaBorder => DrawRibbonGroupAreaBorder1And2(context, rect, state, palette, false, true, memento),
                PaletteRibbonColorStyle.RibbonGroupAreaBorder2 => DrawRibbonGroupAreaBorder1And2(context, rect, state, palette, true, true, memento),
                _ => base.DrawRibbonBack(shape, context, rect, state, palette, orientation, composition, memento)
            });
Ejemplo n.º 20
0
 /// <summary>
 /// Perform drawing of a ribbon cluster edge.
 /// </summary>
 /// <param name="shape">Ribbon shape.</param>
 /// <param name="context">Render context.</param>
 /// <param name="displayRect">Display area available for drawing.</param>
 /// <param name="paletteBack">Palette used for recovering drawing details.</param>
 /// <param name="state">State associated with rendering.</param>
 public abstract void DrawRibbonClusterEdge(PaletteRibbonShape shape,
                                            RenderContext context,
                                            Rectangle displayRect,
                                            IPaletteBack paletteBack,
                                            PaletteState state);
Ejemplo n.º 21
0
 /// <summary>
 /// Draw the application tab.
 /// </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="baseColor1">Base color1 used for drawing the ribbon tab.</param>
 /// <param name="baseColor2">Base color2 used for drawing the ribbon tab.</param>
 /// <param name="memento">Cached values to use when drawing.</param>
 public abstract IDisposable DrawRibbonApplicationTab(PaletteRibbonShape shape,
                                                      RenderContext context,
                                                      Rectangle rect,
                                                      PaletteState state,
                                                      Color baseColor1,
                                                      Color baseColor2,
                                                      IDisposable memento);
Ejemplo n.º 22
0
        /// <summary>
        /// Internal rendering method.
        /// </summary>
        protected virtual IDisposable DrawRibbonAppButton(PaletteRibbonShape shape,
                                                          RenderContext context,
                                                          Rectangle rect,
                                                          PaletteState state,
                                                          IPaletteRibbonBack palette,
                                                          bool trackBorderAsPressed,
                                                          IDisposable memento)
        {
            // Reduce the area of the actual button as the extra space is used for shadow
            rect.Width -= 3;
            rect.Height -= 3;

            if ((rect.Width > 0) && (rect.Height > 0))
            {
                // Get the colors from the palette
                Color topLight = palette.GetRibbonBackColor1(state);
                Color topMedium = palette.GetRibbonBackColor2(state);
                Color topDark = palette.GetRibbonBackColor3(state);
                Color bottomLight = palette.GetRibbonBackColor4(state);
                Color bottomMedium = palette.GetRibbonBackColor5(state);
                Color bottomDark = CommonHelper.MergeColors(topDark, 0.78f, Color.Empty, 0.22f);

                bool generate = true;
                MementoRibbonAppButton cache;

                // Access a cache instance and decide if cache resources need generating
                if ((memento == null) || !(memento is MementoRibbonAppButton))
                {
                    if (memento != null)
                        memento.Dispose();

                    cache = new MementoRibbonAppButton(rect, topLight, topMedium,
                                                       topDark, bottomLight, bottomMedium);
                    memento = cache;
                }
                else
                {
                    cache = (MementoRibbonAppButton)memento;
                    generate = !cache.UseCachedValues(rect, topLight, topMedium,
                                                      topDark, bottomLight, bottomMedium);
                }

                // Do we need to generate the contents of the cache?
                if (generate)
                {
                    // Dispose of existing values
                    cache.Dispose();

                    cache.borderShadow1 = new RectangleF(rect.X, rect.Y, rect.Width + 2, rect.Height + 2);
                    cache.borderShadow2 = new RectangleF(rect.X, rect.Y, rect.Width + 1, rect.Height + 1);
                    cache.borderMain1 = new RectangleF(rect.X + 1, rect.Y + 1, rect.Width - 2, rect.Height - 2);
                    cache.borderMain2 = new RectangleF(cache.borderMain1.X + 1, cache.borderMain1.Y + 1, cache.borderMain1.Width - 2, cache.borderMain1.Height - 2);
                    cache.borderMain3 = new RectangleF(cache.borderMain1.X + 1, cache.borderMain1.Y + 1, cache.borderMain1.Width - 2, cache.borderMain1.Height - 2);
                    cache.borderMain4 = new RectangleF(cache.borderMain2.X, cache.borderMain2.Y + 1, cache.borderMain2.Width, cache.borderMain2.Height - 2);
                    cache.rectBottomGlow = new RectangleF(0, 0, rect.Width * 0.75f, rect.Height * 0.75f);
                    cache.rectLower = new RectangleF(rect.X, rect.Y - 1, rect.Width, rect.Height + 1);
                    cache.rectUpperGlow = new RectangleF();
                    cache.rectUpperGlow.Width = rect.Width - 4;
                    cache.rectUpperGlow.Height = rect.Height / 8;
                    cache.rectUpperGlow.Y = rect.Y + (rect.Height - cache.rectUpperGlow.Height) / 2;
                    cache.rectUpperGlow.X = rect.X + (rect.Width - cache.rectUpperGlow.Width) / 2;

                    cache.brushUpper1 = new LinearGradientBrush(rect, Color.Transparent, Color.Transparent, LinearGradientMode.Horizontal);
                    cache.brushLower = new LinearGradientBrush(cache.rectLower, Color.Transparent, Color.Transparent, LinearGradientMode.Horizontal);
                }

                using (AntiAlias aa = new AntiAlias(context.Graphics))
                {
                    DrawRibbonAppButtonBorder1(context.Graphics, cache);
                    DrawRibbonAppButtonUpperHalf(context.Graphics, cache, state, topDark, bottomDark, topLight, topMedium, trackBorderAsPressed);
                    DrawRibbonAppButtonLowerHalf(context.Graphics, cache, state, bottomDark, bottomLight, bottomMedium);
                    DrawRibbonAppButtonGlowCenter(context.Graphics, cache, state, topLight, bottomLight);
                    DrawRibbonAppButtonGlowUpperBottom(context.Graphics, cache, state, bottomLight, bottomMedium, bottomDark);
                    DrawRibbonAppButtonBorder2(context.Graphics, cache, state, bottomLight, trackBorderAsPressed);
                }
            }

            return memento;
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Draw the application tab.
        /// </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="baseColor1">Base color1 used for drawing the ribbon tab.</param>
        /// <param name="baseColor2">Base color2 used for drawing the ribbon tab.</param>
        /// <param name="memento">Cached values to use when drawing.</param>
        public override IDisposable DrawRibbonApplicationTab(PaletteRibbonShape shape, RenderContext context, Rectangle rect, PaletteState state, Color baseColor1, Color baseColor2, IDisposable memento)
        {
            if ((rect.Width > 0) && (rect.Height > 0))
            {
                var generate = true;
                MementoRibbonAppTab2013 cache;

                // Access a cache instance and decide if cache resources need generating
                if (memento is MementoRibbonAppTab2013 tab2013)
                {
                    cache    = tab2013;
                    generate = !cache.UseCachedValues(rect, baseColor1);
                }
                else
                {
                    memento?.Dispose();

                    cache   = new MementoRibbonAppTab2013(rect, baseColor1);
                    memento = cache;
                }

                // Do we need to generate the contents of the cache?
                if (generate)
                {
                    // Dispose of existing values
                    cache.Dispose();

                    // Create common paths to all the app tab states
                    cache.GeneratePaths(rect, state);
                    //cache.borderPen = new Pen(baseColor1);

                    // Create state specific colors/brushes/pens
                    cache.insideFillBrush = state switch
                    {
                        PaletteState.Normal =>
                        //cache.borderBrush = new SolidBrush(baseColor1);
                        new SolidBrush(baseColor1),
                        PaletteState.Tracking => new SolidBrush(baseColor2),
                        PaletteState.Tracking | PaletteState.FocusOverride => new SolidBrush(
                            ControlPaint.LightLight(baseColor2)),
                        PaletteState.Pressed => new SolidBrush(baseColor2),
                        _ => cache.insideFillBrush
                    };
                }

                // Fill the entire tab area and then add a border around the edge
                //context.Graphics.FillPath(cache.borderBrush, cache.borderFillPath);

                // Draw the outside border
                //using (AntiAlias aa = new AntiAlias(context.Graphics))
                //    context.Graphics.DrawPath(cache.borderPen, cache.borderPath);

                // Fill inside area
                //context.Graphics.FillPath(cache.insideFillBrush, cache.insideFillPath);
                context.Graphics.FillRectangle(cache.insideFillBrush, cache.rect);

                // Draw highlight over bottom half
                //using (Clipping clip = new Clipping(context.Graphics, cache.insideFillPath))
                //    context.Graphics.FillPath(cache.highlightBrush, cache.highlightPath);
            }

            return(memento);
        }
Ejemplo n.º 24
0
        private void SyncChildrenToRibbonGroupItems()
        {
            // Grab the shape of the ribbon
            _lastShape = _ribbon.RibbonShape;

            bool itemEdgeVisible          = (_lastShape != PaletteRibbonShape.Office2010);
            bool itemEdgeIgnoreNormal     = (_lastShape == PaletteRibbonShape.Office2010);
            bool itemConstantBorder       = (_lastShape != PaletteRibbonShape.Office2010);
            bool itemDrawNonTrackingAreas = (_lastShape != PaletteRibbonShape.Office2010);

            // Remove all child elements
            Clear();

            // Always add the start separator as the first view element
            Add(_startSep);

            // Create new lookups which are up to date
            ItemToView regenView = new ItemToView();
            ViewToEdge regenEdge = new ViewToEdge();

            // Cache the first and last visible children
            ViewBase viewFirst = null;
            ViewBase viewLast  = null;

            // Add a view element for each group item
            foreach (IRibbonGroupItem item in _ribbonCluster.Items)
            {
                ViewBase itemView;
                ViewDrawRibbonGroupClusterEdge itemEdge;

                // Do we already have a view for this item definition
                if (_itemToView.ContainsKey(item))
                {
                    itemView = _itemToView[item];
                    itemEdge = _viewToEdge[itemView];

                    // Remove from lookups
                    _itemToView.Remove(item);
                    _viewToEdge.Remove(itemView);
                }
                else
                {
                    // Ask the item definition to return an appropriate view
                    itemView = item.CreateView(_ribbon, _needPaint);

                    // Create a border edge to go with the item view
                    itemEdge = new ViewDrawRibbonGroupClusterEdge(_ribbon, _paletteBorderEdge);
                }

                // Update the visible state
                itemView.Visible = _ribbon.InDesignHelperMode || item.Visible;
                itemEdge.Visible = itemEdgeVisible && (_ribbon.InDesignHelperMode || item.Visible);

                // We need to remember associations
                regenView.Add(item, itemView);
                regenEdge.Add(itemView, itemEdge);

                Add(itemView);
                Add(itemEdge);

                // Update the cached first/last items
                if (itemView.Visible && (viewFirst == null))
                {
                    viewFirst = itemView;
                }

                if (itemView.Visible)
                {
                    viewLast = itemView;
                }
            }

            // Update the display borders for the visible items
            foreach (ViewBase item in regenView.Values)
            {
                // Only interested in visible items
                if (item.Visible)
                {
                    if ((item is ViewDrawRibbonGroupClusterButton) ||
                        (item is ViewDrawRibbonGroupClusterColorButton))
                    {
                        // By default each button shows only the top and bottom
                        PaletteDrawBorders maxBorders = PaletteDrawBorders.TopBottom;

                        switch (_lastShape)
                        {
                        default:
                        case PaletteRibbonShape.Office2007:
                            maxBorders = PaletteDrawBorders.TopBottom;

                            // First and last items have extra borders
                            if (item == viewFirst)
                            {
                                // If first and last, it needs all borders
                                if (item == viewLast)
                                {
                                    maxBorders = PaletteDrawBorders.All;
                                }
                                else
                                {
                                    maxBorders = PaletteDrawBorders.TopBottomLeft;
                                }
                            }
                            else if (item == viewLast)
                            {
                                maxBorders = PaletteDrawBorders.TopBottomRight;
                            }
                            break;

                        case PaletteRibbonShape.Office2010:
                            maxBorders = PaletteDrawBorders.All;
                            break;
                        }

                        // Remove the border edge after the last button
                        if (item == viewLast)
                        {
                            Remove(regenEdge[item]);
                        }

                        // Cast to correct type
                        ViewDrawRibbonGroupClusterButton      clusterButton      = item as ViewDrawRibbonGroupClusterButton;
                        ViewDrawRibbonGroupClusterColorButton clusterColorButton = item as ViewDrawRibbonGroupClusterColorButton;

                        if (clusterButton != null)
                        {
                            clusterButton.MaxBorderEdges       = maxBorders;
                            clusterButton.BorderIgnoreNormal   = itemEdgeIgnoreNormal;
                            clusterButton.ConstantBorder       = itemConstantBorder;
                            clusterButton.DrawNonTrackingAreas = itemDrawNonTrackingAreas;
                        }

                        if (clusterColorButton != null)
                        {
                            clusterColorButton.MaxBorderEdges       = maxBorders;
                            clusterColorButton.BorderIgnoreNormal   = itemEdgeIgnoreNormal;
                            clusterColorButton.ConstantBorder       = itemConstantBorder;
                            clusterColorButton.DrawNonTrackingAreas = itemDrawNonTrackingAreas;
                        }
                    }
                }
            }

            // Dispose of all the items no longer needed
            foreach (ViewBase view in _itemToView.Values)
            {
                view.Dispose();
            }

            foreach (ViewBase view in _viewToEdge.Values)
            {
                view.Dispose();
            }

            // Always add the end separator as the last view element (excluding any desing time additions)
            Add(_endSep);

            // Define visible state of the separators
            _startSep.Visible = (_lastShape == PaletteRibbonShape.Office2010);
            _endSep.Visible   = (_lastShape == PaletteRibbonShape.Office2010);

            // When in design time help mode
            if (_ribbon.InDesignHelperMode)
            {
                // Create the design time 'Item' first time it is needed
                if (_viewAddItem == null)
                {
                    _viewAddItem = new ViewDrawRibbonDesignCluster(_ribbon,
                                                                   _ribbonCluster,
                                                                   _needPaint);
                }

                // Always add at end of the list of items
                Add(_viewAddItem);
            }

            // Use the latest tables
            _itemToView = regenView;
            _viewToEdge = regenEdge;
        }
Ejemplo n.º 25
0
 /// <summary>
 /// Draw the application tab.
 /// </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="baseColor1">Base color1 used for drawing the ribbon tab.</param>
 /// <param name="baseColor2">Base color2 used for drawing the ribbon tab.</param>
 /// <param name="memento">Cached values to use when drawing.</param>
 public override IDisposable DrawRibbonApplicationTab(PaletteRibbonShape shape,
                                                      RenderContext context,
                                                      Rectangle rect,
                                                      PaletteState state,
                                                      Color baseColor1,
                                                      Color baseColor2,
                                                      IDisposable memento)
 {
     return DrawRibbonAppTab(shape, context, rect, state, baseColor1, baseColor2, memento);
 }
Ejemplo n.º 26
0
        /// <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;
        }
Ejemplo n.º 27
0
        /// <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;
        }
Ejemplo n.º 28
0
        /// <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;
        }
Ejemplo n.º 29
0
        /// <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;
        }
Ejemplo n.º 30
0
        /// <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;
        }
Ejemplo n.º 31
0
        /// <summary>
        /// Internal rendering method.
        /// </summary>
        protected virtual IDisposable DrawRibbonAppTab(PaletteRibbonShape shape,
                                                       RenderContext context,
                                                       Rectangle rect,
                                                       PaletteState state,
                                                       Color baseColor1,
                                                       Color baseColor2,
                                                       IDisposable memento)
        {
            if ((rect.Width > 0) && (rect.Height > 0))
            {
                bool generate = true;
                MementoRibbonAppTab cache;

                // Access a cache instance and decide if cache resources need generating
                if ((memento == null) || !(memento is MementoRibbonAppTab))
                {
                    if (memento != null)
                        memento.Dispose();

                    cache = new MementoRibbonAppTab(rect, baseColor1, baseColor2);
                    memento = cache;
                }
                else
                {
                    cache = (MementoRibbonAppTab)memento;
                    generate = !cache.UseCachedValues(rect, baseColor1, baseColor2);
                }

                // Do we need to generate the contents of the cache?
                if (generate)
                {
                    // Dispose of existing values
                    cache.Dispose();

                    // Create common paths to all the app tab states
                    cache.GeneratePaths(rect, state);
                    cache.borderPen = new Pen(baseColor1);

                    // Create state specific colors/brushes/pens
                    switch (state)
                    {
                        case PaletteState.Normal:
                            cache.borderBrush = new SolidBrush(CommonHelper.MergeColors(baseColor1, 0.2f, baseColor2, 0.8f));
                            cache.insideFillBrush = new LinearGradientBrush(new RectangleF(rect.X, rect.Y + 1, rect.Width, rect.Height),
                                                                            CommonHelper.MergeColors(baseColor1, 0.3f, baseColor2, 0.7f),
                                                                            CommonHelper.MergeColors(baseColor1, 0.6f, baseColor2, 0.4f),
                                                                            90f);

                            cache.insideFillBrush.SetSigmaBellShape(0.33f);
                            cache.highlightBrush.CenterColor = Color.FromArgb(64, Color.White);
                            break;
                        case PaletteState.Tracking:
                            cache.borderBrush = new SolidBrush(baseColor2);
                            cache.insideFillBrush = new LinearGradientBrush(new RectangleF(rect.X, rect.Y + 1, rect.Width, rect.Height),
                                                                            CommonHelper.MergeColors(baseColor1, 0.3f, baseColor2, 0.7f),
                                                                            CommonHelper.MergeColors(baseColor1, 0.6f, baseColor2, 0.4f),
                                                                            90f);

                            cache.insideFillBrush.SetSigmaBellShape(0.33f);
                            cache.highlightBrush.CenterColor = Color.FromArgb(100, Color.White);
                            break;
                        case PaletteState.Tracking | PaletteState.FocusOverride:
                            cache.borderBrush = new SolidBrush(ControlPaint.LightLight(baseColor2));
                            cache.insideFillBrush = new LinearGradientBrush(new RectangleF(rect.X, rect.Y + 1, rect.Width, rect.Height),
                                                                            CommonHelper.MergeColors(baseColor1, 0.3f, baseColor2, 0.7f),
                                                                            CommonHelper.MergeColors(baseColor1, 0.6f, baseColor2, 0.4f),
                                                                            90f);

                            cache.insideFillBrush.SetSigmaBellShape(0.33f);
                            cache.highlightBrush.CenterColor = ControlPaint.LightLight(baseColor2);
                            break;
                        case PaletteState.Pressed:
                            cache.borderBrush = new SolidBrush(CommonHelper.MergeColors(baseColor1, 0.5f, baseColor2, 0.5f));
                            cache.insideFillBrush = new LinearGradientBrush(new RectangleF(rect.X, rect.Y + 1, rect.Width, rect.Height),
                                                                            CommonHelper.MergeColors(baseColor1, 0.3f, baseColor2, 0.7f),
                                                                            CommonHelper.MergeColors(baseColor1, 0.75f, baseColor2, 0.25f),
                                                                            90f);

                            cache.insideFillBrush.SetSigmaBellShape(0f);
                            cache.highlightBrush.CenterColor = Color.FromArgb(90, Color.White);
                            break;
                    }
                }

                // Fill the entire tab area and then add a border around the edge
                context.Graphics.FillPath(cache.borderBrush, cache.borderFillPath);

                // Draw the outside border
                using (AntiAlias aa = new AntiAlias(context.Graphics))
                    context.Graphics.DrawPath(cache.borderPen, cache.borderPath);

                // Fill inside area
                context.Graphics.FillPath(cache.insideFillBrush, cache.insideFillPath);

                // Draw highlight over bottom half
                using(Clipping clip = new Clipping(context.Graphics, cache.insideFillPath))
                    context.Graphics.FillPath(cache.highlightBrush, cache.highlightPath);
            }

            return memento;
        }
Ejemplo n.º 32
0
        /// <summary>
        /// Perform drawing of a ribbon group separator.
        /// </summary>
        /// <param name="shape">Ribbon shape.</param>
        /// <param name="context">Render context.</param>
        /// <param name="displayRect">Display area available for drawing.</param>
        /// <param name="paletteGeneral">General ribbon palette details.</param>
        /// <param name="state">State associated with rendering.</param>
        public override void DrawRibbonGroupSeparator(PaletteRibbonShape shape,
                                                      RenderContext context,
                                                      Rectangle displayRect,
                                                      IPaletteRibbonGeneral paletteGeneral,
                                                      PaletteState state)
        {
            Debug.Assert(context != null);
            Debug.Assert(paletteGeneral != null);

            // Validate parameter references
            if (context == null) throw new ArgumentNullException("context");
            if (paletteGeneral == null) throw new ArgumentNullException("paletteGeneral");

            int x = displayRect.X + (displayRect.Width - 2) / 2;
            Color darkColor = paletteGeneral.GetRibbonGroupSeparatorDark(state);
            Color lightColor = paletteGeneral.GetRibbonGroupSeparatorLight(state);

            switch (shape)
            {
                default:
                case PaletteRibbonShape.Office2007:
                    using (Pen darkPen = new Pen(darkColor),
                               lightPen = new Pen(lightColor))
                    {
                        context.Graphics.DrawLine(lightPen, x, displayRect.Top + 2, x, displayRect.Bottom - 3);
                        context.Graphics.DrawLine(darkPen, x + 1, displayRect.Top + 2, x + 1, displayRect.Bottom - 3);
                    }
                    break;
                case PaletteRibbonShape.Office2010:
                    using (LinearGradientBrush darkBrush = new LinearGradientBrush(new RectangleF(displayRect.X, displayRect.Y - 1, displayRect.Width, displayRect.Height + 2), Color.FromArgb(72, darkColor), darkColor, 90f),
                                               lightBrush = new LinearGradientBrush(new RectangleF(displayRect.X - 1, displayRect.Y - 1, displayRect.Width + 2, displayRect.Height + 2), Color.FromArgb(128, lightColor), lightColor, 90f))
                    {
                        darkBrush.SetSigmaBellShape(0.5f);
                        lightBrush.SetSigmaBellShape(0.5f);

                        using (Pen darkPen = new Pen(darkBrush))
                        {
                            context.Graphics.FillRectangle(lightBrush, x, displayRect.Top, 3, displayRect.Height);
                            context.Graphics.DrawLine(darkPen, x + 1, displayRect.Top, x + 1, displayRect.Bottom - 1);
                        }
                    }
                    break;
            }
        }
Ejemplo n.º 33
0
        /// <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 override IDisposable DrawRibbonBack(PaletteRibbonShape shape,
                                                   RenderContext context,
                                                   Rectangle rect,
                                                   PaletteState state,
                                                   IPaletteRibbonBack palette,
                                                   VisualOrientation orientation,
                                                   bool composition,
                                                   IDisposable memento)
        {
            // Note is the incoming state is detailed we are drawing inside a popip
            bool showingInPopup = ((state & PaletteState.FocusOverride) == PaletteState.FocusOverride);
            if (showingInPopup)
                state = state & ~PaletteState.FocusOverride;

            switch (palette.GetRibbonBackColorStyle(state))
            {
                case PaletteRibbonColorStyle.Empty:
                    // Do nothing
                    break;
                case PaletteRibbonColorStyle.Solid:
                    using (SolidBrush backBrush = new SolidBrush(palette.GetRibbonBackColor1(state)))
                        context.Graphics.FillRectangle(backBrush, rect);
                    break;
                case PaletteRibbonColorStyle.Linear:
                    return DrawRibbonLinear(context, rect, state, palette, memento);
                case PaletteRibbonColorStyle.LinearBorder:
                    return DrawRibbonLinearBorder(context, rect, state, palette, memento);
                case PaletteRibbonColorStyle.RibbonAppMenuInner:
                    return DrawRibbonAppMenuInner(context, rect, state, palette, memento);
                case PaletteRibbonColorStyle.RibbonAppMenuOuter:
                    return DrawRibbonAppMenuOuter(context, rect, state, palette, memento);
                case PaletteRibbonColorStyle.RibbonQATFullbarRound:
                    return DrawRibbonQATFullbarRound(context, rect, state, palette, memento);
                case PaletteRibbonColorStyle.RibbonQATFullbarSquare:
                    return DrawRibbonQATFullbarSquare(context, rect, state, palette, memento);
                case PaletteRibbonColorStyle.RibbonQATMinibarSingle:
                    return DrawRibbonQATMinibarSingle(context, rect, state, palette, composition, memento);
                case PaletteRibbonColorStyle.RibbonQATMinibarDouble:
                    return DrawRibbonQATMinibarDouble(context, rect, state, palette, composition, memento);
                case PaletteRibbonColorStyle.RibbonQATOverflow:
                    return DrawRibbonQATOverflow(shape, context, rect, state, palette, memento);
                case PaletteRibbonColorStyle.RibbonGroupGradientOne:
                    return DrawRibbonGroupGradientOne(context, rect, state, palette, memento);
                case PaletteRibbonColorStyle.RibbonGroupGradientTwo:
                    return DrawRibbonGroupGradientTwo(context, rect, state, palette, _groupGradientTwo, memento);
                case PaletteRibbonColorStyle.RibbonGroupCollapsedBorder:
                    return DrawRibbonGroupCollapsedBorder(context, rect, state, palette, memento);
                case PaletteRibbonColorStyle.RibbonGroupCollapsedFrameBorder:
                    return DrawRibbonGroupCollapsedFrameBorder(context, rect, state, palette, memento);
                case PaletteRibbonColorStyle.RibbonGroupCollapsedFrameBack:
                    return DrawRibbonGroupGradientTwo(context, rect, state, palette, _groupGradientFrame, memento);
                case PaletteRibbonColorStyle.RibbonGroupNormalBorder:
                    return DrawRibbonGroupNormalBorder(context, rect, state, palette, false, false, memento);
                case PaletteRibbonColorStyle.RibbonGroupNormalBorderSep:
                    return DrawRibbonGroupNormalBorderSep(showingInPopup, context, rect, state, palette, memento, false, false, false);
                case PaletteRibbonColorStyle.RibbonGroupNormalBorderSepPressedLight:
                    return DrawRibbonGroupNormalBorderSep(showingInPopup, context, rect, state, palette, memento, true, false, false);
                case PaletteRibbonColorStyle.RibbonGroupNormalBorderSepPressedDark:
                    return DrawRibbonGroupNormalBorderSep(showingInPopup, context, rect, state, palette, memento, true, false, true);
                case PaletteRibbonColorStyle.RibbonGroupNormalBorderSepTrackingLight:
                    return DrawRibbonGroupNormalBorderSep(showingInPopup, context, rect, state, palette, memento, false, true, false);
                case PaletteRibbonColorStyle.RibbonGroupNormalBorderSepTrackingDark:
                    return DrawRibbonGroupNormalBorderSep(showingInPopup, context, rect, state, palette, memento, false, true, true);
                case PaletteRibbonColorStyle.RibbonGroupNormalBorderTracking:
                    return DrawRibbonGroupNormalBorder(context, rect, state, palette, true, false, memento);
                case PaletteRibbonColorStyle.RibbonGroupNormalBorderTrackingLight:
                    return DrawRibbonGroupNormalBorder(context, rect, state, palette, true, true, memento);
                case PaletteRibbonColorStyle.RibbonGroupNormalTitle:
                    return DrawRibbonGroupNormalTitle(context, rect, state, palette, memento);
                case PaletteRibbonColorStyle.RibbonGroupAreaBorder:
                    return DrawRibbonGroupAreaBorder1And2(context, rect, state, palette, false, false, memento);
                case PaletteRibbonColorStyle.RibbonGroupAreaBorder2:
                    return DrawRibbonGroupAreaBorder1And2(context, rect, state, palette, true, false, memento);
                case PaletteRibbonColorStyle.RibbonGroupAreaBorder3:
                    return DrawRibbonGroupAreaBorder3And4(context, rect, state, palette, memento, true);
                case PaletteRibbonColorStyle.RibbonGroupAreaBorder4:
                    return DrawRibbonGroupAreaBorder3And4(context, rect, state, palette, memento, false);
                case PaletteRibbonColorStyle.RibbonGroupAreaBorderContext:
                    return DrawRibbonGroupAreaBorderContext(context, rect, state, palette, memento);
                case PaletteRibbonColorStyle.RibbonTabTracking2007:
                    return DrawRibbonTabTracking2007(shape, context, rect, state, palette, orientation, memento);
                case PaletteRibbonColorStyle.RibbonTabFocus2010:
                    return DrawRibbonTabFocus2010(shape, context, rect, state, palette, orientation, memento);
                case PaletteRibbonColorStyle.RibbonTabTracking2010:
                    return DrawRibbonTabTracking2010(shape, context, rect, state, palette, orientation, memento, true);
                case PaletteRibbonColorStyle.RibbonTabTracking2010Alt:
                    return DrawRibbonTabTracking2010(shape, context, rect, state, palette, orientation, memento, false);
                case PaletteRibbonColorStyle.RibbonTabGlowing:
                    return DrawRibbonTabGlowing(shape, context, rect, state, palette, orientation, memento);
                case PaletteRibbonColorStyle.RibbonTabHighlight:
                    return DrawRibbonTabHighlight(shape, context, rect, state, palette, orientation, memento, false);
                case PaletteRibbonColorStyle.RibbonTabHighlight2:
                    return DrawRibbonTabHighlight(shape, context, rect, state, palette, orientation, memento, true);
                case PaletteRibbonColorStyle.RibbonTabSelected2007:
                    return DrawRibbonTabSelected2007(context, rect, state, palette, orientation, memento);
                case PaletteRibbonColorStyle.RibbonTabSelected2010:
                    return DrawRibbonTabSelected2010(context, rect, state, palette, orientation, memento, true);
                case PaletteRibbonColorStyle.RibbonTabSelected2010Alt:
                    return DrawRibbonTabSelected2010(context, rect, state, palette, orientation, memento, false);
                case PaletteRibbonColorStyle.RibbonTabContextSelected:
                    return DrawRibbonTabContextSelected(shape, context, rect, state, palette, orientation, memento);
                default:
                    // Should never happen!
                    Debug.Assert(false);
                    break;
            }

            return null;
        }
Ejemplo n.º 34
0
        /// <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;
        }
Ejemplo n.º 35
0
 /// <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 override IDisposable DrawRibbonApplicationButton(PaletteRibbonShape shape,
                                                         RenderContext context,
                                                         Rectangle rect,
                                                         PaletteState state,
                                                         IPaletteRibbonBack palette,
                                                         IDisposable memento)
 {
     return DrawRibbonAppButton(shape, context, rect, state, palette, false, memento);
 }
Ejemplo n.º 36
0
 /// <summary>
 /// Perform drawing of a ribbon overflow image.
 /// </summary>
 /// <param name="shape">Ribbon shape.</param>
 /// <param name="context">Render context.</param>
 /// <param name="displayRect">Display area available for drawing.</param>
 /// <param name="paletteGeneral">General ribbon palette details.</param>
 /// <param name="state">State associated with rendering.</param>
 public abstract void DrawRibbonOverflow(PaletteRibbonShape shape,
                                         RenderContext context,
                                         Rectangle displayRect,
                                         IPaletteRibbonGeneral paletteGeneral,
                                         PaletteState state);
        /// <summary>
        /// Initialize a new instance of the PaletteRibbonGeneral class.
        /// </summary>
        /// <param name="inherit">Source for inheriting general values.</param>
        /// <param name="needPaint">Delegate for notifying paint requests.</param>
        public PaletteRibbonGeneral(IPaletteRibbonGeneral inherit,
                                    NeedPaintHandler needPaint)
        {
            Debug.Assert(inherit != null);

            // Remember inheritance
            _inherit = inherit;

            // Store the provided paint notification delegate
            NeedPaint = needPaint;

            // Set default values
            _contextTextAlign = PaletteRelativeAlign.Inherit;
            _contextTextColor = Color.Empty;
            _contextTextFont = null;
            _disabledDarkColor = Color.Empty;
            _disabledLightColor = Color.Empty;
            _dialogDarkColor = Color.Empty;
            _dialogLightColor = Color.Empty;
            _dropArrowLightColor = Color.Empty;
            _dropArrowDarkColor = Color.Empty;
            _groupSeparatorDark = Color.Empty;
            _groupSeparatorLight = Color.Empty;
            _minimizeBarDarkColor = Color.Empty;
            _minimizeBarLightColor = Color.Empty;
            _ribbonShape = PaletteRibbonShape.Inherit;
            _tabSeparatorColor = Color.Empty;
            _tabSeparatorContextColor = Color.Empty;
            _textFont = null;
            _textHint = PaletteTextHint.Inherit;
            _qatButtonDarkColor = Color.Empty;
            _qatButtonLightColor = Color.Empty;
        }
Ejemplo n.º 38
0
        /// <summary>
        /// Perform drawing of a ribbon dialog box launcher glyph.
        /// </summary>
        /// <param name="shape">Ribbon shape.</param>
        /// <param name="context">Render context.</param>
        /// <param name="displayRect">Display area available for drawing.</param>
        /// <param name="paletteGeneral">General ribbon palette details.</param>
        /// <param name="state">State associated with rendering.</param>
        public override void DrawRibbonDialogBoxLauncher(PaletteRibbonShape shape,
                                                         RenderContext context,
                                                         Rectangle displayRect,
                                                         IPaletteRibbonGeneral paletteGeneral,
                                                         PaletteState state)
        {
            Debug.Assert(context != null);
            Debug.Assert(paletteGeneral != null);

            // Validate parameter references
            if (context == null) throw new ArgumentNullException("context");
            if (paletteGeneral == null) throw new ArgumentNullException("paletteGeneral");

            switch (shape)
            {
                default:
                case PaletteRibbonShape.Office2007:
                    using (Pen darkPen = new Pen(paletteGeneral.GetRibbonGroupDialogDark(state)),
                               lightPen = new Pen(paletteGeneral.GetRibbonGroupDialogLight(state)))
                    {
                        context.Graphics.DrawLine(darkPen, displayRect.Left, displayRect.Top + 5, displayRect.Left, displayRect.Top);
                        context.Graphics.DrawLine(darkPen, displayRect.Left, displayRect.Top, displayRect.Left + 5, displayRect.Top);
                        context.Graphics.DrawLine(lightPen, displayRect.Left + 1, displayRect.Top + 5, displayRect.Left + 1, displayRect.Top + 1);
                        context.Graphics.DrawLine(lightPen, displayRect.Left + 1, displayRect.Top + 1, displayRect.Left + 5, displayRect.Top + 1);
                        context.Graphics.DrawLine(lightPen, displayRect.Right - 1, displayRect.Bottom - 5, displayRect.Right - 1, displayRect.Bottom - 1);
                        context.Graphics.DrawLine(lightPen, displayRect.Right - 1, displayRect.Bottom - 1, displayRect.Right - 4, displayRect.Bottom - 1);
                        context.Graphics.DrawLine(lightPen, displayRect.Right - 1, displayRect.Bottom - 1, displayRect.Right - 4, displayRect.Bottom - 5);
                        context.Graphics.DrawLine(darkPen, displayRect.Right - 5, displayRect.Bottom - 2, displayRect.Right - 2, displayRect.Bottom - 2);
                        context.Graphics.DrawLine(darkPen, displayRect.Right - 4, displayRect.Bottom - 3, displayRect.Right - 3, displayRect.Bottom - 3);
                        context.Graphics.DrawLine(darkPen, displayRect.Right - 2, displayRect.Bottom - 2, displayRect.Right - 2, displayRect.Bottom - 5);
                        context.Graphics.DrawLine(darkPen, displayRect.Right - 3, displayRect.Bottom - 3, displayRect.Right - 3, displayRect.Bottom - 4);
                        context.Graphics.DrawLine(darkPen, displayRect.Right - 5, displayRect.Bottom - 5, displayRect.Right - 3, displayRect.Bottom - 3);
                    }
                    break;
                case PaletteRibbonShape.Office2010:
                    LinearGradientBrush dialogBrush = new LinearGradientBrush(new RectangleF(displayRect.X - 1, displayRect.Y - 1, displayRect.Width + 2, displayRect.Height + 2),
                                                                              paletteGeneral.GetRibbonGroupDialogLight(state),
                                                                              paletteGeneral.GetRibbonGroupDialogDark(state),
                                                                              45f);

                    using (Pen dialogPen = new Pen(dialogBrush))
                    {
                        context.Graphics.DrawLine(dialogPen, displayRect.Left, displayRect.Top + 5, displayRect.Left, displayRect.Top);
                        context.Graphics.DrawLine(dialogPen, displayRect.Left, displayRect.Top, displayRect.Left + 5, displayRect.Top);
                        context.Graphics.DrawLine(dialogPen, displayRect.Right - 5, displayRect.Bottom - 2, displayRect.Right - 2, displayRect.Bottom - 2);
                        context.Graphics.DrawLine(dialogPen, displayRect.Right - 4, displayRect.Bottom - 3, displayRect.Right - 3, displayRect.Bottom - 3);
                        context.Graphics.DrawLine(dialogPen, displayRect.Right - 2, displayRect.Bottom - 2, displayRect.Right - 2, displayRect.Bottom - 5);
                        context.Graphics.DrawLine(dialogPen, displayRect.Right - 3, displayRect.Bottom - 3, displayRect.Right - 3, displayRect.Bottom - 4);
                        context.Graphics.DrawLine(dialogPen, displayRect.Right - 5, displayRect.Bottom - 5, displayRect.Right - 3, displayRect.Bottom - 3);
                    }
                    break;
            }
        }
Ejemplo n.º 39
0
        /// <summary>
        /// Perform drawing of a ribbon overflow image.
        /// </summary>
        /// <param name="shape">Ribbon shape.</param>
        /// <param name="context">Render context.</param>
        /// <param name="displayRect">Display area available for drawing.</param>
        /// <param name="paletteGeneral">General ribbon palette details.</param>
        /// <param name="state">State associated with rendering.</param>
        public override void DrawRibbonOverflow(PaletteRibbonShape shape,
                                                RenderContext context,
                                                Rectangle displayRect,
                                                IPaletteRibbonGeneral paletteGeneral,
                                                PaletteState state)
        {
            Debug.Assert(context != null);
            Debug.Assert(paletteGeneral != null);

            // Validate parameter references
            if (context == null) throw new ArgumentNullException("context");
            if (paletteGeneral == null) throw new ArgumentNullException("paletteGeneral");

            Color c1 = paletteGeneral.GetRibbonQATButtonDark(state);
            Color c2 = paletteGeneral.GetRibbonQATButtonLight(state);

            // Office 2010 uses the same color for both parts
            if (shape == PaletteRibbonShape.Office2010)
                c2 = c1;

            // If disabled then convert to black and white
            if (state == PaletteState.Disabled)
            {
                c1 = CommonHelper.ColorToBlackAndWhite(c1);
                c2 = CommonHelper.ColorToBlackAndWhite(c2);
            }

            using (Pen darkPen = new Pen(c1),
                       lightPen = new Pen(c2))
            {
                context.Graphics.DrawLine(darkPen, displayRect.Left, displayRect.Top + 1, displayRect.Left, displayRect.Top + 3);
                context.Graphics.DrawLine(darkPen, displayRect.Left + 1, displayRect.Top + 2, displayRect.Left, displayRect.Top + 3);
                context.Graphics.DrawLine(lightPen, displayRect.Left, displayRect.Top, displayRect.Left + 2, displayRect.Top + 2);
                context.Graphics.DrawLine(lightPen, displayRect.Left + 1, displayRect.Top + 3, displayRect.Left, displayRect.Top + 4);

                context.Graphics.DrawLine(darkPen, displayRect.Left + 4, displayRect.Top + 1, displayRect.Left + 4, displayRect.Top + 3);
                context.Graphics.DrawLine(darkPen, displayRect.Left + 5, displayRect.Top + 2, displayRect.Left + 4, displayRect.Top + 3);
                context.Graphics.DrawLine(lightPen, displayRect.Left + 4, displayRect.Top, displayRect.Left + 6, displayRect.Top + 2);
                context.Graphics.DrawLine(lightPen, displayRect.Left + 5, displayRect.Top + 3, displayRect.Left + 4, displayRect.Top + 4);
            }
        }
        /// <summary>
        /// Initialize a new instance of the ViewDrawNavRibbonTab class.
        /// </summary>
        /// <param name="navigator">Owning navigator instance.</param>
        /// <param name="page">Page this ribbon tab represents.</param>
        public ViewDrawNavRibbonTab(KryptonNavigator navigator,
                                    KryptonPage page)
        {
            Debug.Assert(navigator != null);
            Debug.Assert(page != null);

            Navigator  = navigator;
            Page       = page;
            _lastClick = DateTime.Now.AddDays(-1);

            // Associate the page component with this view element
            Component = page;

            // Create a controller for managing button behavior
            _buttonController = new PageButtonController(this, OnNeedPaint)
            {
                ClickOnDown = true
            };
            _buttonController.Click      += OnClick;
            _buttonController.RightClick += OnRightClick;

            // Allow the page to be dragged and hook into drag events
            _buttonController.AllowDragging        = true;
            _buttonController.DragStart           += OnDragStart;
            _buttonController.DragMove            += OnDragMove;
            _buttonController.DragEnd             += OnDragEnd;
            _buttonController.DragQuit            += OnDragQuit;
            _buttonController.ButtonDragRectangle += OnButtonDragRectangle;
            _buttonController.ButtonDragOffset    += OnButtonDragOffset;

            // A tab is selected on being pressed and not on the mouse up
            _buttonController.ClickOnDown = true;

            // We need to be notified of got/lost focus and keyboard events
            SourceController = _buttonController;
            KeyController    = _buttonController;

            // Create a decorator to interface with the tooltip manager
            ToolTipController toolTipController = new ToolTipController(Navigator.ToolTipManager, this, _buttonController);
            ToolTipController hoverController   = new ToolTipController(Navigator.HoverManager, this, toolTipController);

            // Assign controller for handing mouse input
            MouseController = hoverController;

            // Create overrides for handling a focus state
            _paletteGeneral        = Navigator.StateCommon.RibbonGeneral;
            _overrideStateNormal   = new PaletteRibbonTabContentInheritOverride(Page.OverrideFocus.RibbonTab.TabDraw, Page.OverrideFocus.RibbonTab.TabDraw, Page.OverrideFocus.RibbonTab.Content, Page.StateNormal.RibbonTab.TabDraw, Page.StateNormal.RibbonTab.TabDraw, Page.StateNormal.RibbonTab.Content, PaletteState.FocusOverride);
            _overrideStateTracking = new PaletteRibbonTabContentInheritOverride(Page.OverrideFocus.RibbonTab.TabDraw, Page.OverrideFocus.RibbonTab.TabDraw, Page.OverrideFocus.RibbonTab.Content, Page.StateTracking.RibbonTab.TabDraw, Page.StateTracking.RibbonTab.TabDraw, Page.StateTracking.RibbonTab.Content, PaletteState.FocusOverride);
            _overrideStatePressed  = new PaletteRibbonTabContentInheritOverride(Page.OverrideFocus.RibbonTab.TabDraw, Page.OverrideFocus.RibbonTab.TabDraw, Page.OverrideFocus.RibbonTab.Content, Page.StatePressed.RibbonTab.TabDraw, Page.StatePressed.RibbonTab.TabDraw, Page.StatePressed.RibbonTab.Content, PaletteState.FocusOverride);
            _overrideStateSelected = new PaletteRibbonTabContentInheritOverride(Page.OverrideFocus.RibbonTab.TabDraw, Page.OverrideFocus.RibbonTab.TabDraw, Page.OverrideFocus.RibbonTab.Content, Page.StateSelected.RibbonTab.TabDraw, Page.StateSelected.RibbonTab.TabDraw, Page.StateSelected.RibbonTab.Content, PaletteState.FocusOverride);

            // Use a class to convert from ribbon tab to content interface
            _contentProvider = new RibbonTabToContent(_paletteGeneral, _overrideStateNormal, _overrideStateNormal);

            // Create the content view element and use the content provider as a way to
            // convert from the ribbon palette entries to the content palette entries
            _viewContent = new ViewDrawContent(_contentProvider, this, VisualOrientation.Top);

            // Add content to the view
            _layoutDocker = new ViewLayoutDocker
            {
                { _viewContent, ViewDockStyle.Fill }
            };
            Add(_layoutDocker);

            // Create button specification collection manager
            ButtonSpecManager = new ButtonSpecNavManagerLayoutBar(Navigator, Navigator.InternalRedirector, Page.ButtonSpecs, null,
                                                                  new ViewLayoutDocker[] { _layoutDocker },
                                                                  new IPaletteMetric[] { Navigator.StateCommon },
                                                                  new PaletteMetricInt[] { PaletteMetricInt.PageButtonInset },
                                                                  new PaletteMetricInt[] { PaletteMetricInt.PageButtonInset },
                                                                  new PaletteMetricPadding[] { PaletteMetricPadding.PageButtonPadding },
                                                                  Navigator.CreateToolStripRenderer,
                                                                  OnNeedPaint)
            {
                // Hook up the tooltip manager so that tooltips can be generated
                ToolTipManager = Navigator.ToolTipManager,
                RemapTarget    = ButtonSpecNavRemap.ButtonSpecRemapTarget.ButtonStandalone
            };

            // Ensure current button specs are created
            ButtonSpecManager.RecreateButtons();

            // Create the state specific memento array
            _mementos = new IDisposable[Enum.GetValues(typeof(PaletteState)).Length];

            // Cache the last shape encountered
            _lastRibbonShape = PaletteRibbonShape.Office2010;
        }
Ejemplo n.º 41
0
        /// <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);
        }
Ejemplo n.º 42
0
 /// <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 storage for drawing objects.</param>
 public override IDisposable DrawRibbonTabContextTitle(PaletteRibbonShape shape,
                                                       RenderContext context,
                                                       Rectangle rect,
                                                       IPaletteRibbonGeneral paletteGeneral,
                                                       IPaletteRibbonBack paletteBack,
                                                       IDisposable memento)
 {
     return DrawRibbonTabContext(context, rect, paletteGeneral, paletteBack, memento);
 }
Ejemplo n.º 43
0
        /// <summary>
        /// Draw the application tab.
        /// </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="baseColor1">Base color1 used for drawing the ribbon tab.</param>
        /// <param name="baseColor2">Base color2 used for drawing the ribbon tab.</param>
        /// <param name="memento">Cached values to use when drawing.</param>
        public override IDisposable DrawRibbonApplicationTab(PaletteRibbonShape shape,
                                                             RenderContext context,
                                                             Rectangle rect,
                                                             PaletteState state,
                                                             Color baseColor1,
                                                             Color baseColor2,
                                                             IDisposable memento)
        {
            if ((rect.Width > 0) && (rect.Height > 0))
            {
                bool generate = true;
                MementoRibbonAppTab2013 cache;

                // Access a cache instance and decide if cache resources need generating
                if ((memento == null) || !(memento is MementoRibbonAppTab2013))
                {
                    if (memento != null)
                    {
                        memento.Dispose();
                    }

                    cache   = new MementoRibbonAppTab2013(rect, baseColor1);
                    memento = cache;
                }
                else
                {
                    cache    = (MementoRibbonAppTab2013)memento;
                    generate = !cache.UseCachedValues(rect, baseColor1);
                }

                // Do we need to generate the contents of the cache?
                if (generate)
                {
                    // Dispose of existing values
                    cache.Dispose();

                    // Create common paths to all the app tab states
                    cache.GeneratePaths(rect, state);
                    //cache.borderPen = new Pen(baseColor1);

                    // Create state specific colors/brushes/pens
                    switch (state)
                    {
                    case PaletteState.Normal:
                        //cache.borderBrush = new SolidBrush(baseColor1);
                        cache.insideFillBrush = new SolidBrush(baseColor1);

                        //cache.insideFillBrush.SetSigmaBellShape(0.33f);
                        //cache.highlightBrush.CenterColor = Color.FromArgb(64, Color.White);
                        break;

                    case PaletteState.Tracking:
                        cache.insideFillBrush = new SolidBrush(baseColor2);
                        //cache.borderBrush = new SolidBrush(baseColor2);
                        //cache.insideFillBrush = new LinearGradientBrush(new RectangleF(rect.X, rect.Y + 1, rect.Width, rect.Height),
                        //                                                CommonHelper.MergeColors(baseColor1, 0.3f, baseColor2, 0.7f),
                        //                                                CommonHelper.MergeColors(baseColor1, 0.6f, baseColor2, 0.4f),
                        //                                                90f);

                        //cache.insideFillBrush.SetSigmaBellShape(0.33f);
                        //cache.highlightBrush.CenterColor = Color.FromArgb(100, Color.White);
                        break;

                    case PaletteState.Tracking | PaletteState.FocusOverride:
                        cache.insideFillBrush = new SolidBrush(ControlPaint.LightLight(baseColor2));
                        //cache.borderBrush = new SolidBrush(ControlPaint.LightLight(baseColor2));
                        //cache.insideFillBrush = new LinearGradientBrush(new RectangleF(rect.X, rect.Y + 1, rect.Width, rect.Height),
                        //                                                CommonHelper.MergeColors(baseColor1, 0.3f, baseColor2, 0.7f),
                        //                                                CommonHelper.MergeColors(baseColor1, 0.6f, baseColor2, 0.4f),
                        //                                                90f);

                        //cache.insideFillBrush.SetSigmaBellShape(0.33f);
                        //cache.highlightBrush.CenterColor = ControlPaint.LightLight(baseColor2);
                        break;

                    case PaletteState.Pressed:
                        cache.insideFillBrush = new SolidBrush(baseColor2);

                        //cache.borderBrush = new SolidBrush(CommonHelper.MergeColors(baseColor1, 0.5f, baseColor2, 0.5f));
                        //cache.insideFillBrush = new LinearGradientBrush(new RectangleF(rect.X, rect.Y + 1, rect.Width, rect.Height),
                        //                                                CommonHelper.MergeColors(baseColor1, 0.3f, baseColor2, 0.7f),
                        //                                                CommonHelper.MergeColors(baseColor1, 0.75f, baseColor2, 0.25f),
                        //                                                90f);

                        //cache.insideFillBrush.SetSigmaBellShape(0f);
                        //cache.highlightBrush.CenterColor = Color.FromArgb(90, Color.White);
                        break;
                    }
                }

                // Fill the entire tab area and then add a border around the edge
                //context.Graphics.FillPath(cache.borderBrush, cache.borderFillPath);

                // Draw the outside border
                //using (AntiAlias aa = new AntiAlias(context.Graphics))
                //    context.Graphics.DrawPath(cache.borderPen, cache.borderPath);

                // Fill inside area
                //context.Graphics.FillPath(cache.insideFillBrush, cache.insideFillPath);
                context.Graphics.FillRectangle(cache.insideFillBrush, cache.rect);

                // Draw highlight over bottom half
                //using (Clipping clip = new Clipping(context.Graphics, cache.insideFillPath))
                //    context.Graphics.FillPath(cache.highlightBrush, cache.highlightPath);
            }

            return(memento);
        }
Ejemplo n.º 44
0
        private void CreateNormalView()
        {
            // Create a layout for the main area
            _layoutNormalMain = new ViewLayoutRibbonTitle();

            if (_ribbon.InDesignMode)
            {
                // At design time we need to know when the user right clicks the group
                ContextClickController controller = new ContextClickController();
                controller.ContextClick += new MouseEventHandler(OnContextClick);
                _layoutNormalMain.MouseController = controller;
            }

            // Create layout elements
            _layoutNormalTitle = new ViewLayoutDocker();
            _layoutNormalContent = new ViewLayoutRibbonGroupContent(_ribbon, _ribbonGroup, _needPaint);
            _layoutNormalSepTop = new ViewLayoutRibbonSeparator(NORMAL_BORDER_TOPLEFT2007, true);
            _layoutNormalSepLeft = new ViewLayoutRibbonSeparator(NORMAL_BORDER_TOPLEFT2007, true);
            _layoutNormalSepRight = new ViewLayoutRibbonSeparator(NORMAL_BORDER_RIGHT2007, true);

            // Add layout elements to correct areas of the normal group
            _layoutNormalMain.Add(_layoutNormalTitle, ViewDockStyle.Bottom);
            _layoutNormalMain.Add(_layoutNormalSepTop, ViewDockStyle.Top);
            _layoutNormalMain.Add(_layoutNormalSepLeft, ViewDockStyle.Left);
            _layoutNormalMain.Add(_layoutNormalSepRight, ViewDockStyle.Right);
            _layoutNormalMain.Add(_layoutNormalContent, ViewDockStyle.Fill);

            // Create and add the title string that fills remainder title area
            _viewNormalTitle = new ViewDrawRibbonGroupTitle(_ribbon, _ribbonGroup);
            _layoutNormalTitle.Add(_viewNormalTitle, ViewDockStyle.Fill);

            // Add the dialog box launcher button to the right side of title area
            _viewNormalDialog = new ViewLayoutRibbonGroupButton(_ribbon, _ribbonGroup, _needPaint);
            _layoutNormalContent.DialogView = _viewNormalDialog;
            _layoutNormalTitle.Add(_viewNormalDialog, ViewDockStyle.Right);

            // Use this class to return the context color for any null values
            _paletteContextBack = new PaletteRibbonContextBack(_ribbon);

            // All values are equal to a default of Office 2007 shape
            _lastRibbonShape = PaletteRibbonShape.Office2007;
            _totalBorders = TOTAL_LEFT_RIGHT_BORDERS_2007;
        }
Ejemplo n.º 45
0
 /// <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);
Ejemplo n.º 46
0
 private void UpdateShapeValues()
 {
     if (_ribbon != null)
     {
         if (_lastRibbonShape != _ribbon.RibbonShape)
         {
             switch (_ribbon.RibbonShape)
             {
                 default:
                 case PaletteRibbonShape.Office2007:
                     _totalBorders = TOTAL_LEFT_RIGHT_BORDERS_2007;
                     _layoutNormalMain.VertOffset = VERT_OFFSET_2007;
                     _layoutNormalSepTop.SeparatorSize = new Size(NORMAL_BORDER_TOPLEFT2007, NORMAL_BORDER_TOPLEFT2007);
                     _layoutNormalSepLeft.SeparatorSize = new Size(NORMAL_BORDER_TOPLEFT2007, NORMAL_BORDER_TOPLEFT2007);
                     _layoutNormalSepRight.SeparatorSize = new Size(NORMAL_BORDER_RIGHT2007, NORMAL_BORDER_RIGHT2007);
                     _layoutCollapsedImagePadding.PreferredPadding = COLLAPSED_IMAGE_PADDING_2007;
                     _lastRibbonShape = PaletteRibbonShape.Office2007;
                     break;
                 case PaletteRibbonShape.Office2010:
                     _totalBorders = TOTAL_LEFT_RIGHT_BORDERS_2010;
                     _layoutNormalMain.VertOffset = VERT_OFFSET_2010;
                     _layoutNormalSepTop.SeparatorSize = new Size(NORMAL_BORDER_TOP2010, NORMAL_BORDER_TOP2010);
                     _layoutNormalSepLeft.SeparatorSize = new Size(NORMAL_BORDER_LEFT2010, NORMAL_BORDER_LEFT2010);
                     _layoutNormalSepRight.SeparatorSize = new Size(NORMAL_BORDER_RIGHT2010, NORMAL_BORDER_RIGHT2010);
                     _layoutCollapsedImagePadding.PreferredPadding = COLLAPSED_IMAGE_PADDING_2010;
                     _lastRibbonShape = PaletteRibbonShape.Office2010;
                     break;
             }
         }
     }
 }
Ejemplo n.º 47
0
 /// <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);
Ejemplo n.º 48
0
        /// <summary>
        /// Perform drawing of a ribbon cluster edge.
        /// </summary>
        /// <param name="shape">Ribbon shape.</param>
        /// <param name="context">Render context.</param>
        /// <param name="displayRect">Display area available for drawing.</param>
        /// <param name="paletteBack">Palette used for recovering drawing details.</param>
        /// <param name="state">State associated with rendering.</param>
        public override void DrawRibbonClusterEdge(PaletteRibbonShape shape,
                                                   RenderContext context,
                                                   Rectangle displayRect,
                                                   IPaletteBack paletteBack,
                                                   PaletteState state)
        {
            Debug.Assert(context != null);
            Debug.Assert(paletteBack != null);

            // Draw inside of the border edge in a lighter version of the border
            using (SolidBrush drawBrush = new SolidBrush(paletteBack.GetBackColor1(state)))
                context.Graphics.FillRectangle(drawBrush, displayRect);
        }
Ejemplo n.º 49
0
 /// <summary>
 /// Perform drawing of a ribbon dialog box launcher glyph.
 /// </summary>
 /// <param name="shape">Ribbon shape.</param>
 /// <param name="context">Render context.</param>
 /// <param name="displayRect">Display area available for drawing.</param>
 /// <param name="paletteGeneral">General ribbon palette details.</param>
 /// <param name="state">State associated with rendering.</param>
 public abstract void DrawRibbonDialogBoxLauncher(PaletteRibbonShape shape,
                                                  RenderContext context,
                                                  Rectangle displayRect,
                                                  IPaletteRibbonGeneral paletteGeneral,
                                                  PaletteState state);
Ejemplo n.º 50
0
        /// <summary>
        /// Perform drawing of a ribbon drop arrow glyph.
        /// </summary>
        /// <param name="shape">Ribbon shape.</param>
        /// <param name="context">Render context.</param>
        /// <param name="displayRect">Display area available for drawing.</param>
        /// <param name="paletteGeneral">General ribbon palette details.</param>
        /// <param name="state">State associated with rendering.</param>
        public override void DrawRibbonDropArrow(PaletteRibbonShape shape,
                                                 RenderContext context,
                                                 Rectangle displayRect,
                                                 IPaletteRibbonGeneral paletteGeneral,
                                                 PaletteState state)
        {
            Debug.Assert(context != null);
            Debug.Assert(paletteGeneral != null);

            // Validate parameter references
            if (context == null) throw new ArgumentNullException("context");
            if (paletteGeneral == null) throw new ArgumentNullException("paletteGeneral");

            Color darkColor = (state == PaletteState.Disabled ? paletteGeneral.GetRibbonDisabledDark(state) :
                                                                paletteGeneral.GetRibbonDropArrowDark(state));

            Color lightColor = (state == PaletteState.Disabled ? paletteGeneral.GetRibbonDisabledLight(state) :
                                                                 paletteGeneral.GetRibbonDropArrowLight(state));

            switch (shape)
            {
                default:
                case PaletteRibbonShape.Office2007:
                    using (Pen darkPen = new Pen(darkColor),
                               lightPen = new Pen(lightColor))
                    {
                        context.Graphics.DrawLine(darkPen, displayRect.Left, displayRect.Top, displayRect.Left + 4, displayRect.Top);
                        context.Graphics.DrawLine(darkPen, displayRect.Left + 1, displayRect.Top + 1, displayRect.Left + 3, displayRect.Top + 1);
                        context.Graphics.DrawLine(darkPen, displayRect.Left + 2, displayRect.Top + 1, displayRect.Left + 2, displayRect.Top + 2);
                        context.Graphics.DrawLine(lightPen, displayRect.Left, displayRect.Top + 1, displayRect.Left + 2, displayRect.Top + 3);
                        context.Graphics.DrawLine(lightPen, displayRect.Left + 2, displayRect.Top + 3, displayRect.Left + 4, displayRect.Top + 1);
                    }
                    break;
                case PaletteRibbonShape.Office2010:
                    using (LinearGradientBrush fillBrush = new LinearGradientBrush(new RectangleF(displayRect.X - 1, displayRect.Y - 1, displayRect.Width + 2, displayRect.Height + 2),
                                                                                   lightColor, darkColor, 45f))
                    {
                        context.Graphics.FillPolygon(fillBrush, new Point[]{ new Point(displayRect.Left - 1, displayRect.Top - 1),
                                                                             new Point(displayRect.Left + 2, displayRect.Top + 3),
                                                                             new Point(displayRect.Left + 5, displayRect.Top) });
                    }
                    break;
            }
        }
Ejemplo n.º 51
0
 /// <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>
 /// Resets the RibbonShape property to its default value.
 /// </summary>
 public void ResetRibbonShape()
 {
     RibbonShape = PaletteRibbonShape.Inherit;
 }