Esempio n. 1
0
        /// <summary>
        /// Renders text of the button
        /// </summary>
        /// <param name="e"></param>
        protected virtual void OnPaintText(RibbonElementPaintEventArgs e)
        {
            if (SizeMode != RibbonElementSizeMode.Compact)
            {
                StringFormat sf = StringFormatFactory.NearCenter();

                if (this.Owner.AltPressed || this.Owner.OrbDropDown.MenuItems.Contains(this))
                {
                    sf.HotkeyPrefix = Drawing.Text.HotkeyPrefix.Show;
                }
                else
                {
                    sf.HotkeyPrefix = Drawing.Text.HotkeyPrefix.Hide;
                }

                if (SizeMode == RibbonElementSizeMode.Large)
                {
                    sf.Alignment     = StringAlignment.Center;
                    sf.LineAlignment = StringAlignment.Near;
                }

                if (Style == RibbonButtonStyle.DropDownListItem)
                {
                    sf.LineAlignment = StringAlignment.Near;
                    Owner.Renderer.OnRenderRibbonItemText(
                        new RibbonTextEventArgs(Owner, e.Graphics, e.Clip, this, Bounds, Text, sf));
                }
                else
                {
                    var newText = Text;

                    if (!String.IsNullOrEmpty(this.AltKey) && this.Text.Contains(AltKey))
                    {
                        var regex = new Regex(Regex.Escape(this.AltKey), RegexOptions.IgnoreCase);
                        newText = regex.Replace(this.Text.Replace("&", ""), "&" + this.AltKey, 1).Replace("&&", "&");
                    }

                    Rectangle bounds = new Rectangle(TextBounds.X, TextBounds.Y + _padding.Top, TextBounds.Width, TextBounds.Height);

                    Owner.Renderer.OnRenderRibbonItemText(
                        new RibbonTextEventArgs(Owner, e.Graphics, e.Clip, this, bounds, newText, Color.Empty, _bold ? FontStyle.Bold : FontStyle.Regular, sf));
                }
            }
        }
        protected override void OnPaintText(RibbonElementPaintEventArgs e)
        {
            if (e.Mode == RibbonElementSizeMode.DropDown)
            {
                StringFormat sf = StringFormatFactory.NearCenter();

                Owner.Renderer.OnRenderRibbonItemText(new RibbonTextEventArgs(
                                                          Owner, e.Graphics, e.Clip, this, TextBounds, Text, Color.Empty, FontStyle.Bold, sf));

                sf.Alignment = StringAlignment.Near;

                Owner.Renderer.OnRenderRibbonItemText(new RibbonTextEventArgs(
                                                          Owner, e.Graphics, e.Clip, this, DescriptionBounds, Description, sf));
            }
            else
            {
                base.OnPaintText(e);
            }
        }