internal override Size GetPreferredSizeCore(Size proposedSize) {
            if (Control.Appearance == Appearance.Button) {
				ButtonStandardAdapter adapter = new ButtonStandardAdapter(Control);
                return adapter.GetPreferredSizeCore(proposedSize);
            } 
            else {
                using (Graphics measurementGraphics = WindowsFormsUtils.CreateMeasurementGraphics()) {
                    using (PaintEventArgs pe = new PaintEventArgs(measurementGraphics, new Rectangle())) {
                        LayoutOptions options = Layout(pe);
                        return options.GetPreferredSizeCore(proposedSize);
                    }
                }
            }
        }
 internal override Size GetPreferredSizeCore(Size proposedSize)
 {
     if (Control.Appearance == Appearance.Button)
     {
         ButtonStandardAdapter adapter = new ButtonStandardAdapter(Control);
         return(adapter.GetPreferredSizeCore(proposedSize));
     }
     else
     {
         using (Graphics measurementGraphics = WindowsFormsUtils.CreateMeasurementGraphics()) {
             using (PaintEventArgs pe = new PaintEventArgs(measurementGraphics, new Rectangle())) {
                 LayoutOptions options = Layout(pe);
                 return(options.GetPreferredSizeCore(proposedSize));
             }
         }
     }
 }
 internal override Size GetPreferredSizeCore(Size proposedSize)
 {
     Size preferredSizeCore;
     if (base.Control.Appearance == Appearance.Button)
     {
         ButtonStandardAdapter adapter = new ButtonStandardAdapter(base.Control);
         return adapter.GetPreferredSizeCore(proposedSize);
     }
     using (Graphics graphics = WindowsFormsUtils.CreateMeasurementGraphics())
     {
         using (PaintEventArgs args = new PaintEventArgs(graphics, new Rectangle()))
         {
             preferredSizeCore = this.Layout(args).GetPreferredSizeCore(proposedSize);
         }
     }
     return preferredSizeCore;
 }
Beispiel #4
0
        internal override Size GetPreferredSizeCore(Size proposedSize)
        {
            Size preferredSizeCore;

            if (base.Control.Appearance == Appearance.Button)
            {
                ButtonStandardAdapter adapter = new ButtonStandardAdapter(base.Control);
                return(adapter.GetPreferredSizeCore(proposedSize));
            }
            using (Graphics graphics = WindowsFormsUtils.CreateMeasurementGraphics())
            {
                using (PaintEventArgs args = new PaintEventArgs(graphics, new Rectangle()))
                {
                    preferredSizeCore = this.Layout(args).GetPreferredSizeCore(proposedSize);
                }
            }
            return(preferredSizeCore);
        }
        internal override Size GetPreferredSizeCore(Size proposedSize)
        {
            if (Control.Appearance == Appearance.Button)
            {
                ButtonStandardAdapter adapter = new ButtonStandardAdapter(Control);
                return(adapter.GetPreferredSizeCore(proposedSize));
            }
            else
            {
                LayoutOptions options = default;
                using (var screen = GdiCache.GetScreenHdc())
                    using (PaintEventArgs pe = new PaintEventArgs(screen, new Rectangle()))
                    {
                        options = Layout(pe);
                    }

                return(options.GetPreferredSizeCore(proposedSize));
            }
        }
 internal override Size GetPreferredSizeCore(Size proposedConstraints)
 {
     if (this.Appearance == System.Windows.Forms.Appearance.Button)
     {
         ButtonStandardAdapter adapter = new ButtonStandardAdapter(this);
         return adapter.GetPreferredSizeCore(proposedConstraints);
     }
     if (base.FlatStyle != FlatStyle.System)
     {
         return base.GetPreferredSizeCore(proposedConstraints);
     }
     Size clientSize = TextRenderer.MeasureText(this.Text, this.Font);
     Size size2 = this.SizeFromClientSize(clientSize);
     size2.Width += 0x19;
     size2.Height += 5;
     return (size2 + base.Padding.Size);
 }
Beispiel #7
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;
        }