/// <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)); } } }
/// <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)); } } }
protected override void OnRenderItemImage(ToolStripItemImageRenderEventArgs e) { Rectangle rc = e.ImageRectangle; TabStripButton btn = e.Item as TabStripButton; 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 : 0)); } else { rc.Offset(delta + 2, 0); } } ToolStripItemImageRenderEventArgs x = new ToolStripItemImageRenderEventArgs(e.Graphics, e.Item, e.Image, rc); if (_currentRenderer != null) { _currentRenderer.DrawItemImage(x); } else { base.OnRenderItemImage(x); } }
protected override void OnRenderItemImage(System.Windows.Forms.ToolStripItemImageRenderEventArgs e) { System.Drawing.Rectangle rectangle = e.ImageRectangle; Oranikle.Studio.Controls.CtrlTabStripButton ctrlTabStripButton = e.Item as Oranikle.Studio.Controls.CtrlTabStripButton; if (ctrlTabStripButton != null) { if (ctrlTabStripButton.DisplayStyle == System.Windows.Forms.ToolStripItemDisplayStyle.ImageAndText) { int i1 = (Mirrored ? -1 : 1) * (ctrlTabStripButton.Checked ? ctrlTabStripButton.VerticalOffset : ctrlTabStripButton.VerticalOffsetInactive); rectangle = new System.Drawing.Rectangle(10, 6 + i1, 22, 22); } else { int i2 = (Mirrored ? -1 : 1) * (ctrlTabStripButton.Checked ? ctrlTabStripButton.VerticalOffset - 4 : ctrlTabStripButton.VerticalOffsetInactive - 4); if (e.ToolStrip.Orientation == System.Windows.Forms.Orientation.Horizontal) { rectangle.Offset(-1, i2 + (Mirrored ? 1 : 0)); } else { rectangle.Offset(-1, 0); } } } System.Windows.Forms.ToolStripItemImageRenderEventArgs toolStripItemImageRenderEventArgs = new System.Windows.Forms.ToolStripItemImageRenderEventArgs(e.Graphics, e.Item, e.Image, rectangle); if (currentRenderer != null) { currentRenderer.DrawItemImage(toolStripItemImageRenderEventArgs); return; } base.OnRenderItemImage(toolStripItemImageRenderEventArgs); }
protected override void OnRenderItemImage(ToolStripItemImageRenderEventArgs e) { if (renderer is ToolStripProfessionalRenderer) { // Do not render set blank image if its a checked. Workaround for incorrect menu width. if (e.Item is ToolStripMenuItem && e.Item != null && ((ToolStripMenuItem)e.Item).Checked) { return; } } renderer.DrawItemImage(e); }
protected override void OnPaint(PaintEventArgs e) { if (base.Owner != null) { ToolStripRenderer renderer = base.Renderer; renderer.DrawLabelBackground(new ToolStripItemRenderEventArgs(e.Graphics, this)); if ((this.DisplayStyle & ToolStripItemDisplayStyle.Image) == ToolStripItemDisplayStyle.Image) { renderer.DrawItemImage(new ToolStripItemImageRenderEventArgs(e.Graphics, this, base.InternalLayout.ImageRectangle)); } this.PaintText(e.Graphics); } }
/// <summary> /// Inheriting classes should override this method to handle this event. /// </summary> protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { if (Owner != null) { ToolStripRenderer renderer = Renderer; renderer.DrawLabelBackground(new ToolStripItemRenderEventArgs(e.Graphics, this)); if ((DisplayStyle & ToolStripItemDisplayStyle.Image) == ToolStripItemDisplayStyle.Image) { renderer.DrawItemImage(new ToolStripItemImageRenderEventArgs(e.Graphics, this, InternalLayout.ImageRectangle)); } PaintText(e.Graphics); } }
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 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 OnRenderItemImage(ToolStripItemImageRenderEventArgs e) { renderer.DrawItemImage(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)); } } } }