System\Windows\Forms\Controls\ComboBox\ComboBox.cs (5)
404=> new Size(121, PreferredHeight);
728set => base.MaximumSize = new Size(value.Width, 0);
734set => base.MinimumSize = new Size(value.Width, 0);
869Size textSize = TextRenderer.MeasureText(LayoutUtils.TestString, Font, new Size(short.MaxValue, (int)(FontHeight * 1.25)), TextFormatFlags.SingleLine);
880Size textSize = TextRenderer.MeasureText(LayoutUtils.TestString, Font, new Size(short.MaxValue, (int)(FontHeight * 1.25)), TextFormatFlags.SingleLine);
System\Windows\Forms\Controls\DataGridView\DataGridViewCell.cs (14)
1276ScaleHelper.GetIconResourceAsBitmap(typeof(DataGridViewCell), bitmapName, new Size(s_iconsWidth, s_iconsHeight));
2291return GetPreferredSize(screen, dataGridViewCellStyle, rowIndex, new Size(width, 0)).Height;
2298return new Size(-1, -1);
2310Size constraintSize) => new(-1, -1);
2346return GetPreferredSize(screen, dataGridViewCellStyle, rowIndex, new Size(0, height)).Width;
2353return new Size(-1, -1);
2363return new Size(OwningColumn.Thickness, OwningRow.GetHeight(rowIndex));
2553Size requiredSize = TextRenderer.MeasureText(text, font, new Size(maxWidth, int.MaxValue), flags);
2577return new Size(0, 0);
2592textSize = TextRenderer.MeasureText(text, font, new Size((int)maxWidth, int.MaxValue), flags);
2621return TextRenderer.MeasureText(text, font, new Size(int.MaxValue, int.MaxValue), flags);
2648textSize = TextRenderer.MeasureText(text, font, new Size((int)maxWidth, maxHeight), flags);
3777editingControl.Size = new Size(editingControlBounds.Width, editingControlBounds.Height);
3863DataGridView.EditingPanel.Size = new Size(wEditingPanel, hEditingPanel);
System\Windows\Forms\Controls\DataGridView\DataGridViewImageCell.cs (10)
403return new Size(-1, -1);
435preferredSize = new Size(0, Math.Min(img.Height, decimal.ToInt32((decimal)img.Height * imgWidthAllowed / img.Width)));
447preferredSize = new Size(0, Math.Min(ico.Height, decimal.ToInt32((decimal)ico.Height * icoWidthAllowed / ico.Width)));
453preferredSize = new Size(0, 1);
470preferredSize = new Size(Math.Min(img.Width, decimal.ToInt32((decimal)img.Width * imgHeightAllowed / img.Height)), 0);
482preferredSize = new Size(Math.Min(ico.Width, decimal.ToInt32((decimal)ico.Width * icoHeightAllowed / ico.Height)), 0);
488preferredSize = new Size(1, 0);
495preferredSize = new Size(img.Width, img.Height);
499preferredSize = new Size(ico.Width, ico.Height);
503preferredSize = new Size(1, 1);
System\Windows\Forms\Controls\PropertyGrid\PropertyGridInternal\GridErrorDialog.cs (11)
130Size = new(208, 43),
138Size = new(64, 64),
151Size = new(100, 23),
163Size = new(75, 23),
176Size = new(75, 23),
190Size = new(290, 29),
213Size = new(284, 73),
230Size = new(290, 108),
231MinimumSize = new(279, 50),
255Size = new(273, 100),
269ClientSize = new(299, 113);
System\Windows\Forms\Controls\PropertyGrid\PropertyGridInternal\PropertyGridView.cs (10)
230? new(SystemInformation.VerticalScrollBarArrowHeightForDpi(DeviceDpiInternal), RowHeight)
231: new(SystemInformation.VerticalScrollBarArrowHeight, RowHeight);
277? new Size(SystemInformation.VerticalScrollBarArrowHeightForDpi(DeviceDpiInternal), RowHeight)
278: new Size(SystemInformation.VerticalScrollBarArrowHeight, RowHeight);
961Size size = new(width, height);
1997Size sizeWindow = new(rect.Width, rect.Height);
4369? new Size(SystemInformation.VerticalScrollBarArrowHeightForDpi(DeviceDpiInternal), RowHeight)
4370: new Size(SystemInformation.VerticalScrollBarArrowHeight, RowHeight);
5182_dropDownButton.Size = new(SystemInformation.VerticalScrollBarArrowHeightForDpi(DeviceDpiInternal), RowHeight);
5186_dropDownButton.Size = new(SystemInformation.VerticalScrollBarArrowHeight, RowHeight);
System\Windows\Forms\Controls\UpDown\UpDownBase.cs (8)
76_upDownButtons.Size = new Size(_defaultButtonsWidth, PreferredHeight);
270protected override Size DefaultSize => new(DefaultControlWidth, PreferredHeight);
310set => base.MaximumSize = new Size(value.Width, 0);
316set => base.MinimumSize = new Size(value.Width, 0);
963upDownEditBounds.Size = new Size(clientArea.Width - _defaultButtonsWidth, clientArea.Height);
1029: SizeFromClientSizeInternal(new(textWidth, height)).Width + _upDownButtons.Width;
1142bodyPath.AddRoundedRectangle(deflatedBounds, new Size(cornerRadius, cornerRadius));
1152new Size(cornerRadius, cornerRadius),
System\Windows\Forms\Form.cs (6)
448return new Size((int)Math.Round(real.Width), (int)Math.Round(real.Height));
885protected override Size DefaultSize => new Size(300, 300);
1239Size = new Size(Math.Min(size.Width, value.Width), Math.Min(size.Height, value.Height));
1356Size = new Size(Math.Max(size.Width, value.Width), Math.Max(size.Height, value.Height));
3047Size newVar = new((int)Math.Round(newVarF.Width), (int)Math.Round(newVarF.Height));
4536_dpiFormSizes.Add(e.DeviceDpiNew, new Size(e.SuggestedRectangle.Width, e.SuggestedRectangle.Height));
System\Windows\Forms\Layout\CommonProperties.cs (6)
32internal static Size DefaultMinimumSize { get; } = new(0, 0);
33internal static Size DefaultMaximumSize { get; } = new(0, 0);
200Debug.Assert(value != GetMaximumSize(element, new Size(-7109, -7107)),
214Debug.Assert(GetMaximumSize(element, new Size(-7109, -7107)) == value, "Error detected setting MaximumSize.");
222Debug.Assert(value != GetMinimumSize(element, new Size(-7109, -7107)),
236Debug.Assert(GetMinimumSize(element, new Size(-7109, -7107)) == value, "Error detected setting MinimumSize.");
System\Windows\Forms\Layout\Containers\SplitContainer.cs (15)
328return new Size(150, 100);
1610Panel1.Size = new Size(0, Panel1.Height);
1611Panel2.Size = new Size(0, Panel2.Height);
1616Panel1.Size = new Size(Panel1.Width, 0);
1617Panel2.Size = new Size(Panel2.Width, 0);
1628Panel1.Size = new Size(_panelSize, Height);
1629Panel2.Size = new Size(Math.Max(Width - _panelSize - SplitterWidthInternal, Panel2MinSize), Height);
1634Panel2.Size = new Size(_panelSize, Height);
1649Panel2.Size = new Size(Math.Max(Width - _splitterDistance - SplitterWidthInternal, Panel2MinSize), Height);
1686Panel1.Size = new Size(Width, _panelSize);
1688Panel2.Size = new Size(Width, Math.Max(Height - panel2Start, Panel2MinSize));
1694Panel2.Size = new Size(Width, _panelSize);
1713Panel2.Size = new Size(Width, Math.Max(Height - panel2Start, Panel2MinSize));
2187Panel2.Size = new Size(Width - _splitterDistance - SplitterWidthInternal, Height);
2237Panel2.Size = new Size(Width, Height - panel2Start);
System\Windows\Forms\Layout\TableLayout.cs (7)
105Size containerSize = container.DisplayRectangle.Size - new Size(cellBorderWidth, cellBorderWidth);
119CommonProperties.SetLayoutBounds(containerInfo.Container, new Size(SumStrips(containerInfo.Columns, 0, containerInfo.Columns.Length),
162Size containerSize = container.DisplayRectangle.Size - new Size(cellBorderWidth * 2, cellBorderWidth * 2);
176Size cellBorderSize = new(cellBorderWidth, cellBorderWidth);
726minWidth = GetElementSize(element, new Size(0, constrainingHeight)).Width;
731minWidth = GetElementSize(element, new Size(1, 0)).Width;
856int minHeight = GetElementSize(element, new Size(currentWidth - margin.Horizontal, 0)).Height + margin.Vertical;
System\Windows\Forms\Printing\PrintPreviewControl.cs (7)
34private Size _virtualSize = new(1, 1);
61Size = new Size(100, 100);
512_imageSize = new Size((int)(_zoom * pageSize.Width), (int)(_zoom * pageSize.Height));
515SetVirtualSizeNoInvalidate(PhysicalToPixels(new Size(virtualX, virtualY), _screenDPI));
682_imageSize = new Size((int)(_zoom * pageSize.Width), (int)(_zoom * pageSize.Height));
776new(PixelsToPhysical(pixels.Width, dpi.X), PixelsToPhysical(pixels.Height, dpi.Y));
782new(PhysicalToPixels(physical.Width, dpi.X), PhysicalToPixels(physical.Height, dpi.Y));
System\Windows\Forms\Rendering\ModernControlVisualStyles.cs (1)
132=> new(
System\Windows\Forms\SystemVisualSettingsTracker.cs (1)
149new Size(
System\Windows\Forms\Control.cs (44)
378Size defaultSize = DefaultSize;
1456public Size ClientSize
1857protected virtual Size DefaultMaximumSize => CommonProperties.DefaultMaximumSize;
1859protected virtual Size DefaultMinimumSize => CommonProperties.DefaultMinimumSize;
1869protected virtual Size DefaultSize => Size.Empty;
2324public virtual Size GetPreferredSize(Size proposedSize)
2340Size cachedSize = CommonProperties.xGetPreferredSizeCache(this);
2349Size preferredSize;
2376internal virtual Size GetPreferredSizeCore(Size proposedSize)
2742[AmbientValue(typeof(Size), "0, 0")]
2743public virtual Size MaximumSize
2748if (value == Size.Empty)
2765public virtual Size MinimumSize
3286public Size Size
4028public Size PreferredSize
4030get { return GetPreferredSize(Size.Empty); }
5495internal Size ApplySizeConstraints(int width, int height)
5502internal Size ApplySizeConstraints(Size proposedSize)
5512if (MaximumSize != Size.Empty || MinimumSize != Size.Empty)
5514Size maximumSize = LayoutUtils.ConvertZeroToUnbounded(MaximumSize);
6674public Size LogicalToDeviceUnits(Size value) => ScaleHelper.ScaleToDpi(value, DeviceDpi);
10589Size minSize = MinimumSize;
10590Size maxSize = MaximumSize;
10593MinimumSize = Size.Empty;
10594MaximumSize = Size.Empty;
10636Size adornmentSize = adornments.Size;
10641LayoutUtils.UnionSizes(Size.Empty, minSize), // make sure we don't go below 0.
10650LayoutUtils.UnionSizes(Size.Empty, maxSize), // make sure we don't go below 0.
10657Size maximumSize = LayoutUtils.ConvertZeroToUnbounded(maxSize);
10658Size scaledSize = LayoutUtils.IntersectSizes(rawScaledBounds.Size, maximumSize);
10715internal Size ScaleSize(Size startSize, float x, float y)
10717Size size = startSize;
11027protected virtual Size SizeFromClientSize(Size clientSize) => SizeFromClientSizeInternal(clientSize);
11029internal Size SizeFromClientSizeInternal(Size size)
11549Size s = DefaultSize;
System\Windows\Forms\Controls\Buttons\ButtonInternal\ButtonBaseAdapter.LayoutOptions.cs (37)
38public Size ImageSize { get; set; }
125private Size Compose(Size checkSize, Size imageSize, Size textSize)
156private Size Decompose(Size checkSize, Size imageSize, Size proposedSize)
195internal Size GetPreferredSizeCore(Size proposedSize)
204Size bordersAndPadding = new(linearBorderAndPadding, linearBorderAndPadding);
209Size checkSize = checkSizeLinear > 0 ? new(checkSizeLinear + 1, checkSizeLinear) : Size.Empty;
212Size textImageInsetSize = new(TextImageInset * 2, TextImageInset * 2);
213Size requiredImageSize = (ImageSize != Size.Empty) ? ImageSize + textImageInsetSize : Size.Empty;
219Size textSize = Size.Empty;
241Size requiredSize = Compose(checkSize, ImageSize, textSize);
242if (EnsureImagePreferredSizeInset && ImageSize != Size.Empty)
244Size imageRequiredSize = Compose(checkSize, requiredImageSize, Size.Empty);
301layout.Focus = ImageSize != Size.Empty
505if (ImageSize == Size.Empty || Text is null || Text.Length == 0 || textImageRelation == TextImageRelation.Overlay)
508Size textSize = GetTextSize(maxBounds.Size);
511Size size = ImageSize;
512if (layout.Options.DotNetOneButtonCompat && ImageSize != Size.Empty)
523Size maxTextSize = LayoutUtils.SubAlignedRegion(maxBounds.Size, ImageSize, textImageRelation);
524Size textSize = GetTextSize(maxTextSize);
528Size combinedSize = LayoutUtils.AddAlignedRegion(textSize, ImageSize, textImageRelation);
674protected virtual Size GetTextSize(Size proposedSize)
678Size textSize = Size.Empty;
685textSize = Size.Ceiling(
System\Windows\Forms\Controls\DataGridView\DataGridViewCell.cs (17)
414public Size PreferredSize => GetPreferredSize(RowIndex);
583public Size Size => GetSize(RowIndex);
1682internal static DataGridViewFreeDimension GetFreeDimensionFromConstraint(Size constraintSize)
2294internal Size GetPreferredSize(int rowIndex)
2303return GetPreferredSize(screen, dataGridViewCellStyle, rowIndex, Size.Empty);
2306protected virtual Size GetPreferredSize(
2310Size constraintSize) => new(-1, -1);
2329Size size = MeasureTextSize(g, text, cellStyle.Font!, flags);
2349protected virtual Size GetSize(int rowIndex)
2553Size requiredSize = TextRenderer.MeasureText(text, font, new Size(maxWidth, int.MaxValue), flags);
2559public static Size MeasureTextPreferredSize(
2580Size textOneLineSize = MeasureTextSize(graphics, text, font, flags);
2588Size textSize;
2605public static Size MeasureTextSize(
2634Size oneLineSize = MeasureTextSize(graphics, text, font, flags);
2644Size textSize;
3959internal static bool TextFitsInBounds(Graphics graphics, string text, Font font, Size maxBounds, TextFormatFlags flags)
System\Windows\Forms\Controls\DataGridView\DataGridViewUtilities.cs (7)
150internal static Size GetPreferredRowHeaderSize(
158Size constraintSize,
161Size preferredSize;
322Size sizeRequired = TextRenderer.MeasureText(text, font, new Size(int.MaxValue, int.MaxValue), flags);
329Size sizeCell = new(cellBounds.Width, cellBounds.Height);
330Size sizeConstraint = TextRenderer.MeasureText(text, font, sizeCell, flags);
351Size sizeText,
System\Windows\Forms\Controls\MonthCalendar\MonthCalendar.cs (14)
84private static readonly Size s_defaultSingleMonthSize = new(176, 153);
98private Size _dimensions = new(1, 1);
267public Size CalendarDimensions
322protected override Size DefaultSize => GetMinReqRect();
791public Size SingleMonthSize
817public new Size Size
1075Size minSize = GetMinReqRect();
1172private Size GetMinReqRect() => GetMinReqRect(0, false, false);
1180private Size GetMinReqRect(int newDimensionLength, bool updateRows, bool updateCols)
1182Size minSize = SingleMonthSize;
1185Size textExtent;
1273Size preferredSize = GetMinReqRect(height, updateRows, false);
1283Size preferredSize = GetMinReqRect(width, false, updateCols);
1651Size max = SystemInformation.MaxWindowTrackSize;
System\Windows\Forms\Controls\ToolStrips\ToolStripItem.ToolStripItemInternalLayout.ToolStripLayoutData.cs (1)
16private Size _size;
System\Windows\Forms\Controls\ToolStrips\ToolStripSettingsManager.SettingsStub.cs (1)
18public Size Size;
System\Windows\Forms\Form.cs (53)
152private Size _autoScaleBaseSize = Size.Empty;
153private Size _minAutoSize = Size.Empty;
169private Dictionary<int, Size>? _dpiFormSizes;
439public virtual Size AutoScaleBaseSize
501_minAutoSize = Size.Empty;
668Size size = ClientSize;
730public new Size ClientSize
885protected override Size DefaultSize => new Size(300, 300);
1186[DefaultValue(typeof(Size), "0, 0")]
1187public override Size MaximumSize
1189get => Properties.TryGetValue(s_propMaxTrackSize, out Size maximumSize) ? maximumSize : Size.Empty;
1204private void UpdateMaximumSize(Size value, bool updateFormSize = true)
1211Size minimumSize = MinimumSize;
1236Size size = Size;
1300public override Size MinimumSize
1302get => Properties.TryGetValue(s_propMinTrackSize, out Size minimumSize) ? minimumSize : DefaultMinimumSize;
1321private void UpdateMinimumSize(Size value, bool updateFormSize = true)
1328Size maximumSize = MaximumSize;
1353Size size = Size;
1908public new Size Size
3045Size baseVar = AutoScaleBaseSize;
3047Size newVar = new((int)Math.Round(newVarF.Width), (int)Math.Round(newVarF.Height));
3079Size correctClientSize = ClientSize;
3118Size correct = ComputeWindowSize(correctClientSize);
3268private Size ComputeWindowSize(Size clientSize)
3278private Size ComputeWindowSize(Size clientSize, WINDOW_STYLE style, WINDOW_EX_STYLE exStyle)
3674Size correct = ComputeWindowSize(ClientSize, (WINDOW_STYLE)maskedStyle, (WINDOW_EX_STYLE)cp.ExStyle);
3911Size s = Size;
4266Size prefSize = PreferredSize;
4271Size adjustedSize = AutoSizeMode == AutoSizeMode.GrowAndShrink ? prefSize : LayoutUtils.UnionSizes(prefSize, Size);
4459Size size = ClientSize;
4590protected virtual bool OnGetDpiScaledSize(int deviceDpiOld, int deviceDpiNew, ref Size desiredSize)
4661Size desiredSize = default;
5143Size restoredSize = _restoredWindowBounds.Size;
5218Size clientSize = ClientSize;
5248Size minSize = MinimumSize;
5249Size maxSize = MaximumSize;
5363Size max = SystemInformation.MaxWindowTrackSize;
5383Size min = SystemInformation.MinWindowTrackSize;
6097_autoScaleBaseSize = Size.Empty;
6304Size previousClientSize = ClientSize;
6930Size minTrack = (AutoSize && _formStateEx[s_formStateExInModalSizingLoop] == 1) ? LayoutUtils.UnionSizes(_minAutoSize, MinimumSize) : MinimumSize;
6932Size maxTrack = MaximumSize;
6946private unsafe void WmGetMinMaxInfoHelper(ref Message m, Size minTrack, Size maxTrack, Rectangle maximizedBounds)
6966Size virtualScreen = SystemInformation.VirtualScreen.Size;
6982Size minTrackWindowSize = SystemInformation.MinWindowTrackSize;
7072Size clientSize = ClientSize;
System\Windows\Forms\Layout\CommonProperties.cs (25)
32internal static Size DefaultMinimumSize { get; } = new(0, 0);
33internal static Size DefaultMaximumSize { get; } = new(0, 0);
97internal static Size GetMaximumSize(IArrangedElement element, Size defaultMaximumSize)
99if (element.Properties.TryGetValue(s_maximumSizeProperty, out Size size))
110internal static Size GetMinimumSize(IArrangedElement element, Size defaultMinimumSize)
112if (element.Properties.TryGetValue(s_minimumSizeProperty, out Size size))
126/// and/or the <see cref="Control.GetPreferredSize(Size)"/> calculation of a control.
198internal static void SetMaximumSize(IArrangedElement element, Size value)
220internal static void SetMinimumSize(IArrangedElement element, Size value)
342/// <see cref="Control.GetPreferredSizeCore(Size)"/> method. DO NOT CALL DIRECTLY
348Debug.Assert(xGetPreferredSizeCache(element) == Size.Empty, "Error detected in xClearPreferredSizeCache.");
372/// <see cref="Control.GetPreferredSizeCore(Size)"/> implementation when asked for a constraining
373/// value of <see cref="LayoutUtils.s_maxSize"/> (or <see cref="Size.Empty"/> too).
375internal static Size xGetPreferredSizeCache(IArrangedElement element)
377if (element.Properties.TryGetValue(s_preferredSizeCacheProperty, out Size size) && (size != LayoutUtils.s_invalidSize))
382return Size.Empty;
388internal static void xSetPreferredSizeCache(IArrangedElement element, Size value)
391value == Size.Empty || value != xGetPreferredSizeCache(element),
674internal static Size GetLayoutBounds(IArrangedElement element)
676if (element.Properties.TryGetValue(s_layoutBoundsProperty, out Size size))
681return Size.Empty;
689/// The <see cref="TableLayout"/> engine now calls <see cref="SetLayoutBounds(IArrangedElement, Size)"/> when it
697internal static void SetLayoutBounds(IArrangedElement element, Size value)
System\Windows\Forms\Layout\DefaultLayout.cs (35)
34Size proposedConstraints = LayoutUtils.s_maxSize;
46Size prefSize = element.GetPreferredSize(proposedConstraints);
59Size newSize = LayoutUtils.UnionSizes(bounds.Size, prefSize);
77private static Rectangle GetGrowthBounds(IArrangedElement element, Size newSize)
378private static Size LayoutDockedControls(IArrangedElement container, bool measureOnly)
385Size preferredSize = Size.Empty;
404Size elementSize = GetVerticalDockedSize(element, remainingBounds.Size, measureOnly);
417Size elementSize = GetVerticalDockedSize(element, remainingBounds.Size, measureOnly);
430Size elementSize = GetHorizontalDockedSize(element, remainingBounds.Size, measureOnly);
443Size elementSize = GetHorizontalDockedSize(element, remainingBounds.Size, measureOnly);
461Size elementSize = remainingBounds.Size;
488private static void TryCalculatePreferredSizeDockedControl(IArrangedElement element, Rectangle newElementBounds, bool measureOnly, ref Size preferredSize, ref Rectangle remainingBounds)
492Size neededSize = new(
514Size elementPrefSize = element.GetPreferredSize(neededSize);
541private static Size GetVerticalDockedSize(IArrangedElement element, Size remainingSize, bool measureOnly)
543Size newSize = xGetDockedSize(element, /* constraints = */ new Size(remainingSize.Width, 1));
558private static Size GetHorizontalDockedSize(IArrangedElement element, Size remainingSize, bool measureOnly)
560Size newSize = xGetDockedSize(element, /* constraints = */ new Size(1, remainingSize.Height));
575private static Size xGetDockedSize(IArrangedElement element, Size constraints)
577Size desiredSize;
596return TryCalculatePreferredSize(container, measureOnly: false, preferredSize: out Size _);
602private static bool TryCalculatePreferredSize(IArrangedElement container, bool measureOnly, out Size preferredSize)
639Size preferredSizeForDocking = Size.Empty;
640Size preferredSizeForAnchoring;
1110internal override Size GetPreferredSize(IArrangedElement container, Size proposedBounds)
1114TryCalculatePreferredSize(container, measureOnly: true, preferredSize: out Size prefSize);
1118private static Size GetAnchorPreferredSize(IArrangedElement container)
1120Size prefSize = Size.Empty;
System\Windows\Forms\Layout\FlowLayout.cs (14)
23internal override Size GetPreferredSize(IArrangedElement container, Size proposedConstraints)
26Size prefSize = TryCalculatePreferredSize(container, measureBounds, measureOnly: true);
53private static Size TryCalculatePreferredSize(IArrangedElement container, Rectangle displayRect, bool measureOnly)
65Size layoutSize = Size.Empty;
77Size rowSize = MeasureRow(containerProxy, elementProxy, i, measureBounds, out int breakIndex);
137private static Size MeasureRow(
156private static Size TryCalculatePreferredSizeRow(
167Size rowSize = Size.Empty;
184Size prefSize;
187Size elementConstraints = new(int.MaxValue, rowBounds.Height - elementProxy.Margin.Size.Height);
218Size requiredSize = prefSize + elementProxy.Margin.Size;
System\Windows\Forms\Layout\LayoutUtils.cs (45)
13public static readonly Size s_maxSize = new(int.MaxValue, int.MaxValue);
14public static readonly Size s_invalidSize = new(int.MinValue, int.MinValue);
43public static Size OldGetLargestStringSizeInCollection(Font? font, ICollection? objects)
45Size largestSize = Size.Empty;
50Size textSize = TextRenderer.MeasureText(obj.ToString(), font, new Size(short.MaxValue, short.MaxValue), TextFormatFlags.SingleLine);
124public static Size ConvertZeroToUnbounded(Size size)
205public static Size UnionSizes(Size a, Size b)
212public static Size IntersectSizes(Size a, Size b)
275public static Rectangle AlignAndStretch(Size fitThis, Rectangle withinThis, AnchorStyles anchorStyles)
280public static Rectangle Align(Size alignThis, Rectangle withinThis, AnchorStyles anchorStyles)
285public static Rectangle Align(Size alignThis, Rectangle withinThis, ContentAlignment align)
290public static Rectangle HAlign(Size alignThis, Rectangle withinThis, AnchorStyles anchorStyles)
306private static Rectangle HAlign(Size alignThis, Rectangle withinThis, ContentAlignment align)
322public static Rectangle VAlign(Size alignThis, Rectangle withinThis, AnchorStyles anchorStyles)
338public static Rectangle VAlign(Size alignThis, Rectangle withinThis, ContentAlignment align)
354public static Size Stretch(Size stretchThis, Size withinThis, AnchorStyles anchorStyles)
356Size stretchedSize = new(
390public static Size AddAlignedRegion(Size textSize, Size imageSize, TextImageRelation relation)
395public static Size AddAlignedRegionCore(Size currentSize, Size contentSize, bool vertical)
453public static Size FlipSize(Size size)
460public static Size FlipSizeIf(bool condition, Size size)
493public static bool IsZeroWidthOrHeight(Size size)
498public static bool AreWidthAndHeightLarger(Size size1, Size size2)
503public static void SplitRegion(Rectangle bounds, Size specifiedContent, AnchorStyles region1Align, out Rectangle region1, out Rectangle region2)
570public static Size SubAlignedRegion(Size currentSize, Size contentSize, TextImageRelation relation)
575public static Size SubAlignedRegionCore(Size currentSize, Size contentSize, bool vertical)
System\Windows\Forms\Layout\LayoutUtils.MeasureTextCache.cs (6)
22private Size _unconstrainedPreferredSize = s_invalidSize;
29public Size GetTextSize(string? text, Font? font, Size proposedConstraints, TextFormatFlags flags)
78Size prefSize = TextRenderer.MeasureText(text, font, proposedConstraints, flags);
99public bool TextRequiresWordBreak(string? text, Font? font, Size size, TextFormatFlags flags)
108private Size GetUnconstrainedSize(string? text, Font? font, TextFormatFlags flags)
System\Windows\Forms\Layout\TableLayout.cs (18)
105Size containerSize = container.DisplayRectangle.Size - new Size(cellBorderWidth, cellBorderWidth);
111Size usedSpace = ApplyStyles(containerInfo, containerSize, measureOnly: false);
135internal override Size GetPreferredSize(IArrangedElement container, Size proposedConstraints)
145Size prefSize = containerInfo.GetCachedPreferredSize(proposedConstraints, out bool isCacheValid);
162Size containerSize = container.DisplayRectangle.Size - new Size(cellBorderWidth * 2, cellBorderWidth * 2);
176Size cellBorderSize = new(cellBorderWidth, cellBorderWidth);
222private static void ExpandLastElement(ContainerInfo containerInfo, Size usedSpace, Size totalSpace)
617private static Size ApplyStyles(ContainerInfo containerInfo, Size proposedConstraints, bool measureOnly)
619Size preferredSize = Size.Empty;
675private static int InflateColumns(ContainerInfo containerInfo, Size proposedConstraints, bool measureOnly)
732maxWidth = GetElementSize(element, Size.Empty).Width;
801private static int InflateRows(ContainerInfo containerInfo, Size proposedConstraints, int expandLastElementWidth, bool measureOnly)
866private static Size GetElementSize(IArrangedElement element, Size proposedConstraints) =>
System\Windows\Forms\Rendering\TextRenderer.cs (38)
23internal static Size MaxSize { get; } = new(int.MaxValue, int.MaxValue);
381public static Size MeasureText(string? text, Font? font)
390/// The <see cref="Size"/>, in pixels, of text drawn on a single line with the specified font. You can
399/// <see cref="MeasureText(IDeviceContext, string?, Font?, Size, TextFormatFlags)"/>.
401public static Size MeasureText(ReadOnlySpan<char> text, Font? font)
404public static Size MeasureText(string? text, Font? font, Size proposedSize)
413/// <param name="proposedSize">The <see cref="Size"/> of the initial bounding rectangle.</param>
415/// The <see cref="Size"/>, in pixels, of <paramref name="text"/> drawn with the specified
418public static Size MeasureText(ReadOnlySpan<char> text, Font? font, Size proposedSize)
421public static Size MeasureText(string? text, Font? font, Size proposedSize, TextFormatFlags flags)
430/// <param name="proposedSize">The <see cref="Size"/> of the initial bounding rectangle.</param>
433/// The <see cref="Size"/>, in pixels, of <paramref name="text"/> drawn with the specified
439public static Size MeasureText(ReadOnlySpan<char> text, Font? font, Size proposedSize, TextFormatFlags flags)
442public static Size MeasureText(IDeviceContext dc, string? text, Font? font)
452/// The <see cref="Size"/>, in pixels, of <paramref name="text"/> drawn with the specified
456public static Size MeasureText(IDeviceContext dc, ReadOnlySpan<char> text, Font? font)
459public static Size MeasureText(IDeviceContext dc, string? text, Font? font, Size proposedSize)
469/// <param name="proposedSize">The <see cref="Size"/> of the initial bounding rectangle.</param>
471/// The <see cref="Size"/>, in pixels, of <paramref name="text"/> drawn with the specified
475public static Size MeasureText(IDeviceContext dc, ReadOnlySpan<char> text, Font? font, Size proposedSize)
478public static Size MeasureText(
482Size proposedSize,
493/// <param name="proposedSize">The <see cref="Size"/> of the initial bounding rectangle.</param>
496/// The <see cref="Size"/>, in pixels, of <paramref name="text"/> drawn with the specified
503public static Size MeasureText(
507Size proposedSize,
511private static Size MeasureTextInternal(
514Size proposedSize,
518return Size.Empty;
526private static Size MeasureTextInternal(
530Size proposedSize,
536return Size.Empty;
System\Windows\Forms\SystemInformation.cs (32)
57public static Size PrimaryMonitorSize => GetSize(SM_CXSCREEN, SM_CYSCREEN);
93public static Size BorderSize => GetSize(SM_CXBORDER, SM_CYBORDER);
98public static Size GetBorderSizeForDpi(int dpi)
109public static Size FixedFrameBorderSize => GetSize(SM_CXFIXEDFRAME, SM_CYFIXEDFRAME);
124public static Size IconSize => GetSize(SM_CXICON, SM_CYICON);
129public static Size CursorSize => GetSize(SM_CXCURSOR, SM_CYCURSOR);
241public static Size MinimumWindowSize => GetSize(SM_CXMIN, SM_CYMIN);
246public static Size CaptionButtonSize => GetSize(SM_CXSIZE, SM_CYSIZE);
251public static Size FrameBorderSize => GetSize(SM_CXFRAME, SM_CYFRAME);
256public static Size MinWindowTrackSize => GetSize(SM_CXMINTRACK, SM_CYMINTRACK);
263public static Size DoubleClickSize => GetSize(SM_CXDOUBLECLK, SM_CYDOUBLECLK);
273public static Size IconSpacingSize => GetSize(SM_CXICONSPACING, SM_CYICONSPACING);
305public static Size Border3DSize => GetSize(SM_CXEDGE, SM_CYEDGE);
310public static Size MinimizedWindowSpacingSize => GetSize(SM_CXMINSPACING, SM_CYMINSPACING);
315public static Size SmallIconSize => GetSize(SM_CXSMICON, SM_CYSMICON);
325public static Size ToolWindowCaptionButtonSize => GetSize(SM_CXSMSIZE, SM_CYSMSIZE);
330public static Size MenuButtonSize => GetSize(SM_CXMENUSIZE, SM_CYMENUSIZE);
366public static Size MinimizedWindowSize => GetSize(SM_CXMINIMIZED, SM_CYMINIMIZED);
372public static Size MaxWindowTrackSize => GetSize(SM_CXMAXTRACK, SM_CYMAXTRACK);
378public static Size PrimaryMonitorMaximizedWindowSize => GetSize(SM_CXMAXIMIZED, SM_CYMAXIMIZED);
396public static Size DragSize => GetSize(SM_CXDRAG, SM_CYDRAG);
408public static Size MenuCheckSize => GetSize(SM_CXMENUCHECK, SM_CYMENUCHECK);
461Size size = PrimaryMonitorSize;
591/// Gets the <see cref="Size"/> in pixels of the rectangle within which the mouse
594public static Size MouseHoverSize
761/// The <see cref="Size"/>, in pixels, of the small caption buttons.
763public static unsafe Size SmallCaptionButtonSize
771: Size.Empty;
776/// The <see cref="Size"/>, in pixels, of the menu bar buttons.
778public static unsafe Size MenuBarButtonSize
786: Size.Empty;
814private static Size GetSize(SYSTEM_METRICS_INDEX x, SYSTEM_METRICS_INDEX y)