Ejemplo n.º 1
0
        internal override Size GetPreferredSizeCore(Size proposedConstraints)
        {
            if (Appearance == Appearance.Button)
            {
                ButtonStandardAdapter adapter = new ButtonStandardAdapter(this);
                return(adapter.GetPreferredSizeCore(proposedConstraints));
            }

            if (FlatStyle != FlatStyle.System)
            {
                return(base.GetPreferredSizeCore(proposedConstraints));
            }

            Size textSize = TextRenderer.MeasureText(this.Text, this.Font);
            Size size     = SizeFromClientSize(textSize);

            size.Width  += 25;
            size.Height += 5;
            return(size + Padding.Size);
        }
Ejemplo n.º 2
0
        internal override Size GetPreferredSizeCore(Size proposedConstraints)
        {
            if (Appearance == Appearance.Button)
            {
                ButtonStandardAdapter adapter = new ButtonStandardAdapter(this);
                return(adapter.GetPreferredSizeCore(proposedConstraints));
            }

            if (FlatStyle != FlatStyle.System)
            {
                return(base.GetPreferredSizeCore(proposedConstraints));
            }

            Size textSize = TextRenderer.MeasureText(this.Text, this.Font);
            Size size     = SizeFromClientSize(textSize);

            size.Width += flatSystemStylePaddingWidth;
            size.Height = DpiHelper.EnableDpiChangedHighDpiImprovements ? Math.Max(size.Height + 5, flatSystemStyleMinimumHeight) : size.Height + 5; // ensure minimum height to avoid truncation of check-box or text
            return(size + Padding.Size);
        }