Esempio n. 1
0
        /// <summary>
        /// Raises the paint event and draws the control
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public override void OnPaint(object sender, RibbonElementPaintEventArgs e)
        {
            if (Owner != null)
            {
                StringFormat f = StringFormatFactory.CenterNoWrap(StringTrimming.None);
                if (Site != null && Site.DesignMode)
                {
                    Owner.Renderer.OnRenderRibbonItemText(new RibbonTextEventArgs(Owner, e.Graphics, Bounds, this, Bounds, Site.Name, f));
                }
                else
                {
                    Owner.Renderer.OnRenderRibbonItemText(new RibbonTextEventArgs(Owner, e.Graphics, Bounds, this, Bounds, this.Text, f));
                    if (ctl != null)
                    {
                        if (ctl.Parent != Canvas)
                        {
                            Canvas.Controls.Add(ctl);
                        }

                        //time to show our control
                        ctl.Location = new System.Drawing.Point(Bounds.Left, (this.SizeMode == RibbonElementSizeMode.DropDown) ? Bounds.Top:  Bounds.Top);
                        ctl.Visible  = true;
                        ctl.BringToFront();
                    }
                }
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Raises the paint event and draws the
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public override void OnPaint(object sender, RibbonElementPaintEventArgs e)
 {
     if (Owner != null)
     {
         base.Owner.Renderer.OnRenderRibbonItem(new RibbonItemRenderEventArgs(base.Owner, e.Graphics, base.Bounds, this));
         StringFormat f = StringFormatFactory.CenterNoWrap(StringTrimming.None);
         f.Alignment = (StringAlignment)TextAlignment;
         Rectangle clipBounds = Rectangle.FromLTRB(Bounds.Left + 3, Bounds.Top + Owner.ItemMargin.Top, Bounds.Right - 3, Bounds.Bottom - Owner.ItemMargin.Bottom);
         base.Owner.Renderer.OnRenderRibbonItemText(new RibbonTextEventArgs(Owner, e.Graphics, Bounds, this, clipBounds, this.Text, f));
     }
 }
Esempio n. 3
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();
            }
        }