internal void PaintText(Graphics g) { ToolStripRenderer renderer = Renderer; if ((DisplayStyle & ToolStripItemDisplayStyle.Text) == ToolStripItemDisplayStyle.Text) { Font font = Font; Color textColor = ForeColor; if (IsLink) { LinkUtilities.EnsureLinkFonts(font, LinkBehavior, ref _linkFont, ref _hoverLinkFont); if (Pressed) { font = _hoverLinkFont; textColor = ActiveLinkColor; } else if (Selected) { font = _hoverLinkFont; textColor = (LinkVisited) ? VisitedLinkColor : LinkColor; } else { font = _linkFont; textColor = (LinkVisited) ? VisitedLinkColor : LinkColor; } } Rectangle textRect = InternalLayout.TextRectangle; renderer.DrawItemText(new ToolStripItemTextRenderEventArgs(g, this, Text, textRect, textColor, font, InternalLayout.TextFormat)); } }
/// <summary> /// Inheriting classes should override this method to handle this event. /// </summary> protected override void OnPaint(PaintEventArgs e) { if (Owner != null) { ToolStripRenderer renderer = Renderer; Graphics g = e.Graphics; renderer.DrawDropDownButtonBackground(new ToolStripItemRenderEventArgs(e.Graphics, this)); if ((DisplayStyle & ToolStripItemDisplayStyle.Image) == ToolStripItemDisplayStyle.Image) { renderer.DrawItemImage(new ToolStripItemImageRenderEventArgs(g, this, InternalLayout.ImageRectangle)); } if ((DisplayStyle & ToolStripItemDisplayStyle.Text) == ToolStripItemDisplayStyle.Text) { renderer.DrawItemText(new ToolStripItemTextRenderEventArgs(g, this, Text, InternalLayout.TextRectangle, ForeColor, Font, InternalLayout.TextFormat)); } if (ShowDropDownArrow) { Rectangle dropDownArrowRect = (InternalLayout is ToolStripDropDownButtonInternalLayout layout) ? layout.DropDownArrowRect : Rectangle.Empty; Color arrowColor; if (Selected && !Pressed && SystemInformation.HighContrast) { arrowColor = Enabled ? SystemColors.HighlightText : SystemColors.ControlDark; } else { arrowColor = Enabled ? SystemColors.ControlText : SystemColors.ControlDark; } renderer.DrawArrow(new ToolStripArrowRenderEventArgs(g, this, dropDownArrowRect, arrowColor, ArrowDirection.Down)); } } }
/// <include file='doc\ToolStripPopupButton.uex' path='docs/doc[@for="ToolStripDropDownButton.OnPaint"]/*' /> /// <devdoc> /// Inheriting classes should override this method to handle this event. /// </devdoc> protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { if (this.Owner != null) { ToolStripRenderer renderer = this.Renderer; Graphics g = e.Graphics; renderer.DrawDropDownButtonBackground(new ToolStripItemRenderEventArgs(e.Graphics, this)); if ((DisplayStyle & ToolStripItemDisplayStyle.Image) == ToolStripItemDisplayStyle.Image) { renderer.DrawItemImage(new ToolStripItemImageRenderEventArgs(g, this, InternalLayout.ImageRectangle)); } if ((DisplayStyle & ToolStripItemDisplayStyle.Text) == ToolStripItemDisplayStyle.Text) { renderer.DrawItemText(new ToolStripItemTextRenderEventArgs(g, this, this.Text, InternalLayout.TextRectangle, this.ForeColor, this.Font, InternalLayout.TextFormat)); } if (ShowDropDownArrow) { ToolStripDropDownButton.ToolStripDropDownButtonInternalLayout layout = InternalLayout as ToolStripDropDownButtonInternalLayout; Rectangle dropDownArrowRect = (layout != null) ? layout.DropDownArrowRect :Rectangle.Empty; Color arrowColor = Enabled ? SystemColors.ControlText : SystemColors.ControlDark; renderer.DrawArrow(new ToolStripArrowRenderEventArgs(g, this, dropDownArrowRect, arrowColor, ArrowDirection.Down)); } } }
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); } }
protected override void OnPaint(PaintEventArgs e) { ToolStripRenderer renderer = base.Renderer; if (renderer != null) { this.InvalidateSplitButtonLayout(); Graphics g = e.Graphics; renderer.DrawSplitButton(new ToolStripItemRenderEventArgs(g, this)); if ((this.DisplayStyle & ToolStripItemDisplayStyle.Image) != ToolStripItemDisplayStyle.None) { renderer.DrawItemImage(new ToolStripItemImageRenderEventArgs(g, this, this.SplitButtonButtonLayout.ImageRectangle)); } if ((this.DisplayStyle & ToolStripItemDisplayStyle.Text) != ToolStripItemDisplayStyle.None) { renderer.DrawItemText(new ToolStripItemTextRenderEventArgs(g, this, this.SplitButtonButton.Text, this.SplitButtonButtonLayout.TextRectangle, this.ForeColor, this.Font, this.SplitButtonButtonLayout.TextFormat)); } } }
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); }
protected override void OnPaint(PaintEventArgs e) { if (base.Owner != null) { ToolStripRenderer renderer = base.Renderer; renderer.DrawButtonBackground(new ToolStripItemRenderEventArgs(e.Graphics, this)); if ((this.DisplayStyle & ToolStripItemDisplayStyle.Image) == ToolStripItemDisplayStyle.Image) { ToolStripItemImageRenderEventArgs args = new ToolStripItemImageRenderEventArgs(e.Graphics, this, base.InternalLayout.ImageRectangle) { ShiftOnPress = true }; renderer.DrawItemImage(args); } if ((this.DisplayStyle & ToolStripItemDisplayStyle.Text) == ToolStripItemDisplayStyle.Text) { renderer.DrawItemText(new ToolStripItemTextRenderEventArgs(e.Graphics, this, this.Text, base.InternalLayout.TextRectangle, this.ForeColor, this.Font, base.InternalLayout.TextFormat)); } } }
/// <include file='doc\ToolStripButton.uex' path='docs/doc[@for="ToolStripButton.OnPaint"]/*' /> /// <devdoc> /// Inheriting classes should override this method to handle this event. /// </devdoc> protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { if (this.Owner != null) { ToolStripRenderer renderer = this.Renderer; renderer.DrawButtonBackground(new ToolStripItemRenderEventArgs(e.Graphics, this)); if ((DisplayStyle & ToolStripItemDisplayStyle.Image) == ToolStripItemDisplayStyle.Image) { ToolStripItemImageRenderEventArgs rea = new ToolStripItemImageRenderEventArgs(e.Graphics, this, InternalLayout.ImageRectangle); rea.ShiftOnPress = true; renderer.DrawItemImage(rea); } if ((DisplayStyle & ToolStripItemDisplayStyle.Text) == ToolStripItemDisplayStyle.Text) { renderer.DrawItemText(new ToolStripItemTextRenderEventArgs(e.Graphics, this, this.Text, InternalLayout.TextRectangle, this.ForeColor, this.Font, InternalLayout.TextFormat)); } } }
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); }
protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e) { renderer.DrawItemText(e); }
protected override void OnPaint(PaintEventArgs e) { if (base.Owner != null) { ToolStripRenderer renderer = base.Renderer; Graphics g = e.Graphics; renderer.DrawMenuItemBackground(new ToolStripItemRenderEventArgs(g, this)); Color menuText = SystemColors.MenuText; if (base.IsForeColorSet) { menuText = this.ForeColor; } else if (!this.IsTopLevel || ToolStripManager.VisualStylesEnabled) { if (this.Selected || this.Pressed) { menuText = SystemColors.HighlightText; } else { menuText = SystemColors.MenuText; } } bool flag = this.RightToLeft == RightToLeft.Yes; ToolStripMenuItemInternalLayout internalLayout = base.InternalLayout as ToolStripMenuItemInternalLayout; if ((internalLayout != null) && internalLayout.UseMenuLayout) { if ((this.CheckState != System.Windows.Forms.CheckState.Unchecked) && internalLayout.PaintCheck) { Rectangle checkRectangle = internalLayout.CheckRectangle; if (!internalLayout.ShowCheckMargin) { checkRectangle = internalLayout.ImageRectangle; } if (checkRectangle.Width != 0) { renderer.DrawItemCheck(new ToolStripItemImageRenderEventArgs(g, this, this.CheckedImage, checkRectangle)); } } if ((this.DisplayStyle & ToolStripItemDisplayStyle.Text) == ToolStripItemDisplayStyle.Text) { renderer.DrawItemText(new ToolStripItemTextRenderEventArgs(g, this, this.Text, base.InternalLayout.TextRectangle, menuText, this.Font, flag ? ContentAlignment.MiddleRight : ContentAlignment.MiddleLeft)); bool showShortcutKeys = this.ShowShortcutKeys; if (!base.DesignMode) { showShortcutKeys = showShortcutKeys && !this.HasDropDownItems; } if (showShortcutKeys) { renderer.DrawItemText(new ToolStripItemTextRenderEventArgs(g, this, this.GetShortcutText(), base.InternalLayout.TextRectangle, menuText, this.Font, flag ? ContentAlignment.MiddleLeft : ContentAlignment.MiddleRight)); } } if (this.HasDropDownItems) { ArrowDirection arrowDirection = flag ? ArrowDirection.Left : ArrowDirection.Right; Color arrowColor = (this.Selected || this.Pressed) ? SystemColors.HighlightText : SystemColors.MenuText; arrowColor = this.Enabled ? arrowColor : SystemColors.ControlDark; renderer.DrawArrow(new ToolStripArrowRenderEventArgs(g, this, internalLayout.ArrowRectangle, arrowColor, arrowDirection)); } if ((internalLayout.PaintImage && ((this.DisplayStyle & ToolStripItemDisplayStyle.Image) == ToolStripItemDisplayStyle.Image)) && (this.Image != null)) { renderer.DrawItemImage(new ToolStripItemImageRenderEventArgs(g, this, base.InternalLayout.ImageRectangle)); } } else { if ((this.DisplayStyle & ToolStripItemDisplayStyle.Text) == ToolStripItemDisplayStyle.Text) { renderer.DrawItemText(new ToolStripItemTextRenderEventArgs(g, this, this.Text, base.InternalLayout.TextRectangle, menuText, this.Font, base.InternalLayout.TextFormat)); } if (((this.DisplayStyle & ToolStripItemDisplayStyle.Image) == ToolStripItemDisplayStyle.Image) && (this.Image != null)) { renderer.DrawItemImage(new ToolStripItemImageRenderEventArgs(g, this, base.InternalLayout.ImageRectangle)); } } } }