/// <summary> /// Fires <see cref="CustomDrawItems" /> event. /// </summary> /// <param name="args">Object containing event data.</param> protected virtual void OnCustomDrawItems(DrawItemsEventArgs args) { if (CustomDrawItems != null) { CustomDrawItems(this, args); } }
/// <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)); }
/// <summary> /// Handles the <see cref="E:CustomDrawItems" /> event. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="DrawItemsEventArgs"/> instance containing the event data.</param> private void OnCustomDrawItems(object sender, DrawItemsEventArgs e) { var o = (AppearanceItem)pgrdItem.SelectedObject; var ts = o.AppearenceText.IsEmpty ? ZeroitToxicButton.DEFAULT.Item.AppearenceText : o.AppearenceText; switch (int.Parse(e.Item.Tag.ToString())) { case 1: PaintUtility.PaintGradientRectangle(e.Graphics, e.Bounds, o.DisabledStyle.IsEmpty ? ZeroitToxicButton.DEFAULT.Item.DisabledStyle : o.DisabledStyle); PaintUtility.PaintBorder(e.Graphics, e.Bounds, o.DisabledBorder.IsEmpty ? ZeroitToxicButton.DEFAULT.Item.DisabledBorder : o.DisabledBorder); PaintUtility.DrawString(e.Graphics, e.Bounds, e.Item.Caption, ts, false, o.DisabledForeGround.IsEmpty ? ZeroitToxicButton.DEFAULT.Item.DisabledForeGround : o.DisabledForeGround); break; case 2: PaintUtility.PaintGradientRectangle(e.Graphics, e.Bounds, o.SelectedStyle.IsEmpty ? ZeroitToxicButton.DEFAULT.Item.SelectedStyle : o.SelectedStyle); PaintUtility.PaintBorder(e.Graphics, e.Bounds, o.SelectedBorder.IsEmpty ? ZeroitToxicButton.DEFAULT.Item.SelectedBorder : o.SelectedBorder); PaintUtility.DrawString(e.Graphics, e.Bounds, e.Item.Caption, ts, false, o.SelectedForeGround.IsEmpty ? ZeroitToxicButton.DEFAULT.Item.SelectedForeGround : o.SelectedForeGround); break; case 3: PaintUtility.PaintGradientRectangle(e.Graphics, e.Bounds, o.ClickStyle.IsEmpty ? ZeroitToxicButton.DEFAULT.Item.ClickStyle : o.ClickStyle); PaintUtility.PaintBorder(e.Graphics, e.Bounds, o.SelectedBorder.IsEmpty ? ZeroitToxicButton.DEFAULT.Item.SelectedBorder : o.SelectedBorder); PaintUtility.DrawString(e.Graphics, e.Bounds, e.Item.Caption, ts, false, o.SelectedForeGround.IsEmpty ? ZeroitToxicButton.DEFAULT.Item.SelectedForeGround : o.SelectedForeGround); break; case 4: PaintUtility.PaintGradientRectangle(e.Graphics, e.Bounds, o.HoverStyle.IsEmpty ? ZeroitToxicButton.DEFAULT.Item.HoverStyle : o.HoverStyle); PaintUtility.PaintBorder(e.Graphics, e.Bounds, o.HoverBorder.IsEmpty ? ZeroitToxicButton.DEFAULT.Item.HoverBorder : o.HoverBorder); PaintUtility.DrawString(e.Graphics, e.Bounds, e.Item.Caption, ts, false, o.HoverForeGround.IsEmpty ? ZeroitToxicButton.DEFAULT.Item.HoverForeGround : o.HoverForeGround); break; case 5: PaintUtility.PaintGradientRectangle(e.Graphics, e.Bounds, o.SelectedHoverStyle.IsEmpty ? ZeroitToxicButton.DEFAULT.Item.SelectedHoverStyle : o.SelectedHoverStyle); PaintUtility.PaintBorder(e.Graphics, e.Bounds, o.HoverBorder.IsEmpty ? ZeroitToxicButton.DEFAULT.Item.HoverBorder : o.HoverBorder); PaintUtility.DrawString(e.Graphics, e.Bounds, e.Item.Caption, ts, false, o.HoverForeGround.IsEmpty ? ZeroitToxicButton.DEFAULT.Item.HoverForeGround : o.HoverForeGround); break; default: PaintUtility.PaintGradientRectangle(e.Graphics, e.Bounds, o.BackStyle.IsEmpty ? ZeroitToxicButton.DEFAULT.Item.BackStyle : o.BackStyle); PaintUtility.PaintBorder(e.Graphics, e.Bounds, o.NormalBorder.IsEmpty ? ZeroitToxicButton.DEFAULT.Item.NormalBorder : o.NormalBorder); PaintUtility.DrawString(e.Graphics, e.Bounds, e.Item.Caption, ts, false, o.NormalForeGround.IsEmpty ? ZeroitToxicButton.DEFAULT.Item.NormalForeGround : o.NormalForeGround); break; } e.Handeled = true; }