Example #1
0
        public override void OnPaint(object sender, RibbonElementPaintEventArgs e)
        {
            if (Owner == null)
            {
                return;
            }
            var f      = StringFormatFactory.CenterNoWrap(StringTrimming.None);
            var design = ((Site?.DesignMode ?? false) ||
                          IsOpenInVisualStudioDesigner());
            var args = new RibbonTextEventArgs(Owner, e.Graphics, Bounds, this, Bounds, design ? Site.Name : Text, f);

            Owner.Renderer.OnRenderRibbonItemText(args);
            if (design)
            {
                return;
            }
            if (_ctl == null)
            {
                return;
            }
            if ((_ctl.Parent != Canvas) &&
                (Canvas != null))
            {
                _ctlParent   = _ctl.Parent;
                _ctlLocation = _ctl.Location;
                _ctlSize     = _ctl.Size;
                Canvas.Controls.Add(_ctl);
                _ctl.Location = new Point(Bounds.Left, Bounds.Top);
                _ctl.Visible  = true;
                _ctl.BringToFront();
            }
            else
            {
                if ((_ctl.Location.X != Bounds.Left) ||
                    (_ctl.Location.Y != Bounds.Top))
                {
                    _ctl.Location = new Point(Bounds.Left, Bounds.Top);
                }
                if (_ctl.Visible)
                {
                    return;
                }
                _ctl.Visible = true;
                _ctl.BringToFront();
            }
        }
Example #2
0
 /// <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(RibbonTextEventArgs e)
 {
 }
        public override void OnRenderRibbonItemText(RibbonTextEventArgs e)
        {
            Color foreColor = e.Color;
            StringFormat sf = e.Format;
            Font f = e.Ribbon.Font;
            bool embedded = false;

            if (e.Item is RibbonButton)
            {
                #region Button
                RibbonButton b = e.Item as RibbonButton;

                if (b is RibbonCaptionButton)
                {
                    if (WinApi.IsWindows) f = new Font(RibbonCaptionButton.WindowsIconsFont, f.Size);
                    embedded = true;
                    foreColor = ColorTable.Arrow;
                }

                if (b.Style == RibbonButtonStyle.DropDown && b.SizeMode == RibbonElementSizeMode.Large)
                {
                    DrawButtonDropDownArrow(e.Graphics, b, e.Bounds);
                }

                #endregion
            }
            else if (e.Item is RibbonSeparator)
            {
                if (e.Ribbon.OrbStyle == RibbonOrbStyle.Office_2007 || e.Ribbon.OrbStyle == RibbonOrbStyle.Office_2010)
                    foreColor = GetTextColor(e.Item.Enabled, ColorTable.Text);
                else if (e.Ribbon.OrbStyle == RibbonOrbStyle.Office_2013)
                    foreColor = GetTextColor(e.Item.Enabled, ColorTable.RibbonItemText_2013);
            }

            embedded = embedded || !e.Item.Enabled;

            if (embedded)
            {
                Rectangle cbr = e.Bounds; cbr.Y++;
                using (SolidBrush b = new SolidBrush(ColorTable.ArrowLight))
                {
                    e.Graphics.DrawString(e.Text, new Font(f, e.Style), b, cbr, sf);
                }
            }

            if (foreColor.Equals(Color.Empty))
            {
                if (e.Ribbon.OrbStyle == RibbonOrbStyle.Office_2007 || e.Ribbon.OrbStyle == RibbonOrbStyle.Office_2010)
                    foreColor = GetTextColor(e.Item.Enabled, ColorTable.Text);
                else if (e.Ribbon.OrbStyle == RibbonOrbStyle.Office_2013)
                    foreColor = GetTextColor(e.Item.Enabled, ColorTable.RibbonItemText_2013);
            }

            using (SolidBrush b = new SolidBrush(foreColor))
            {

                e.Graphics.DrawString(e.Text, new Font(f, e.Style), b, e.Bounds, sf);
            }
        }
 /// <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(RibbonTextEventArgs e)
 {
 }