Esempio n. 1
0
 /// <summary>
 /// Fires <see cref="CustomDrawBackGround" /> event.
 /// </summary>
 /// <param name="args">Object containing event data.</param>
 protected virtual void OnCustomDrawBackGround(DrawBackGroundEventArgs args)
 {
     if (CustomDrawBackGround != null)
     {
         CustomDrawBackGround(this, args);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.Control.Paint" /> event.
        /// </summary>
        /// <param name="e">A <see cref="T:System.Windows.Forms.PaintEventArgs" /> that contains the event data.</param>
        protected override void OnPaint(PaintEventArgs e)
        {
            CreateMemoryBitmap();
            //RefreshControl();
            Graphics.Clear(BackColor);
            //Graphics.Clear(Color.Transparent);
            var bArgs = new DrawBackGroundEventArgs(Graphics, ClientRectangle, CurrentAppearance.Bar, this);

            OnCustomDrawBackGround(bArgs);
            if (!bArgs.Handeled)
            {
                bArgs.DrawBackground();
                bArgs.DrawBorder();
            }
            if (!((items == null) || (items.Count == 0)))
            {
                foreach (BarItem barItem in items)
                {
                    var itemRect = new Rectangle(Padding.Left, barItem.Top, buttonWidth - Padding.Left - Padding.Right,
                                                 barItem.Height);
                    itemRect.Offset(0, AutoScrollPosition.Y);
                    var args = new DrawItemsEventArgs(Graphics, itemRect, barItem, GetButtonState(barItem), this);
                    OnCustomDrawItems(args);
                    if (args.Handeled)
                    {
                        continue;
                    }
                    args.DrawItemBackGround();
                    args.DrawItemBorder();
                    args.DrawIcon();
                    args.DrawItemText();
                }
            }
            if (!Enabled)
            {
                Graphics.FillRectangle(
                    new SolidBrush(Color.FromArgb((int)(DisableTransparency * 2.55), CurrentAppearance.Bar.DisabledMask)),
                    0, 0, Width - 1, Height - 1);
            }
            PaintUtility.DrawImage(e.Graphics, new Rectangle(0, 0, Width, Height), bmp, (int)(ImageTransparency * 2.55));
        }