src/EFTools/EntityDesign/UI/Views/Controls/AutoWrapRadioButton.cs
// <summary>
//     Retrieves the size of a rectangular area into which a control can be fitted.
// </summary>
// <param name="proposedSize">The constraining size; the size for the control should fit into.</param>
Retrieves the size of a rectangular area into which a control can be fitted.
Retrieves the size of a rectangular area into which a control can be fitted .
public override Size GetPreferredSize(Size proposedSize)
        {
            var prefSize = base.GetPreferredSize(proposedSize);
            if (!String.IsNullOrEmpty(Text)
                && prefSize.Width > proposedSize.Width)
            {
                var bordersAndPadding = prefSize - _cachedTextSize;
                var newConstraints = proposedSize - bordersAndPadding;
                if (_preferredSizeHash.ContainsKey(newConstraints))
                {
                    prefSize = _preferredSizeHash[newConstraints];
                }
                else
                {
                    prefSize = bordersAndPadding + TextRenderer.MeasureText(Text, Font, newConstraints, TextFormatFlags.WordBreak);
                    _preferredSizeHash[newConstraints] = prefSize;
                }
            }
            return prefSize;
        }
public override Size GetPreferredSize ( Size proposedSize ) { var prefSize = base . GetPreferredSize ( proposedSize ) ; if ( ! String . IsNullOrEmpty ( Text ) && prefSize . Width > proposedSize . Width ) { var bordersAndPadding = prefSize - _cachedTextSize ; var newConstraints = proposedSize - bordersAndPadding ; if ( _preferredSizeHash . ContainsKey ( newConstraints ) ) { prefSize = _preferredSizeHash [ newConstraints ] ; } else { prefSize = bordersAndPadding + TextRenderer . MeasureText ( Text , Font , newConstraints , TextFormatFlags . WordBreak ) ; _preferredSizeHash [ newConstraints ] = prefSize ; } } return prefSize ; }
Retrieves the size of a rectangular area into which a control can be fitted.
Retrieves the size of a rectangular area into which a control can be fitted .
// if the actual control size is greater than the constraining size, recalculate the size because there is a possiblility of wrapping.  // calculate the borders and paddings. // calculate the new constraint size for our control. // check the cache first if we have the preferred size given a constraint (TextRenderer.MeasureText could be expensive).
proposedSize
Size
The constraining size; the size for the control should fit into.
The constraining size ; the size for the control should fit into .