Esempio n. 1
0
        /// <summary>
        /// Raises the Paint event.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public override void OnPaint(object sender, RibbonElementPaintEventArgs e)
        {
            if (Owner == null)
            {
                return;
            }
            RibbonElementSizeMode theSize = GetNearestSize(e.Mode);

            Owner.Renderer.OnRenderRibbonItem(new RibbonItemRenderEventArgs(Owner, e.Graphics, e.Clip, this));

            Rectangle img = Rectangle.Empty;

            #region Image
            if (theSize == RibbonElementSizeMode.Large)
            {
                if (Image != null)
                {
                    img = new Rectangle(
                        Bounds.Left + ((Bounds.Width - Image.Width) / 2),
                        Bounds.Top + Owner.ItemMargin.Top,
                        Image.Width,
                        Image.Height);

                    Owner.Renderer.OnRenderRibbonItemImage(
                        new RibbonItemBoundsEventArgs(Owner, e.Graphics, e.Clip, this, img));
                }
            }
            else
            {
                if (SmallImage != null)
                {
                    img = new Rectangle(
                        Bounds.Left + Owner.ItemMargin.Left,
                        Bounds.Top + ((Bounds.Height - SmallImage.Height) / 2),
                        SmallImage.Width,
                        SmallImage.Height);

                    Owner.Renderer.OnRenderRibbonItemImage(
                        new RibbonItemBoundsEventArgs(Owner, e.Graphics, e.Clip, this, img));
                }
            }
            #endregion

            if (SizeMode != RibbonElementSizeMode.Compact)
            {
                Owner.Renderer.OnRenderRibbonItemText(new RibbonItemBoundsEventArgs(Owner, e.Graphics, e.Clip, this, _textBounds));
            }

            //Rectangle t = Rectangle.Empty;
            //int imgw = SmallImage == null ? 16 : SmallImage.Width;
            //int imgh = Image == null ? 32 : Image.Height;

            //if (theSize == RibbonElementSizeMode.Large)
            //{
            //    t = Rectangle.FromLTRB(
            //        Bounds.Left + Owner.ItemMargin.Left,
            //        Bounds.Top + Owner.ItemMargin.Top + imgh + Owner.ItemMargin.Vertical,
            //        Bounds.Right - Owner.ItemMargin.Right,
            //        Bounds.Bottom - Owner.ItemMargin.Bottom);

            //    if(SizeMode != RibbonElementSizeMode.Compact)
            //        Owner.Renderer.OnRenderRibbonItemText(
            //            new RibbonItemBoundsEventArgs(Owner, e.Graphics, e.Clip, this, t));
            //}
            //else
            //{
            //    int ddw = Style != RibbonButtonStyle.Normal ? _dropDownMargin.Horizontal : 0;
            //    t = Rectangle.FromLTRB(
            //        Bounds.Left + imgw + Owner.ItemMargin.Horizontal + Owner.ItemMargin.Left,
            //        Bounds.Top + Owner.ItemMargin.Top,
            //        Bounds.Right - ddw,
            //        Bounds.Bottom - Owner.ItemMargin.Bottom);

            //    if (SizeMode != RibbonElementSizeMode.Compact)
            //        Owner.Renderer.OnRenderRibbonItemText(
            //            new RibbonItemBoundsEventArgs(Owner, e.Graphics, e.Clip, this, t));
            //}
        }
Esempio n. 2
0
 public abstract void OnPaint(object sender, RibbonElementPaintEventArgs e);