Пример #1
0
        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));
                    }
                }
            }
        }
        protected override LayoutOptions Layout(PaintEventArgs e)
        {
            LayoutOptions layout = CommonLayout();

            layout.hintTextUp          = false;
            layout.everettButtonCompat = !Application.RenderWithVisualStyles;

            if (Application.RenderWithVisualStyles)
            {
                ButtonBase b = Control;
                using (Graphics g = WindowsFormsUtils.CreateMeasurementGraphics()) {
                    layout.checkSize = RadioButtonRenderer.GetGlyphSize(g, RadioButtonRenderer.ConvertFromButtonState(GetState(), b.MouseIsOver), b.HandleInternal).Width;
                }
            }
            else
            {
                layout.checkSize = (int)(layout.checkSize * GetDpiScaleRatio(e.Graphics));
            }

            return(layout);
        }
        protected override LayoutOptions Layout(PaintEventArgs e)
        {
            LayoutOptions layout = CommonLayout();

            layout.checkPaddingSize    = 1;
            layout.everettButtonCompat = !Application.RenderWithVisualStyles;

            // VSWhidbey 420870
            if (Application.RenderWithVisualStyles)
            {
                using (Graphics g = WindowsFormsUtils.CreateMeasurementGraphics()) {
                    layout.checkSize = CheckBoxRenderer.GetGlyphSize(g, CheckBoxRenderer.ConvertFromButtonState(GetState(), true, Control.MouseIsOver)).Width;
                }
            }
            // Dev10
            else
            {
                layout.checkSize = (int)(layout.checkSize * GetDpiScaleRatio(e.Graphics));
            }

            return(layout);
        }