protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e) { if (e.Item.Enabled) { e.TextColor = this.ThemeTextColor; base.OnRenderItemText(e); } else { e.Item.Enabled = true; if (this.ThemeBackgroundColor.GetBrightness() > 0.5) //light background color { e.TextColor = Theme.DarkenColor(this.ThemeBackgroundColor, 0.5f); } else //dark background color { e.TextColor = Theme.LightenColor(this.ThemeBackgroundColor, 0.5f); } base.OnRenderItemText(e); e.Item.Enabled = false; } }
protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e) { if (e.Item.Enabled) { e.TextColor = this.ThemeTextColor; base.OnRenderItemText(e); } else { // KBR 20190615 this step appears to be unnecessary [and prevents the menu from auto-collapsing] //e.Item.Enabled = true; if (this.ThemeBackgroundColor.GetBrightness() > 0.5) //light background color { e.TextColor = Theme.DarkenColor(this.ThemeBackgroundColor, 0.5f); } else //dark background color { e.TextColor = Theme.LightenColor(this.ThemeBackgroundColor, 0.5f); } base.OnRenderItemText(e); // KBR 20190615 this step appears to be unnecessary [and prevents the menu from auto-collapsing] //e.Item.Enabled = false; } }
protected override void OnRenderOverflowButtonBackground(ToolStripItemRenderEventArgs e) { #region Draw Background var space = 0.12f; var btn = (ToolStripOverflowButton)e.Item; var brushBg = new SolidBrush(Color.Black); // hover/selected state if (btn.Selected) { brushBg = new SolidBrush(Theme.LightenColor(this.ThemeBackgroundColor, 0.15f)); e.Graphics.FillRectangle(brushBg, new RectangleF( e.Item.Bounds.Width * space, e.Item.Bounds.Height * space, e.Item.Bounds.Width * (1 - space * 2), e.Item.Bounds.Height * (1 - space * 2) ) ); } else if (btn.DropDown.Visible) { brushBg = new SolidBrush(Theme.DarkenColor(this.ThemeBackgroundColor, 0.15f)); e.Graphics.FillRectangle(brushBg, new RectangleF( e.Item.Bounds.Width * space, e.Item.Bounds.Height * space, e.Item.Bounds.Width * (1 - space * 2), e.Item.Bounds.Height * (1 - space * 2) ) ); } brushBg.Dispose(); #endregion #region Draw "..." var brushFont = new SolidBrush(this.ThemeTextColor); var font = new Font(FontFamily.GenericSerif, 10, FontStyle.Bold); var fontSize = e.Graphics.MeasureString("…", font); e.Graphics.DrawString("…", font, brushFont, e.Item.Bounds.Width / 2 - fontSize.Width / 2, e.Item.Bounds.Height / 2 - fontSize.Height / 2 ); font.Dispose(); brushFont.Dispose(); #endregion }