Наследование: System.Windows.Forms.ToolStripItemRenderEventArgs
Пример #1
0
        protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
        {
            if ((e.Item is ToolStripMenuItem) && (e.Item.Selected || e.Item.Pressed))
                e.TextColor = e.Item.ForeColor;

            base.OnRenderItemText(e);
        }
 protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
 {
     Tab item = e.Item as Tab;
     if (item != null)
     {
         e.TextRectangle = e.Item.ContentRectangle;
         e.TextFormat |= TextFormatFlags.EndEllipsis;
         if (item.Pressed)
         {
             Rectangle textRectangle = e.TextRectangle;
             textRectangle.Offset(-1, -1);
             e.TextRectangle = textRectangle;
         }
         if (!((item.Checked || e.Item.IsForeColorSet()) || e.ToolStrip.IsForeColorSet()))
         {
             e.TextColor = SystemColors.GrayText;
         }
         if (item.Checked && !e.TextFont.Bold)
         {
             using (e.TextFont = new Font(e.TextFont, FontStyle.Bold))
             {
                 if (TextRenderer.MeasureText(e.Graphics, e.Text, e.TextFont).Width <= e.TextRectangle.Width)
                 {
                     e.TextFormat &= ~TextFormatFlags.EndEllipsis;
                 }
                 base.OnRenderItemText(e);
             }
             return;
         }
     }
     base.OnRenderItemText(e);
 }
Пример #3
0
            protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
            {
                var helper = new GraphicsHelper(e.Graphics);
                var button = e.Item as ToolStripButton;

                var shadow = new Rectangle(
                    e.TextRectangle.X + 1,
                    e.TextRectangle.Y + 1,
                    e.TextRectangle.Width,
                    e.TextRectangle.Height);

                uint shadowColor = UColor.Blend(0xdd, UColor.White);
                uint textColor = e.TextColor.ToUInt();

                if (e.Item.Selected || e.Item.Pressed || (button != null && button.Checked))
                {
                    shadowColor = UColor.Blend(0x7a, UColor.Black);
                    textColor = UColor.White;
                }

                var format = new StringFormat();
                format.LineAlignment = StringAlignment.Center;
                format.Alignment = StringAlignment.Near;

                helper.Text(e.Text, e.TextFont, shadowColor, shadow, format);
                helper.Text(e.Text, e.TextFont, textColor, e.TextRectangle, format);
            }
Пример #4
0
 //Modification of original OnRenderItemText to allow color to be set even if the control is disabled
 protected void OnRenderItemTextNew(ToolStripItemTextRenderEventArgs e)
 {
     Graphics dc = e.Graphics;
         Color textColor = e.TextColor;
         Font textFont = e.TextFont;
         string text = e.Text;
         Rectangle textRectangle = e.TextRectangle;
         TextFormatFlags textFormat = e.TextFormat;
         //textColor = item.Enabled ? textColor : SystemColors.GrayText;
         if (((e.TextDirection != ToolStripTextDirection.Horizontal) && (textRectangle.Width > 0)) && (textRectangle.Height > 0))
         {
             Size size = /*LayoutUtils.FlipSize(*/textRectangle.Size/*)*/;
             using (Bitmap bitmap = new Bitmap(size.Width, size.Height, PixelFormat.Format32bppPArgb))
             {
                 using (Graphics graphics2 = Graphics.FromImage(bitmap))
                 {
                     graphics2.TextRenderingHint = TextRenderingHint.AntiAlias;
                     TextRenderer.DrawText(graphics2, text, textFont, new Rectangle(Point.Empty, size), textColor, textFormat);
                     bitmap.RotateFlip((e.TextDirection == ToolStripTextDirection.Vertical90) ? RotateFlipType.Rotate90FlipNone : RotateFlipType.Rotate270FlipNone);
                     dc.DrawImage(bitmap, textRectangle);
                 }
                 return;
             }
         }
         TextRenderer.DrawText(dc, text, textFont, textRectangle, textColor, textFormat);
 }
 protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
 {
     Rectangle textRectangle = e.TextRectangle;
     if (((e.ToolStrip is ToolStripDropDown) && (e.Item is ToolStripMenuItem)) && (textRectangle.Left < 40))
     {
         textRectangle = Rectangle.FromLTRB(0x18, textRectangle.Top, textRectangle.Right, textRectangle.Bottom);
     }
     if (!e.Item.Enabled)
     {
         textRectangle.Offset(1, 1);
         TextRenderer.DrawText(e.Graphics, e.Text, e.TextFont, textRectangle, SystemColors.ControlLightLight, e.TextFormat);
         textRectangle.Offset(-1, -1);
         TextRenderer.DrawText(e.Graphics, e.Text, e.TextFont, textRectangle, SystemColors.GrayText, e.TextFormat);
     }
     else
     {
         ToolStripSplitButton button = e.Item as ToolStripSplitButton;
         if (!((e.Item is ToolStripMenuItem) || !((button != null) ? button.ButtonPressed : e.Item.Pressed)))
         {
             textRectangle.Offset(1, 1);
         }
         e.TextRectangle = textRectangle;
         ToolStripMenuItem item = e.Item as ToolStripMenuItem;
         if ((item != null) && (item.Selected || item.DropDown.Visible))
         {
             e.TextColor = SystemColors.HighlightText;
         }
         base.OnRenderItemText(e);
     }
 }
        /// <summary>
        /// Raises the RenderItemText event.
        /// </summary>
        /// <param name="e">A ToolStripItemTextRenderEventArgs that contains the event data.</param>
        protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
        {
			if (ColorTable.UseSystemColors == false)
			{
				ProfessionalColorTable colorTable = ColorTable as XiaoCai.WinformUI.Panels.ProfessionalColorTable;
				if (colorTable != null)
				{
					if ((e.ToolStrip is MenuStrip) && (e.Item.Selected == false) && e.Item.Pressed == false)
					{
						if (colorTable.MenuItemText != Color.Empty)
						{
							e.TextColor = colorTable.MenuItemText;
						}
					}
					if ((e.ToolStrip is StatusStrip) && (e.Item.Selected == false) && e.Item.Pressed == false)
					{
						if (colorTable.StatusStripText != Color.Empty)
						{
							e.TextColor = colorTable.StatusStripText;
						}
					}
				}
			}
            base.OnRenderItemText(e);
        }
        protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
        {
            ToolStripStatusLabel label = e.Item as ToolStripStatusLabel;

            // It's not a label, panic, wait no; just let the SystemRenderer do it's thing
            if (label == null)
            {
                base.OnRenderItemText(e);
                return;
            }

            // If we are rendering a link we don't support AutoEllipsie
            if (label.IsLink)
            {
                base.OnRenderItemText(e);
                return;
            }

            TextRenderer.DrawText(e.Graphics,
                label.Text,
                label.Font,
                e.TextRectangle,
                label.ForeColor,
                TextFormatFlags.EndEllipsis);
        }
Пример #8
0
		protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
		{
			// Without this, the ToolStrip renderer leaves some border artifacts
			// even when the style is set to "no border".
			e.SizeTextRectangleToText();
			base.OnRenderItemText(e);
		}
Пример #9
0
 protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e) {
     if(fNoPrefix) {
         e.TextFormat |= TextFormatFlags.NoPrefix;
     }
     e.TextColor = e.Item.Selected ? SystemColors.HighlightText : SystemColors.MenuText;
     base.OnRenderItemText(e);
 }
Пример #10
0
        protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
        {
            if (e.Item.Selected && (!e.Item.Pressed || e.Item is ToolStripButton))
            {
                e.DefaultTextColor = SystemColors.HighlightText;
            }
            else if (e.TextColor != SystemColors.HighlightText && e.TextColor != SystemColors.ControlText)
            {
                // we'll change the DefaultTextColor, if someone wants to change this,manually set the TextColor property.
                if (e.Item.Selected || e.Item.Pressed)
                {
                    e.DefaultTextColor = SystemColors.HighlightText;
                }
                else
                {
                    e.DefaultTextColor = SystemColors.ControlText;
                }
            }

            // ToolstripButtons that are checked are rendered with a highlight
            // background. In that case, set the text color to highlight as well.
            if (typeof(ToolStripButton).IsAssignableFrom(e.Item.GetType()) &&
                ((ToolStripButton)e.Item).DisplayStyle != ToolStripItemDisplayStyle.Image &&
                ((ToolStripButton)e.Item).Checked)
            {
                e.TextColor = SystemColors.HighlightText;
            }

            base.OnRenderItemText(e);
        }
 protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
 {
     if ((e.TextColor != SystemColors.HighlightText) || (e.TextColor != SystemColors.ControlText))
     {
         e.DefaultTextColor = SystemColors.ControlText;
     }
     base.OnRenderItemText(e);
 }
 protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
 {
     // 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(255, e.TextColor.R, e.TextColor.G, e.TextColor.B);
       using (SolidBrush brush = new SolidBrush(color))
     e.Graphics.DrawString(e.Text, e.TextFont, brush, e.TextRectangle);
 }
Пример #13
0
 protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
 {
     base.OnRenderItemText(e);
     Tab tab = e.Item as Tab;
     if (tab != null && tab.Checked) {
         Rectangle rect = e.TextRectangle;
         ControlPaint.DrawFocusRectangle(e.Graphics, rect);
     }
 }
Пример #14
0
 protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
 {
     e.Graphics.DrawString(
         e.Text,
         e.TextFont,
         textBrush,
         e.TextRectangle.Location
     );
 }
Пример #15
0
        protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
        {
            if (e.Item is ToolStripMenuItem && ((ToolStripMenuItem)e.Item).Checked)
            {
                e.TextFont = new Font(e.Item.Font, FontStyle.Bold);
            }

            base.OnRenderItemText(e);
        }
Пример #16
0
        protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
        {
            if (e.Item is ToolStripLabel)
            {
                e.TextRectangle = new Rectangle(e.TextRectangle.X + 5, e.TextRectangle.Y, e.Item.Bounds.Width - 5, e.TextRectangle.Height);
                base.OnRenderItemText(e);
                return;
            }

            var text = e.Text;
            var font = e.TextFont;
            var rect = e.TextRectangle;
            var format = e.TextFormat;

            // symbol 0x25CF
            var iconCol = MyColors.LeftToolGray;
            if (e.Item.Tag != null && e.Item.Tag is Color)
                iconCol = (Color)e.Item.Tag;
            e.TextColor = iconCol;
            e.TextFont = new Font(e.TextFont.FontFamily, 18);
            e.Text = Common.theSign;
            e.TextFormat = TextFormatFlags.NoPadding | TextFormatFlags.Left;
            e.TextRectangle = new Rectangle(e.TextRectangle.X, 2, 40, 40);
            base.OnRenderItemText(e);

            // render textu
            e.Text = text;
            e.TextFont = new Font(font, FontStyle.Bold);
            e.TextRectangle = rect;
            e.TextFormat = format;
            e.TextColor = Color.White;
            e.TextRectangle = new Rectangle(e.TextRectangle.X + 25, e.TextRectangle.Y, e.Item.Bounds.Width - 25, e.TextRectangle.Height);
            var index = text.LastIndexOf('.');
            if (index == -1)
            {
                // polozka bez poctu..
                base.OnRenderItemText(e);
                return;
            }

            // text polozky
            var title = text.Substring(0, index + 1);
            e.TextColor = Color.White;
            e.Text = title;
            base.OnRenderItemText(e);

            // pocet poloziek
            var count = "0";
            if (text.Contains(' '))
                count = text.Substring(text.IndexOf(' ') + 1).Trim('(', ')');
            e.Text = count;
            e.TextFont = font;
            e.TextColor = MyColors.LeftToolGray;
            e.TextFormat = TextFormatFlags.NoPadding | TextFormatFlags.Right;
            e.TextRectangle = new Rectangle(e.TextRectangle.X, e.TextRectangle.Y, e.Item.Bounds.Width - e.TextRectangle.X - 10, e.TextRectangle.Height);
            base.OnRenderItemText(e);
        }
Пример #17
0
        protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
        {
            //if (e.Item.Bounds.Contains(e.ToolStrip.PointToClient(Cursor.Position)))
            e.TextColor = Color.White;
            /*if (e.Item is ToolStripMenuItem)
                e.TextColor = Color.Black;*/

            base.OnRenderItemText(e);
        }
Пример #18
0
		protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
		{
			if (e.Item.Selected)
			{
				e.TextColor = Color.FromArgb(255, 223, 127);
			}

			base.OnRenderItemText(e);
		}
 protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
 {
     //e.TextFormat = TextFormatFlags.Left | TextFormatFlags.VerticalCenter;
     if (e.Item.Enabled)
         e.TextColor = Color.Black;
     else
         e.TextColor = Color.Gray;
     base.OnRenderItemText(e);
 }
Пример #20
0
 protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
 {
     if (e.TextColor != SystemColors.HighlightText && e.TextColor != SystemColors.ControlText)
     {
         // we'll change the DefaultTextColor, if someone wants to change this,manually set the TextColor property.
         e.DefaultTextColor = SystemColors.ControlText;
     }
     base.OnRenderItemText(e);
 }
        protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
        {
            if (e.Item.Selected && e.Item.Pressed == false)
                e.TextColor = MetroUI.Style.AccentFrontColor;
            else
                e.TextColor = MetroUI.Style.ForeColor;

            base.OnRenderItemText(e);
        }
        public void DrawItemText(ToolStripItemTextRenderEventArgs e)
        {
            this.OnRenderItemText(e);
            ToolStripItemTextRenderEventHandler handler = this.Events[EventRenderItemText] as ToolStripItemTextRenderEventHandler;

            if (handler != null)
            {
                handler(this, e);
            }
        }
Пример #23
0
        /// <include file='doc\ToolStripRenderer.uex' path='docs/doc[@for="ToolStripRenderer.DrawItemText"]/*' />
        /// <devdoc>
        /// Draw text
        /// </devdoc>
        public void DrawItemText(ToolStripItemTextRenderEventArgs e)
        {
            OnRenderItemText(e);

            ToolStripItemTextRenderEventHandler eh = Events[EventRenderItemText] as ToolStripItemTextRenderEventHandler;

            if (eh != null)
            {
                eh(this, e);
            }
        }
Пример #24
0
 protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
 {
     e.TextColor = Color.WhiteSmoke;
     if(e.Item.Selected) {
         e.TextColor = Color.Black;
     }
     if(e.Item.Pressed) {
         e.TextColor = Color.Black;
     }
     base.OnRenderItemText(e);
 }
Пример #25
0
 protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
 {
     if (e.Item.Enabled)
     {
         e.TextColor = Color.White;
     }
     else
     {
         e.TextColor = Color.FromArgb(200, 200, 200);
     }
     base.OnRenderItemText(e);
 }
        protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
        {
            var mi = e.Item as ToolStripMenuItem;
            if (mi != null)
            {
                e.TextColor = e.Text == getShortcutText(mi)
                                ? SystemColors.GrayText
                                : SystemColors.MenuText;
            }

            base.OnRenderItemText(e);
        }
Пример #27
0
 protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
 {
     if (e.Item is ToolStripMenuItem && ((ToolStripMenuItem) e.Item).Checked)
     {
         Rectangle rect = e.TextRectangle;
         rect.X += 5;
         e.Graphics.DrawString( e.Text, e.Item.Font, Brushes.Black, new Point( rect.X+5, rect.Y ) );
     }
     else
     {
         base.OnRenderItemText(e);
     }
 }
        protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
        {
            if (e.Item.IsOnDropDown && IsSupported)
            {

                var renderer = new VisualStyleRenderer("menu", 14, GetItemState(e.Item));
                
                e.TextColor = renderer.GetColor(ColorProperty.TextColor);

            }

            base.OnRenderItemText(e);

        }
Пример #29
0
        /// <summary>
        /// Raises the RenderItemText event. 
        /// </summary>
        /// <param name="e">A ToolStripItemTextRenderEventArgs that contains the event data.</param>
        protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
        {
            if (e.ToolStrip is MenuStrip)
                e.TextColor = KCT.MenuStripText;
            else if (e.ToolStrip is StatusStrip)
                e.TextColor = KCT.StatusStripText;
            else if ((e.ToolStrip is ContextMenuStrip) ||
                     (e.ToolStrip is ToolStripDropDown))
                e.TextColor = KCT.MenuItemText;
            else if (e.ToolStrip is ToolStrip)
                e.TextColor = KCT.ToolStripText;

            base.OnRenderItemText(e);
        }
Пример #30
0
        protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
        {
            if(e != null)
            {
                ToolStripItem tsi = e.Item;
                if(tsi != null)
                {
                    bool bDropDown = (tsi.OwnerItem != null);
                    bool bCtxMenu = (tsi.Owner is ContextMenuStrip);

                    Color clr = tsi.ForeColor;

                    if(!tsi.Enabled && !tsi.Selected)
                    {
                        if(!UIUtil.IsHighContrast)
                        {
                            // Draw light "shadow"
                            Rectangle r = e.TextRectangle;
                            int dx = DpiUtil.ScaleIntX(128) / 128; // Force floor
                            int dy = DpiUtil.ScaleIntY(128) / 128; // Force floor
                            r.Offset(dx, dy);
                            TextRenderer.DrawText(e.Graphics, e.Text, e.TextFont,
                                r, SystemColors.HighlightText, e.TextFormat);
                        }

                        clr = SystemColors.GrayText;
                    }
                    else if(tsi.Selected && (bDropDown || bCtxMenu))
                        clr = SystemColors.HighlightText;
                    else if(clr.ToArgb() == Control.DefaultForeColor.ToArgb())
                        clr = SystemColors.MenuText;
                    else
                    {
                        bool bDarkBack = this.IsDarkStyle;
                        bool bDarkText = UIUtil.IsDarkColor(clr);

                        if((bDarkBack && bDarkText) || (!bDarkBack && !bDarkText))
                        {
                            Debug.Assert(false);
                            clr = SystemColors.MenuText;
                        }
                    }

                    e.TextColor = clr;
                }
            }
            else { Debug.Assert(false); }

            base.OnRenderItemText(e);
        }
        protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
        {
            // Wow are we seriously still doing this alrighty then
            base.OnRenderItemText(e);
            
            if (e.Item.Selected)
            {
                e.Item.ForeColor = Color.White;
            }
            else
            {
                e.Item.ForeColor = Color.Black;
            }

        }
Пример #32
0
        protected virtual void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
        {
            if (e.TextDirection == ToolStripTextDirection.Vertical90)
            {
                GraphicsState gs = e.Graphics.Save();
                PointF        p  = new PointF(e.Graphics.Transform.OffsetX, e.Graphics.Transform.OffsetY);

                e.Graphics.ResetTransform();
                e.Graphics.RotateTransform(90);

                RectangleF r = new RectangleF((e.Item.Height - e.TextRectangle.Height) / 2, (e.TextRectangle.Width + p.X) * -1 - 18, e.TextRectangle.Height, e.TextRectangle.Width);

                StringFormat sf = new StringFormat();
                sf.Alignment = StringAlignment.Center;

                e.Graphics.DrawString(e.Text, e.TextFont, ThemeEngine.Current.ResPool.GetSolidBrush(e.TextColor), r, sf);

                e.Graphics.Restore(gs);
            }
            else if (e.TextDirection == ToolStripTextDirection.Vertical270)
            {
                GraphicsState gs = e.Graphics.Save();
                PointF        p  = new PointF(e.Graphics.Transform.OffsetX, e.Graphics.Transform.OffsetY);

                e.Graphics.ResetTransform();
                e.Graphics.RotateTransform(270);

                RectangleF r = new RectangleF(-e.TextRectangle.Height - (e.Item.Height - e.TextRectangle.Height) / 2, (e.TextRectangle.Width + p.X) + 4, e.TextRectangle.Height, e.TextRectangle.Width);

                StringFormat sf = new StringFormat();
                sf.Alignment = StringAlignment.Center;

                e.Graphics.DrawString(e.Text, e.TextFont, ThemeEngine.Current.ResPool.GetSolidBrush(e.TextColor), r, sf);

                e.Graphics.Restore(gs);
            }
            else
            {
                TextRenderer.DrawText(e.Graphics, e.Text, e.TextFont, e.TextRectangle, e.TextColor, e.TextFormat);
            }

            ToolStripItemTextRenderEventHandler eh = (ToolStripItemTextRenderEventHandler)Events[RenderItemTextEvent];

            if (eh != null)
            {
                eh(this, e);
            }
        }
		protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
		{
			var g = e.Graphics;
			g.TextRenderingHint = TextRenderingHint.AntiAlias;

			if (e.Item.IsOnDropDown)
			{
				var itemRect = GetItemRect(e.Item);
				var textRect = new Rectangle(24, itemRect.Y, itemRect.Width - (24 + 16), itemRect.Height);
				g.DrawString(e.Text, SkinManager.ROBOTO_MEDIUM_10, e.Item.Enabled ? SkinManager.GetMainTextBrush() : SkinManager.GetDisabledOrHintBrush(), textRect, new StringFormat() { LineAlignment = StringAlignment.Center });
			}
			else
			{
				g.DrawString(e.Text, SkinManager.ROBOTO_MEDIUM_10, Brushes.White, e.TextRectangle, new StringFormat() { LineAlignment = StringAlignment.Center });
			}
		}
        protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
        {
            //base.OnRenderItemText(e);
            Color color = Color.FromArgb(58, 67, 74);
            if(e.Item.Selected)
                color = Color.White;

            TextRenderer.DrawText(
                e.Graphics,
                e.Text,
                new Font("微软雅黑", 9),
                e.TextRectangle,
                color,
                Color.Transparent,
                TextFormatFlags.Left | TextFormatFlags.VerticalCenter | TextFormatFlags.EndEllipsis);
        }
        private static void doDraw(ToolStripItemTextRenderEventArgs e, bool isShortcut)
        {
            // 2013-10-31, Uwe Keim: Hier selbst zeichnen (via ILSpy kopiert und vereinfacht),
            //                       weil sonst ein disabled shortcut in einer anderen Farbe
            //                       gezeichnet werden würde.

            var item = e.Item;
            var graphics = e.Graphics;
            var color = e.TextColor;
            var textFont = e.TextFont;
            var text = e.Text;
            var textRectangle = e.TextRectangle;
            var textFormat = e.TextFormat;
            color = (item.Enabled ? color : (isShortcut ? color : SystemColors.GrayText));

            TextRenderer.DrawText(graphics, text, textFont, textRectangle, color, textFormat);
        }
Пример #36
0
            protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
            {
                // The TextColor for a disabled item is ignored, so we have to temporarily enable the item.
                bool enabled = e.Item.Enabled;
                e.Item.Enabled = true;
                base.OnRenderItemText(e);
                e.Item.Enabled = enabled;

                // Draw an icon just before the text starts
                String s = e.Text;
                String sSpaces = String.Empty;  // sSpaces will be the spaces at the beginning of s
                for (int i = 0; i < s.Length && s[i] == ' '; ++i)
                    sSpaces += ' ';
                Size indent = Drawing.MeasureText(sSpaces, e.TextFont);
                Image im = Images.GetImage16For(e.Item.Tag as IXenObject);
                e.Graphics.DrawImage(im, indent.Width - im.Width - RIGHT_MARGIN, e.TextRectangle.Top + TOP_MARGIN, im.Width, im.Height);
            }
Пример #37
0
        protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
        {
            Rectangle      rc  = e.TextRectangle;
            TabStripButton btn = e.Item as TabStripButton;
            Color          c   = e.TextColor;
            Font           f   = e.TextFont;

            if (btn != null)
            {
                int delta = ((Mirrored) ? -1 : 1) * ((btn.Checked) ? 1 : selOffset);
                if (e.ToolStrip.Orientation == Orientation.Horizontal)
                {
                    rc.Offset((Mirrored) ? 2 : 1, delta + ((Mirrored) ? 1 : -1));
                }
                else
                {
                    rc.Offset(delta + 2, 0);
                }
                if (btn.Selected)
                {
                    c = btn.HotTextColor;
                }
                else if (btn.Checked)
                {
                    c = btn.SelectedTextColor;
                }
                if (btn.Checked)
                {
                    f = btn.SelectedFont;
                }
            }
            ToolStripItemTextRenderEventArgs x =
                new ToolStripItemTextRenderEventArgs(e.Graphics, e.Item, e.Text, rc, c, f, e.TextFormat);

            x.TextDirection = e.TextDirection;
            if (_currentRenderer != null)
            {
                _currentRenderer.DrawItemText(x);
            }
            else
            {
                base.OnRenderItemText(x);
            }
        }
Пример #38
0
 protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
 {
     if (renderer is ToolStripProfessionalRenderer)
     {
         Color text = Color.Empty;
         if (e.ToolStrip is StatusStrip)
         {
             text = GetThemeColor("StatusStrip.ForeColor");
         }
         else
         {
             text = GetThemeColor("ToolStripItem.TextColor");
         }
         if (text != Color.Empty)
         {
             e.TextColor = text;
         }
     }
     renderer.DrawItemText(e);
 }
Пример #39
0
        /// <include file='doc\ToolStripRenderer.uex' path='docs/doc[@for="ToolStripRenderer.OnRenderItemText"]/*' />
        /// <devdoc>
        /// Draw the item's text.  ToolStrip users should override this function to change the
        /// drawing of all text.
        /// </devdoc>
        protected virtual void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
        {
            if (RendererOverride != null)
            {
                RendererOverride.OnRenderItemText(e);
                return;
            }

            ToolStripItem   item       = e.Item;
            Graphics        g          = e.Graphics;
            Color           textColor  = e.TextColor;
            Font            textFont   = e.TextFont;
            string          text       = e.Text;
            Rectangle       textRect   = e.TextRectangle;
            TextFormatFlags textFormat = e.TextFormat;

            // if we're disabled draw in a different color.
            textColor = (item.Enabled) ? textColor : SystemColors.GrayText;

            if (e.TextDirection != ToolStripTextDirection.Horizontal && textRect.Width > 0 && textRect.Height > 0)
            {
                // Perf: this is a bit heavy handed.. perhaps we can share the bitmap.
                Size textSize = LayoutUtils.FlipSize(textRect.Size);
                using (Bitmap textBmp = new Bitmap(textSize.Width, textSize.Height, PixelFormat.Format32bppPArgb)) {
                    using (Graphics textGraphics = Graphics.FromImage(textBmp)) {
                        // now draw the text..
                        textGraphics.TextRenderingHint = TextRenderingHint.AntiAlias;
                        TextRenderer.DrawText(textGraphics, text, textFont, new Rectangle(Point.Empty, textSize), textColor, textFormat);
                        textBmp.RotateFlip((e.TextDirection == ToolStripTextDirection.Vertical90) ? RotateFlipType.Rotate90FlipNone :  RotateFlipType.Rotate270FlipNone);
                        g.DrawImage(textBmp, textRect);
                    }
                }
            }
            else
            {
                TextRenderer.DrawText(g, text, textFont, textRect, textColor, textFormat);
            }
        }
Пример #40
0
 protected override void OnRenderItemText(System.Windows.Forms.ToolStripItemTextRenderEventArgs e)
 {
     System.Drawing.Rectangle rectangle = e.TextRectangle;
     Oranikle.Studio.Controls.CtrlTabStripButton ctrlTabStripButton = e.Item as Oranikle.Studio.Controls.CtrlTabStripButton;
     System.Drawing.Color color = e.TextColor;
     System.Drawing.Font  font  = e.TextFont;
     if (ctrlTabStripButton != null)
     {
         int i1 = (Mirrored ? -1 : 1) * (ctrlTabStripButton.Checked ? ctrlTabStripButton.VerticalOffset : ctrlTabStripButton.VerticalOffsetInactive);
         int i2 = ctrlTabStripButton.Width - 37 - ctrlTabStripButton.CloseButtonHorizontalOffset - 7;
         if (i2 < 25)
         {
             return;
         }
         rectangle = new System.Drawing.Rectangle(37, rectangle.Y + i1, i2, rectangle.Height);
         if (ctrlTabStripButton.Selected)
         {
             color = ctrlTabStripButton.TextColorHot;
         }
         else if (ctrlTabStripButton.Checked)
         {
             color = ctrlTabStripButton.TextColor;
         }
         else
         {
             color = ctrlTabStripButton.TextColorInactive;
         }
     }
     System.Windows.Forms.ToolStripItemTextRenderEventArgs toolStripItemTextRenderEventArgs = new System.Windows.Forms.ToolStripItemTextRenderEventArgs(e.Graphics, e.Item, e.Text, rectangle, color, font, System.Drawing.ContentAlignment.MiddleLeft);
     if (currentRenderer != null)
     {
         currentRenderer.DrawItemText(toolStripItemTextRenderEventArgs);
         return;
     }
     base.OnRenderItemText(toolStripItemTextRenderEventArgs);
 }
Пример #41
0
 protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
 {
     base.OnRenderItemText(e);
 }
Пример #42
0
 public void DrawItemText(ToolStripItemTextRenderEventArgs e)
 {
     throw null;
 }
Пример #43
0
 protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
 {
     renderer.DrawItemText(e);
 }
Пример #44
0
 public void DrawItemText(ToolStripItemTextRenderEventArgs e)
 {
     this.OnRenderItemText(e);
 }
Пример #45
0
 protected virtual void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
 {
     throw null;
 }
Пример #46
0
        protected override void OnRenderItemText(System.Windows.Forms.ToolStripItemTextRenderEventArgs e)
        {
            if (!OsUtils.CompositionEnabled())
            {
                // The OS doesn't support desktop composition, or it isn't enabled
                base.OnRenderItemText(e);
                return;
            }

            // Drawing text on glass is a bit of a pain - text generated with GDI (e.g. standard
            // controls) ends up being transparent as GDI doesn't understand alpha transparency.
            // GDI+ is fine drawing text on glass but it doesn't use ClearType, so the text ends
            // up looking out of place, ugly or both.  The proper way is using DrawThemeTextEx,
            // which works fine, but requires a top-down DIB to draw to, rather than the bottom
            // up ones that GDI normally uses.  Hence; create top-down DIB, draw text to it and
            // then AlphaBlend it in to the graphics object that we are rendering to.

            // Get the rendering HDC, and create a compatible one for drawing the text to
            IntPtr renderHdc = e.Graphics.GetHdc();
            IntPtr memoryHdc = NativeMethods.CreateCompatibleDC(renderHdc);

            // NULL Pointer
            if (memoryHdc == IntPtr.Zero)
            {
                throw new Win32Exception();
            }

            NativeMethods.BITMAPINFO info = default(NativeMethods.BITMAPINFO);
            info.biSize        = Convert.ToUInt32(Marshal.SizeOf(typeof(NativeMethods.BITMAPINFO)));
            info.biWidth       = e.TextRectangle.Width;
            info.biHeight      = -e.TextRectangle.Height; // Negative = top-down
            info.biPlanes      = 1;
            info.biBitCount    = 32;
            info.biCompression = NativeMethods.BI_RGB;

            IntPtr bits = IntPtr.Zero;

            // Create the top-down DIB
            IntPtr dib = NativeMethods.CreateDIBSection(renderHdc, ref info, 0, ref bits, IntPtr.Zero, 0);

            // NULL Pointer
            if (dib == IntPtr.Zero)
            {
                throw new Win32Exception();
            }

            // Select the created DIB into our memory DC for use
            // NULL Pointer
            if (NativeMethods.SelectObject(memoryHdc, dib) == IntPtr.Zero)
            {
                throw new Win32Exception();
            }

            // Create a font we can use with GetThemeTextEx
            IntPtr hFont = e.TextFont.ToHfont();

            // And select it into the DC as well
            // NULL Pointer
            if (NativeMethods.SelectObject(memoryHdc, hFont) == IntPtr.Zero)
            {
                throw new Win32Exception();
            }

            // Fetch a VisualStyleRenderer suitable for toolbar text
            VisualStyleRenderer renderer = new VisualStyleRenderer(VisualStyleElement.ToolBar.Button.Normal);

            // Set up a RECT for the area to draw the text in
            NativeMethods.RECT textRect = default(NativeMethods.RECT);
            textRect.left   = 0;
            textRect.top    = 0;
            textRect.right  = e.TextRectangle.Width;
            textRect.bottom = e.TextRectangle.Height;

            // Options for GetThemeTextEx
            NativeMethods.DTTOPTS opts = default(NativeMethods.DTTOPTS);
            opts.dwSize  = Convert.ToUInt32(Marshal.SizeOf(opts));
            opts.dwFlags = NativeMethods.DTT_COMPOSITED | NativeMethods.DTT_TEXTCOLOR;
            opts.crText  = Convert.ToUInt32(ColorTranslator.ToWin32(e.TextColor)); // Alpha blended text of the colour specified

            // Paint the text
            Marshal.ThrowExceptionForHR(NativeMethods.DrawThemeTextEx(renderer.Handle, memoryHdc, 0, 0, e.Text, -1, (uint)e.TextFormat, ref textRect, ref opts));

            // Set up the AlphaBlend copy
            NativeMethods.BLENDFUNCTION blendFunc = default(NativeMethods.BLENDFUNCTION);
            blendFunc.BlendOp             = NativeMethods.AC_SRC_OVER;
            blendFunc.SourceConstantAlpha = 255;
            blendFunc.AlphaFormat         = NativeMethods.AC_SRC_ALPHA; // Per-pixel alpha only

            // Blend the painted text into the render DC
            if (!NativeMethods.AlphaBlend(renderHdc, e.TextRectangle.Left, e.TextRectangle.Top, e.TextRectangle.Width, e.TextRectangle.Height, memoryHdc, 0, 0, e.TextRectangle.Width, e.TextRectangle.Height, blendFunc))
            {
                throw new Win32Exception();
            }

            // Clean up the GDI objects
            if (!NativeMethods.DeleteObject(hFont))
            {
                throw new Win32Exception();
            }

            if (!NativeMethods.DeleteObject(dib))
            {
                throw new Win32Exception();
            }

            if (!NativeMethods.DeleteDC(memoryHdc))
            {
                throw new Win32Exception();
            }

            e.Graphics.ReleaseHdc();
        }
Пример #47
0
 protected override void OnRenderItemText(System.Windows.Forms.ToolStripItemTextRenderEventArgs e)
 {
     e.TextColor = this.ColorTable.CommonColorTable.TextColor;
     base.OnRenderItemText(e);
 }