public override void OnRenderRibbonItemText(RibbonItemBoundsEventArgs e)
        {
            if (e.Item is RibbonButton)
            {
                #region Button
                var b = e.Item as RibbonButton;
                var sf = new StringFormat
                             {
                                 LineAlignment = StringAlignment.Center,
                                 Alignment = StringAlignment.Near
                             };

                if (e.Item.SizeMode == RibbonElementSizeMode.Large)
                {
                    sf.Alignment = StringAlignment.Center;

                    if (!string.IsNullOrEmpty(e.Item.Text) && !e.Item.Text.Contains(" "))
                    {
                        sf.LineAlignment = StringAlignment.Near;
                    }
                }

                using (var brush = new SolidBrush(GetTextColor(e.Item.Enabled)))
                {
                    e.Graphics.DrawString(e.Item.Text, e.Ribbon.Font, brush, e.Bounds, sf);
                }

                if (b.Style == RibbonButtonStyle.DropDown && b.SizeMode == RibbonElementSizeMode.Large)
                {
                    DrawButtonDropDownArrow(e.Graphics, b, e.Bounds);
                }
                #endregion
            }
            else if (e.Item is RibbonSeparator)
            {
                #region Separator
                DrawSeparatorText(e, e.Item as RibbonSeparator);
                #endregion
            }
            else if (e.Item is RibbonTextBox)
            {
                #region Textbox
                DrawTextBoxText(e.Graphics, e);
                #endregion
            }
            else
            {
                #region Generic
                e.Graphics.DrawString(e.Item.Text, e.Ribbon.Font, SystemBrushes.ControlText, e.Bounds);
                #endregion
            }
        }
        public override void OnRenderRibbonItemImage(RibbonItemBoundsEventArgs e)
        {
            var img = e.Item.Image;

            if (e.Item is RibbonButton)
            {
                if (!(e.Item.SizeMode == RibbonElementSizeMode.Large || e.Item.SizeMode == RibbonElementSizeMode.Overflow))
                {
                    img = (e.Item as RibbonButton).SmallImage;
                }
            }

            if (img != null)
            {

                if (!e.Item.Enabled)
                    img = CreateDisabledImage(img);

                e.Graphics.DrawImage(img, e.Bounds);
            }
        }
 public void DrawSeparatorText(RibbonItemBoundsEventArgs e, RibbonSeparator sep)
 {
     using (Brush b = new SolidBrush(GetTextColor(sep.Enabled)))
     {
         e.Graphics.DrawString(sep.Text, new Font(sep.Owner.Font, FontStyle.Bold), b, e.Bounds);
     }
 }
        /// <summary>
        /// Draws the text of a RibbonTextbox
        /// </summary>
        /// <param name="g"></param>
        /// <param name="e"></param>
        public void DrawTextBoxText(Graphics g, RibbonItemBoundsEventArgs e)
        {
            var t = e.Item as RibbonTextBox;

            var f = new StringFormat()
                        {
                            Alignment = StringAlignment.Near,
                            LineAlignment = StringAlignment.Center,
                            Trimming = StringTrimming.None,
                        };
            f.FormatFlags |= StringFormatFlags.NoWrap;

            e.Graphics.DrawString(t.TextBoxText, e.Ribbon.Font,
                                  t.Enabled ? SystemBrushes.ControlText : SystemBrushes.GrayText, t.TextBoxTextBounds, f);

            if (t.LabelVisible)
            {
                using (Brush b = new SolidBrush(GetTextColor(e.Item.Enabled)))
                {
                    e.Graphics.DrawString(t.Text, e.Ribbon.Font, b, t.LabelBounds, f);
                }
            }
        }
 /// <summary>
 /// Renders the text of the item specified on the event
 /// </summary>
 /// <param name="e">Event data and paint tools</param>
 public virtual void OnRenderRibbonItemText(RibbonItemBoundsEventArgs e)
 {
 }