187 references to TextRenderer
System.Windows.Forms (86)
System\Windows\Forms\Controls\Buttons\Button.cs (1)
96Size requiredSize = TextRenderer.MeasureText(Text, Font);
System\Windows\Forms\Controls\Buttons\ButtonInternal\ButtonBaseAdapter.cs (5)
92/// Get <see cref="TextFormatFlags"/> for rendering text using GDI (<see cref="TextRenderer"/>). 496TextRenderer.DrawTextInternal(e, Control.Text, Control.Font, r, colors.ButtonShadow, formatFlags); 501TextRenderer.DrawTextInternal(e, Control.Text, Control.Font, r, colors.Highlight, formatFlags); 504TextRenderer.DrawTextInternal(e, Control.Text, Control.Font, r, colors.ButtonShadow, formatFlags); 509TextRenderer.DrawTextInternal(e, Control.Text, Control.Font, r, color, formatFlags);
System\Windows\Forms\Controls\Buttons\ButtonInternal\ButtonBaseAdapter.LayoutOptions.cs (1)
677textSize = TextRenderer.MeasureText(Text, Font, proposedSize, TextFormatFlags);
System\Windows\Forms\Controls\Buttons\ButtonRenderer.cs (2)
162TextRenderer.DrawText(g, buttonText, font, contentBounds, textColor, flags); 273TextRenderer.DrawText(deviceContext, buttonText, font, contentBounds, textColor, flags);
System\Windows\Forms\Controls\Buttons\CheckBox.cs (1)
283Size textSize = TextRenderer.MeasureText(Text, Font);
System\Windows\Forms\Controls\Buttons\CheckBoxRenderer.cs (2)
147TextRenderer.DrawText(g, checkBoxText, font, textBounds, textColor, flags); 219TextRenderer.DrawText(g, checkBoxText, font, textBounds, textColor, flags);
System\Windows\Forms\Controls\Buttons\RadioButton.cs (1)
254Size textSize = TextRenderer.MeasureText(Text, Font);
System\Windows\Forms\Controls\Buttons\RadioButtonRenderer.cs (2)
147TextRenderer.DrawText(g, radioButtonText, font, textBounds, textColor, flags); 240TextRenderer.DrawText(g, radioButtonText, font, textBounds, textColor, flags);
System\Windows\Forms\Controls\ComboBox\ComboBox.cs (2)
774Size textSize = TextRenderer.MeasureText(LayoutUtils.TestString, Font, new Size(short.MaxValue, (int)(FontHeight * 1.25)), TextFormatFlags.SingleLine); 785Size textSize = TextRenderer.MeasureText(LayoutUtils.TestString, Font, new Size(short.MaxValue, (int)(FontHeight * 1.25)), TextFormatFlags.SingleLine);
System\Windows\Forms\Controls\ComboBox\ComboBoxRenderer.cs (1)
92TextRenderer.DrawText(g, comboBoxText, font, textBounds, textColor, flags);
System\Windows\Forms\Controls\DataGridView\DataGridViewButtonCell.cs (1)
992TextRenderer.DrawText(
System\Windows\Forms\Controls\DataGridView\DataGridViewCell.cs (4)
2552Size requiredSize = TextRenderer.MeasureText(text, font, new Size(maxWidth, int.MaxValue), flags); 2591textSize = TextRenderer.MeasureText(text, font, new Size((int)maxWidth, int.MaxValue), flags); 2620return TextRenderer.MeasureText(text, font, new Size(int.MaxValue, int.MaxValue), flags); 2647textSize = TextRenderer.MeasureText(text, font, new Size((int)maxWidth, maxHeight), flags);
System\Windows\Forms\Controls\DataGridView\DataGridViewColumnHeaderCell.cs (1)
976TextRenderer.DrawText(
System\Windows\Forms\Controls\DataGridView\DataGridViewComboBoxCell.cs (2)
606Size preferredSize = TextRenderer.MeasureText(comboBox.GetItemText(item), comboBox.Font); 2339TextRenderer.DrawText(
System\Windows\Forms\Controls\DataGridView\DataGridViewLinkCell.cs (1)
1027TextRenderer.DrawText(
System\Windows\Forms\Controls\DataGridView\DataGridViewRowHeaderCell.cs (1)
888TextRenderer.DrawText(
System\Windows\Forms\Controls\DataGridView\DataGridViewTextBoxCell.cs (1)
743TextRenderer.DrawText(graphics,
System\Windows\Forms\Controls\DataGridView\DataGridViewTopLeftHeaderCell.cs (1)
328TextRenderer.DrawText(
System\Windows\Forms\Controls\DataGridView\DataGridViewUtilities.cs (2)
322Size sizeRequired = TextRenderer.MeasureText(text, font, new Size(int.MaxValue, int.MaxValue), flags); 330Size sizeConstraint = TextRenderer.MeasureText(text, font, sizeCell, flags);
System\Windows\Forms\Controls\GroupBox\GroupBox.cs (1)
430Color textColor = Enabled ? ForeColor : TextRenderer.DisabledTextColor(BackColor);
System\Windows\Forms\Controls\GroupBox\GroupBoxRenderer.cs (4)
181Size measuredBounds = TextRenderer.MeasureText( 202TextRenderer.DrawText(deviceContext, groupBoxText, font, textBounds, textColor, flags); 284Size measuredBounds = TextRenderer.MeasureText( 303TextRenderer.DrawText(deviceContext, groupBoxText, font, textBounds, textColor, flags);
System\Windows\Forms\Controls\Labels\Label.cs (3)
1299TextRenderer.DrawTextInternal(e, Text, Font, face, color, flags: flags); 1306Color disabledTextForeColor = TextRenderer.DisabledTextColor(BackColor); 1307TextRenderer.DrawTextInternal(e, Text, Font, face, disabledTextForeColor, flags: flags);
System\Windows\Forms\Controls\Labels\LinkLabel.cs (4)
559Size textSize = TextRenderer.MeasureText(text, alwaysUnderlined, clientSize, flags); 1302TextRenderer.DrawText( 1311| TextRenderer.SkipAssertFlag 1365TextRenderer.DrawText(
System\Windows\Forms\Controls\ListBoxes\CheckedListBox.cs (1)
702TextRenderer.DrawText(e, text, font, stringBounds, foreColor, flags);
System\Windows\Forms\Controls\ListView\DrawListViewColumnHeaderEventArgs.cs (2)
142int padding = TextRenderer.MeasureText(" ", Font).Width; 145TextRenderer.DrawText(Graphics, text, Font, newBounds, ForeColor, flags);
System\Windows\Forms\Controls\ListView\DrawListViewItemEventArgs.cs (2)
91TextRenderer.DrawText(Graphics, Item.Text, Item.Font, UpdateBounds(Bounds, drawText: true), Item.ForeColor, flags); 104Size textSize = TextRenderer.MeasureText(subItem.Text, subItem.Font);
System\Windows\Forms\Controls\ListView\DrawListViewSubItemEventArgs.cs (2)
140int padding = TextRenderer.MeasureText(" ", font).Width; 143TextRenderer.DrawText(Graphics, text, font, newBounds, color, flags);
System\Windows\Forms\Controls\ListView\ListViewItem.IKeyboardToolTip.cs (3)
114new Size(Math.Min(TextRenderer.MeasureText(item.Text, item.Font).Width, itemBounds.Width), 123int textWidth = TextRenderer.MeasureText(item.Text, item.Font).Width; 128textWidth = Math.Max(TextRenderer.MeasureText(subItem.Text, subItem.Font).Width, textWidth);
System\Windows\Forms\Controls\PropertyGrid\PropertyGrid.MeasureTextHelper.cs (2)
24: TextRenderer.MeasureText( 34: TextRenderer.MeasureText(
System\Windows\Forms\Controls\PropertyGrid\PropertyGridInternal\GridEntry.cs (2)
1608TextRenderer.DrawText(g, label, font, textRect, textColor, PropertyGrid.MeasureTextHelper.GetTextRendererFlags()); 1937TextRenderer.DrawTextInternal(
System\Windows\Forms\Controls\TabControl\TabRenderer.cs (2)
80TextRenderer.DrawText(g, tabItemText, font, contentBounds, textColor, flags); 131TextRenderer.DrawText(g, tabItemText, font, contentBounds, textColor, flags);
System\Windows\Forms\Controls\TextBox\TextBox.cs (2)
910TextRenderer.DrawTextInternal(hdc, PlaceholderText, Font, rectangle, SystemColors.GrayText, TextRenderer.DefaultQuality, flags);
System\Windows\Forms\Controls\TextBox\TextBoxBase.cs (1)
850Size textSize = TextRenderer.MeasureText(Text, Font, proposedConstraints, format);
System\Windows\Forms\Controls\TextBox\TextBoxRenderer.cs (1)
84TextRenderer.DrawText(g, textBoxText, font, textBounds, textColor, flags);
System\Windows\Forms\Controls\ToolStrips\ToolStripDropDownMenu.cs (1)
295_tabWidth = TextRenderer.MeasureText("\t", Font).Width;
System\Windows\Forms\Controls\ToolStrips\ToolStripItem.cs (1)
2359_cachedTextSize = TextRenderer.MeasureText(Text, Font);
System\Windows\Forms\Controls\ToolStrips\ToolStripMenuItem.cs (1)
734_cachedShortcutSize = TextRenderer.MeasureText(shortcutString, Font);
System\Windows\Forms\Controls\ToolStrips\ToolStripRenderer.cs (2)
882TextRenderer.DrawText(textGraphics, text, textFont, new Rectangle(Point.Empty, textSize), textColor, textFormat); 888TextRenderer.DrawText(g, text, textFont, textRect, textColor, textFormat);
System\Windows\Forms\Controls\TreeView\TreeView.cs (3)
2828Size textSize = TextRenderer.MeasureText(node.Text, node.TreeView!.Font); 2848TextRenderer.DrawText(g, node.Text, font, bounds, color, TextFormatFlags.Default); 2855TextRenderer.DrawText(g, node.Text, font, bounds, color, TextFormatFlags.Default);
System\Windows\Forms\Controls\UpDown\NumericUpDown.cs (3)
813int textWidth = TextRenderer.MeasureText(GetNumberText(testNumber), Font).Width; 821int shortTextWidth = TextRenderer.MeasureText(shortText, Font).Width; 850Size digitSize = TextRenderer.MeasureText(charSpan, Font);
System\Windows\Forms\Dialogs\ThreadExceptionDialog.cs (1)
205textSize = Size.Ceiling(TextRenderer.MeasureText(messageText, Font, textSize, TextFormatFlags.WordBreak));
System\Windows\Forms\Layout\LayoutUtils.cs (1)
50Size textSize = TextRenderer.MeasureText(obj.ToString(), font, new Size(short.MaxValue, short.MaxValue), TextFormatFlags.SingleLine);
System\Windows\Forms\Layout\LayoutUtils.MeasureTextCache.cs (2)
78Size prefSize = TextRenderer.MeasureText(text, font, proposedConstraints, flags); 116_unconstrainedPreferredSize = TextRenderer.MeasureText(text, font, s_maxSize, flags);
System\Windows\Forms\Rendering\ControlPaint.cs (5)
1987FONT_QUALITY quality = TextRenderer.FontQualityFromTextRenderingHint(dc); 1989using DeviceContextHdcScope hdc = dc.ToHdcScope(TextRenderer.GetApplyStateFlags(dc, format)); 2004TextRenderer.DrawTextInternal(dc, s, font, layoutRectangle, SystemColors.GrayText, quality, format); 2011TextRenderer.DrawTextInternal(dc, s, font, layoutRectangle, paintcolor, quality, format); 2014TextRenderer.DrawTextInternal(dc, s, font, layoutRectangle, paintcolor, quality, format);
System\Windows\Forms\Rendering\TextRenderer.cs (1)
394/// <see cref="TextRenderer"/> is to add padding to the bounding rectangle of the drawn text to accommodate
System\Windows\Forms\ToolTip\DrawToolTipEventArgs.cs (1)
93TextRenderer.DrawText(Graphics, ToolTipText, Font, Bounds, _foreColor, flags);
System.Windows.Forms.Design (5)
System\ComponentModel\Design\CollectionEditor.SplitButton.cs (2)
62if (_showSplit && !string.IsNullOrEmpty(Text) && TextRenderer.MeasureText(Text, Font).Width + PushButtonWidth > preferredSize.Width) 233TextRenderer.DrawText(pevent, Text, Font, bounds, SystemColors.ControlText, formatFlags);
System\Windows\Forms\Design\DataGridViewColumnCollectionDialog.cs (1)
1162int itemWidth = TextRenderer.MeasureText(_selectedColumns.Items[i].ToString(), _selectedColumns.Font).Width;
System\Windows\Forms\Design\DesignBindingPicker.cs (1)
1863TextRenderer.DrawText(e.Graphics, Text, Font, rect, ForeColor, formatFlags);
System\Windows\Forms\Design\SplitterPanelDesigner.cs (1)
194TextRenderer.DrawText(g, name, drawFont, new Point(watermarkX, watermarkY), waterMarkTextColor, TextFormatFlags.PreserveGraphicsClipping | TextFormatFlags.PreserveGraphicsTranslateTransform);
System.Windows.Forms.Tests (96)
System\Windows\Forms\ButtonTests.cs (13)
599Size newSize = TextRenderer.MeasureText(control.Text, control.Font); 696Size oldSize = TextRenderer.MeasureText(control.Text, control.Font); 700Size newSize = TextRenderer.MeasureText(control.Text, font); 951Size oldSize = TextRenderer.MeasureText(control.Text, control.Font); 955Size newSize = TextRenderer.MeasureText("NewText", control.Font); 1338Size minSize = TextRenderer.MeasureText(control.Text, control.Font); 1362Size minSize = TextRenderer.MeasureText(control.Text, control.Font); 1634Size minSize = TextRenderer.MeasureText(control.Text, control.Font); 1658Size minSize = TextRenderer.MeasureText(control.Text, control.Font); 1682Size minSize = TextRenderer.MeasureText(control.Text, control.Font); 1706Size minSize = TextRenderer.MeasureText(control.Text, control.Font); 1730Size minSize = TextRenderer.MeasureText(control.Text, control.Font); 1754Size minSize = TextRenderer.MeasureText(control.Text, control.Font);
System\Windows\Forms\ListViewItem.IKeyboardToolTipTests.cs (2)
184? TextRenderer.MeasureText(listViewItem.Text, listViewItem.Font).Width 200? TextRenderer.MeasureText(listViewSubItem.Text, listViewSubItem.Font).Width
System\Windows\Forms\TextRendererTests.cs (78)
38TextRenderer.DrawText(graphics, text, font, pt, foreColor); 41TextRenderer.DrawText(graphics, text, font, pt, foreColor); 72TextRenderer.DrawText(graphics, text, font, pt, foreColor, backColor); 75TextRenderer.DrawText(graphics, text, font, pt, foreColor, backColor); 109TextRenderer.DrawText(graphics, text, font, pt, foreColor, flags); 112TextRenderer.DrawText(graphics, text, font, pt, foreColor, flags); 150TextRenderer.DrawText(graphics, text, font, pt, foreColor, backColor, flags); 153TextRenderer.DrawText(graphics, text, font, pt, foreColor, backColor, flags); 182TextRenderer.DrawText(graphics, text, font, bounds, foreColor); 185TextRenderer.DrawText(graphics, text, font, bounds, foreColor); 218TextRenderer.DrawText(graphics, text, font, rectangle, foreColor, backColor); 221TextRenderer.DrawText(graphics, text, font, rectangle, foreColor, backColor); 258TextRenderer.DrawText(graphics, text, font, rectangle, foreColor, flags); 261TextRenderer.DrawText(graphics, text, font, rectangle, foreColor, flags); 302TextRenderer.DrawText(graphics, text, font, rectangle, foreColor, backColor, flags); 305TextRenderer.DrawText(graphics, text, font, rectangle, foreColor, backColor, flags); 323TextRenderer.DrawText(mockDeviceContext.Object, "text", SystemFonts.MenuFont, Point.Empty, Color.Red); 327TextRenderer.DrawText(mockDeviceContext.Object, "text", SystemFonts.MenuFont, Point.Empty, Color.Red, Color.Blue); 331TextRenderer.DrawText(mockDeviceContext.Object, "text", SystemFonts.MenuFont, Point.Empty, Color.Red, TextFormatFlags.Default); 335TextRenderer.DrawText(mockDeviceContext.Object, "text", SystemFonts.MenuFont, Point.Empty, Color.Red, Color.Blue, TextFormatFlags.Default); 339TextRenderer.DrawText(mockDeviceContext.Object, "text", SystemFonts.MenuFont, new Rectangle(1, 2, 300, 400), Color.Red); 343TextRenderer.DrawText(mockDeviceContext.Object, "text", SystemFonts.MenuFont, new Rectangle(1, 2, 300, 400), Color.Red, TextFormatFlags.Default); 347TextRenderer.DrawText(mockDeviceContext.Object, "text", SystemFonts.MenuFont, new Rectangle(1, 2, 300, 400), Color.Red, Color.Blue); 351TextRenderer.DrawText(mockDeviceContext.Object, "text", SystemFonts.MenuFont, new Rectangle(1, 2, 300, 400), Color.Red, Color.Blue, TextFormatFlags.Default); 355TextRenderer.DrawText(mockDeviceContext.Object, "text".AsSpan(), SystemFonts.MenuFont, Point.Empty, Color.Red); 359TextRenderer.DrawText(mockDeviceContext.Object, "text".AsSpan(), SystemFonts.MenuFont, Point.Empty, Color.Red, Color.Blue); 363TextRenderer.DrawText(mockDeviceContext.Object, "text".AsSpan(), SystemFonts.MenuFont, Point.Empty, Color.Red, TextFormatFlags.Default); 367TextRenderer.DrawText(mockDeviceContext.Object, "text".AsSpan(), SystemFonts.MenuFont, Point.Empty, Color.Red, Color.Blue, TextFormatFlags.Default); 371TextRenderer.DrawText(mockDeviceContext.Object, "text".AsSpan(), SystemFonts.MenuFont, new Rectangle(1, 2, 300, 400), Color.Red); 375TextRenderer.DrawText(mockDeviceContext.Object, "text".AsSpan(), SystemFonts.MenuFont, new Rectangle(1, 2, 300, 400), Color.Red, TextFormatFlags.Default); 379TextRenderer.DrawText(mockDeviceContext.Object, "text".AsSpan(), SystemFonts.MenuFont, new Rectangle(1, 2, 300, 400), Color.Red, Color.Blue); 383TextRenderer.DrawText(mockDeviceContext.Object, "text".AsSpan(), SystemFonts.MenuFont, new Rectangle(1, 2, 300, 400), Color.Red, Color.Blue, TextFormatFlags.Default); 391Assert.Throws<ArgumentNullException>("dc", () => TextRenderer.DrawText(null, "text", SystemFonts.MenuFont, Point.Empty, Color.Red)); 404Size result = TextRenderer.MeasureText(text, font); 409Assert.Equal(result, TextRenderer.MeasureText(text, font)); 428Size result = TextRenderer.MeasureText(text, font, proposedSize); 433Assert.Equal(result, TextRenderer.MeasureText(text, font, proposedSize)); 460Size result = TextRenderer.MeasureText(text, font, proposedSize, flags); 465Assert.Equal(result, TextRenderer.MeasureText(text, font, proposedSize, flags)); 475Size result = TextRenderer.MeasureText(graphics, text, font); 480Assert.Equal(result, TextRenderer.MeasureText(graphics, text, font)); 490Size result = TextRenderer.MeasureText(graphics, text, font, proposedSize); 495Assert.Equal(result, TextRenderer.MeasureText(graphics, text, font, proposedSize)); 505Size result = TextRenderer.MeasureText(graphics, text, font, proposedSize, flags); 510Assert.Equal(result, TextRenderer.MeasureText(graphics, text, font, proposedSize, flags)); 519Assert.Equal(Size.Empty, TextRenderer.MeasureText(text, SystemFonts.MenuFont)); 520Assert.Equal(Size.Empty, TextRenderer.MeasureText(text, SystemFonts.MenuFont, new Size(300, 400))); 521Assert.Equal(Size.Empty, TextRenderer.MeasureText(text, SystemFonts.MenuFont, new Size(300, 400), TextFormatFlags.Default)); 522Assert.Equal(Size.Empty, TextRenderer.MeasureText(graphics, text, SystemFonts.MenuFont)); 523Assert.Equal(Size.Empty, TextRenderer.MeasureText(graphics, text, SystemFonts.MenuFont, new Size(300, 400))); 524Assert.Equal(Size.Empty, TextRenderer.MeasureText(graphics, text, SystemFonts.MenuFont, new Size(300, 400), TextFormatFlags.Default)); 525Assert.Equal(Size.Empty, TextRenderer.MeasureText(text.AsSpan(), SystemFonts.MenuFont)); 526Assert.Equal(Size.Empty, TextRenderer.MeasureText(text.AsSpan(), SystemFonts.MenuFont, new Size(300, 400))); 527Assert.Equal(Size.Empty, TextRenderer.MeasureText(text.AsSpan(), SystemFonts.MenuFont, new Size(300, 400), TextFormatFlags.Default)); 528Assert.Equal(Size.Empty, TextRenderer.MeasureText(graphics, text.AsSpan(), SystemFonts.MenuFont)); 529Assert.Equal(Size.Empty, TextRenderer.MeasureText(graphics, text.AsSpan(), SystemFonts.MenuFont, new Size(300, 400))); 530Assert.Equal(Size.Empty, TextRenderer.MeasureText(graphics, text.AsSpan(), SystemFonts.MenuFont, new Size(300, 400), TextFormatFlags.Default)); 548TextRenderer.MeasureText(mockDeviceContext.Object, "text", SystemFonts.MenuFont); 552TextRenderer.MeasureText(mockDeviceContext.Object, "text", SystemFonts.MenuFont, new Size(300, 400)); 556TextRenderer.MeasureText(mockDeviceContext.Object, "text", SystemFonts.MenuFont, new Size(300, 400), TextFormatFlags.Default); 564Assert.Throws<ArgumentNullException>("dc", () => TextRenderer.MeasureText(null, string.Empty, SystemFonts.MenuFont)); 565Assert.Throws<ArgumentNullException>("dc", () => TextRenderer.MeasureText(null, string.Empty, SystemFonts.MenuFont, new Size(300, 400))); 566Assert.Throws<ArgumentNullException>("dc", () => TextRenderer.MeasureText(null, string.Empty, SystemFonts.MenuFont, new Size(300, 400), TextFormatFlags.Default)); 591TextRenderer.DrawText(context, "Acrylic", SystemFonts.DefaultFont, 594TextRenderer.DrawText(context, "Acrylic", SystemFonts.DefaultFont, 597TextRenderer.DrawText(context, "Acrylic", SystemFonts.DefaultFont, 600TextRenderer.DrawText(context, "Acrylic", SystemFonts.DefaultFont, 615() => TextRenderer.DrawText( 622() => TextRenderer.DrawText( 630() => TextRenderer.DrawText( 637() => TextRenderer.DrawText( 645() => TextRenderer.MeasureText( 651() => TextRenderer.MeasureText( 673TextRenderer.DrawText( 696TextRenderer.DrawText( 727Size size = TextRenderer.MeasureText( 766TextRenderer.DrawText( 814Size size = TextRenderer.MeasureText(
TextBoxBaseTests.cs (3)
5085int width = TextRenderer.MeasureText(control.Text, control.Font).Width; 5105int width = TextRenderer.MeasureText(control.Text, control.Font).Width; 5128int width = TextRenderer.MeasureText(control.Text, control.Font, Size.Empty, TextFormatFlags.SingleLine).Width;