Example #1
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>
        /// <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);
            }
        }
Example #2
0
        /// <summary>
        /// Gets the light disabled color used for ribbon glyphs.
        /// </summary>
        /// <param name="state">Palette value should be applicable to this state.</param>
        /// <returns>Color value.</returns>
        public override Color GetRibbonDisabledLight(PaletteState state)
        {
            IPaletteRibbonGeneral inherit = GetInherit(state);

            return(inherit?.GetRibbonDisabledLight(state) ?? Target.GetRibbonDisabledLight(state));
        }
Example #3
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;
            }
        }
        /// <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.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);
            }
        }