protected override void OnRenderImageMargin(ToolStripRenderEventArgs e)
{
if ((e.ToolStrip is ContextMenuStrip) ||
(e.ToolStrip is ToolStripDropDownMenu))
{
// Start with the total margin area
Rectangle marginRect = e.AffectedBounds;
// Do we need to draw with separator on the opposite edge?
bool rtl = (e.ToolStrip.RightToLeft == RightToLeft.Yes);
marginRect.Y += _marginInset;
marginRect.Height -= _marginInset * 2;
// Reduce so it is inside the border
if (!rtl)
marginRect.X += _marginInset;
else
marginRect.X += _marginInset / 2;
// Draw the entire margine area in a solid color
using (SolidBrush backBrush = new SolidBrush(KCT.ImageMarginGradientBegin))
e.Graphics.FillRectangle(backBrush, marginRect);
// Create the light and dark line pens
using (Pen lightPen = new Pen(CommonHelper.WhitenColor(KCT.ToolStripDropDownBackground, 1.02f, 1.02f, 1.02f)),
darkPen = new Pen(CommonHelper.WhitenColor(KCT.ToolStripDropDownBackground, 1.26f, 1.26f, 1.26f)))
{
if (!rtl)
{
// Draw the light and dark lines on the right hand side
e.Graphics.DrawLine(lightPen, marginRect.Right, marginRect.Top, marginRect.Right, marginRect.Bottom);
e.Graphics.DrawLine(darkPen, marginRect.Right - 1, marginRect.Top, marginRect.Right - 1, marginRect.Bottom);
}
else
{
// Draw the light and dark lines on the left hand side
e.Graphics.DrawLine(lightPen, marginRect.Left - 1, marginRect.Top, marginRect.Left - 1, marginRect.Bottom);
e.Graphics.DrawLine(darkPen, marginRect.Left, marginRect.Top, marginRect.Left, marginRect.Bottom);
}
}
}
else
{
base.OnRenderImageMargin(e);
}
}