예제 #1
0
        protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
        {
            StringFormat format = ToolStripHelper.FlagsToStringFormat(e.TextFormat);

            format.FormatFlags |= StringFormatFlags.NoWrap;

            // In the case the renderer is used for a control sitting on an Aero glass window (Vista+)
            // we have to draw the text manually, as it would appear semi-transparently otherwise.
            Color color = Color.FromArgb(0xa2, 0xa4, 0xa5);

            if (e.Item.Enabled)
            {
                color = Color.FromArgb(0x1e, 0x1e, 0x1e);
            }
            using (SolidBrush brush = new SolidBrush(color))
                e.Graphics.DrawString(e.Text, e.TextFont, brush, e.TextRectangle, format);
        }
예제 #2
0
        protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
        {
            StringFormat format = ToolStripHelper.FlagsToStringFormat(e.TextFormat);

            format.FormatFlags |= StringFormatFlags.NoWrap;

            // In the case the renderer is used for a control sitting on an Aero glass window (Vista+)
            // we have to draw the text manually, as it would appear semi-transparently otherwise.
            Color color;
            Font  font = e.TextFont;

            if (Conversions.InHighContrastMode())
            {
                bool selected = e.Item.Selected;
                if (!e.Item.IsOnDropDown && ((ToolStripMenuItem)e.Item).DropDown.Visible)
                {
                    selected = false;
                }
                color = selected ? Color.White : Color.Black;
                if (!e.Item.Enabled)
                {
                    color = Color.Green;
                }
                font = new Font(font, font.Style | FontStyle.Bold);
            }
            else
            {
                color = Color.Gray;
                if (e.Item.Enabled)
                {
                    color = Color.Black;
                }
            }
            using (SolidBrush brush = new SolidBrush(color))
                e.Graphics.DrawString(e.Text, font, brush, e.TextRectangle, format);
        }