protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e)
{
// Make sure the font is current
if (e.ToolStrip.Font != KCT.MenuStripFont)
e.ToolStrip.Font = KCT.MenuStripFont;
if ((e.ToolStrip is ContextMenuStrip) ||
(e.ToolStrip is ToolStripDropDownMenu))
{
// Create border and clipping paths
using (GraphicsPath borderPath = CreateBorderPath(e.AffectedBounds, _cutContextMenu),
clipPath = CreateClipBorderPath(e.AffectedBounds, _cutContextMenu))
{
// Clip all drawing to within the border path
using (Clipping clipping = new Clipping(e.Graphics, clipPath))
{
// Create the background brush
using (SolidBrush backBrush = new SolidBrush(KCT.ToolStripDropDownBackground))
e.Graphics.FillPath(backBrush, borderPath);
}
}
}
else if (e.ToolStrip is StatusStrip)
{
// Create rectangle that covers the status strip area
RectangleF backRect = new RectangleF(0, 0, e.ToolStrip.Width, e.ToolStrip.Height);
Form owner = e.ToolStrip.FindForm();
// Check if the status strip is inside a KryptonForm and using the Sparkle renderer, in
// which case we want to extend the drawing down into the border area for an integrated look
if ((owner != null) &&
(owner is KryptonForm) &&
e.ToolStrip.Visible &&
(e.ToolStrip.Dock == DockStyle.Bottom) &&
(e.ToolStrip.Bottom == owner.ClientSize.Height) &&
(e.ToolStrip.RenderMode == ToolStripRenderMode.ManagerRenderMode) &&
(ToolStripManager.Renderer is KryptonSparkleRenderer))
{
// Get the window borders
KryptonForm kryptonForm = (KryptonForm)owner;
// Finally check that the actual form is using custom chrome
if (kryptonForm.ApplyCustomChrome)
{
// Extend down into the bottom border
Padding borders = kryptonForm.RealWindowBorders;
backRect.Height += borders.Bottom;
backRect.Width += borders.Horizontal;
backRect.X -= borders.Left;
}
}
// Cannot paint a zero sized area
if ((backRect.Width > 0) && (backRect.Height > 0))
{
// Draw entire background
using (SolidBrush backBrush = new SolidBrush(KCT.MenuStripGradientBegin))
e.Graphics.FillRectangle(backBrush, backRect);
// Create path for the rounded bottom edges
using (GraphicsPath innerPath = new GraphicsPath())
{
RectangleF innerRectF = new RectangleF(backRect.X + 2, backRect.Y, backRect.Width - 4, backRect.Height - 2);
innerPath.AddLine(innerRectF.Right - 1, innerRectF.Top, innerRectF.Right - 1, innerRectF.Bottom - 7);
innerPath.AddArc(innerRectF.Right - 7, innerRectF.Bottom - 7, 6, 6, 0f, 90f);
innerPath.AddArc(innerRectF.Left, innerRectF.Bottom - 7, 6, 6, 90f, 90f);
innerPath.AddLine(innerRectF.Left, innerRectF.Bottom - 7, innerRectF.Left, innerRectF.Top);
// Make the last and first arc join up
innerPath.CloseFigure();
// Fill with a gradient brush
using (LinearGradientBrush innerBrush = new LinearGradientBrush(new Rectangle((int)backRect.X - 1, (int)backRect.Y - 1,
(int)backRect.Width + 2, (int)backRect.Height + 1),
KCT.StatusStripGradientBegin,
KCT.StatusStripGradientEnd,
90f))
{
innerBrush.Blend = _statusStripBlend;
using(AntiAlias aa = new AntiAlias(e.Graphics))
e.Graphics.FillPath(innerBrush, innerPath);
}
}
}
}
else
base.OnRenderToolStripBackground(e);
}