protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e) { ToolStripItem tsi = ((e != null) ? e.Item : null); if ((tsi != null) && ((tsi.Owner is ContextMenuStrip) || (tsi.OwnerItem != null)) && tsi.Selected) { Rectangle rect = tsi.ContentRectangle; rect.Offset(0, -1); rect.Height += 1; Color clrStart = KeePassTsrColorTable.StartGradient(this.ColorTable.MenuItemSelected); Color clrEnd = KeePassTsrColorTable.EndGradient(this.ColorTable.MenuItemSelected); Color clrBorder = this.ColorTable.MenuItemBorder; if (!tsi.Enabled) { Color clrBase = this.ColorTable.MenuStripGradientEnd; clrStart = UIUtil.ColorTowardsGrayscale(clrStart, clrBase, 0.5); clrEnd = UIUtil.ColorTowardsGrayscale(clrEnd, clrBase, 0.2); clrBorder = UIUtil.ColorTowardsGrayscale(clrBorder, clrBase, 0.2); } Graphics g = e.Graphics; if (g != null) { LinearGradientBrush br = new LinearGradientBrush(rect, clrStart, clrEnd, LinearGradientMode.Vertical); Pen p = new Pen(clrBorder); SmoothingMode smOrg = g.SmoothingMode; g.SmoothingMode = SmoothingMode.HighQuality; GraphicsPath gp = UIUtil.CreateRoundedRectangle(rect.X, rect.Y, rect.Width, rect.Height, DpiUtil.ScaleIntY(2)); if (gp != null) { g.FillPath(br, gp); g.DrawPath(p, gp); gp.Dispose(); } else // Shouldn't ever happen... { Debug.Assert(false); g.FillRectangle(br, rect); g.DrawRectangle(p, rect); } g.SmoothingMode = smOrg; p.Dispose(); br.Dispose(); return; } else { Debug.Assert(false); } } base.OnRenderMenuItemBackground(e); }