internal static void DrawCheckBackground(bool controlEnabled, CheckState controlCheckState, Graphics g, Rectangle bounds, Color checkColor, Color checkBackground, bool disabledColors, ButtonBaseAdapter.ColorData colors)
 {
     using (WindowsGraphics graphics = WindowsGraphics.FromGraphics(g))
     {
         WindowsBrush brush;
         if (!controlEnabled && disabledColors)
         {
             brush = new WindowsSolidBrush(graphics.DeviceContext, SystemColors.Control);
         }
         else if (((controlCheckState == CheckState.Indeterminate) && (checkBackground == SystemColors.Window)) && disabledColors)
         {
             Color color = SystemInformation.HighContrast ? SystemColors.ControlDark : SystemColors.Control;
             byte red = (byte) ((color.R + SystemColors.Window.R) / 2);
             byte green = (byte) ((color.G + SystemColors.Window.G) / 2);
             byte blue = (byte) ((color.B + SystemColors.Window.B) / 2);
             brush = new WindowsSolidBrush(graphics.DeviceContext, Color.FromArgb(red, green, blue));
         }
         else
         {
             brush = new WindowsSolidBrush(graphics.DeviceContext, checkBackground);
         }
         try
         {
             graphics.FillRectangle(brush, bounds);
         }
         finally
         {
             if (brush != null)
             {
                 brush.Dispose();
             }
         }
     }
 }
 protected void DrawCheckBackground3DLite(PaintEventArgs e, Rectangle bounds, Color checkColor, Color checkBackground, ButtonBaseAdapter.ColorData colors, bool disabledColors)
 {
     Graphics graphics = e.Graphics;
     Color control = checkBackground;
     if (!this.Control.Enabled && disabledColors)
     {
         control = SystemColors.Control;
     }
     using (Brush brush = new SolidBrush(control))
     {
         using (Pen pen = new Pen(colors.buttonShadow))
         {
             using (Pen pen2 = new Pen(colors.buttonFace))
             {
                 using (Pen pen3 = new Pen(colors.highlight))
                 {
                     bounds.Width--;
                     bounds.Height--;
                     graphics.DrawPie(pen, bounds, 136f, 88f);
                     graphics.DrawPie(pen, bounds, 226f, 88f);
                     graphics.DrawPie(pen3, bounds, 316f, 88f);
                     graphics.DrawPie(pen3, bounds, 46f, 88f);
                     bounds.Inflate(-1, -1);
                     graphics.FillEllipse(brush, bounds);
                     graphics.DrawEllipse(pen2, bounds);
                 }
             }
         }
     }
 }
        internal override void PaintOver(PaintEventArgs e, CheckState state)
        {
            ButtonBaseAdapter.ColorData  colors = base.PaintPopupRender(e.Graphics).Calculate();
            ButtonBaseAdapter.LayoutData layout = this.PaintPopupLayout(e, state == CheckState.Unchecked, SystemInformation.HighContrast ? 2 : 1).Layout();
            Graphics  g = e.Graphics;
            Rectangle clientRectangle = base.Control.ClientRectangle;
            Brush     background      = null;

            if (state == CheckState.Indeterminate)
            {
                background = ButtonBaseAdapter.CreateDitherBrush(colors.highlight, colors.buttonFace);
            }
            try
            {
                base.PaintButtonBackground(e, clientRectangle, background);
            }
            finally
            {
                if (background != null)
                {
                    background.Dispose();
                    background = null;
                }
            }
            if (base.Control.IsDefault)
            {
                clientRectangle.Inflate(-1, -1);
            }
            base.PaintImage(e, layout);
            base.PaintField(e, layout, colors, colors.windowText, true);
            ButtonBaseAdapter.DrawDefaultBorder(g, clientRectangle, colors.options.highContrast ? colors.windowText : colors.buttonShadow, base.Control.IsDefault);
            if (SystemInformation.HighContrast)
            {
                using (Pen pen = new Pen(colors.windowFrame))
                {
                    using (Pen pen2 = new Pen(colors.highlight))
                    {
                        using (Pen pen3 = new Pen(colors.buttonShadow))
                        {
                            g.DrawLine(pen, (int)(clientRectangle.Left + 1), (int)(clientRectangle.Top + 1), (int)(clientRectangle.Right - 2), (int)(clientRectangle.Top + 1));
                            g.DrawLine(pen, (int)(clientRectangle.Left + 1), (int)(clientRectangle.Top + 1), (int)(clientRectangle.Left + 1), (int)(clientRectangle.Bottom - 2));
                            g.DrawLine(pen, clientRectangle.Left, clientRectangle.Bottom - 1, clientRectangle.Right, clientRectangle.Bottom - 1);
                            g.DrawLine(pen, clientRectangle.Right - 1, clientRectangle.Top, clientRectangle.Right - 1, clientRectangle.Bottom);
                            g.DrawLine(pen2, clientRectangle.Left, clientRectangle.Top, clientRectangle.Right, clientRectangle.Top);
                            g.DrawLine(pen2, clientRectangle.Left, clientRectangle.Top, clientRectangle.Left, clientRectangle.Bottom);
                            g.DrawLine(pen3, (int)(clientRectangle.Left + 1), (int)(clientRectangle.Bottom - 2), (int)(clientRectangle.Right - 2), (int)(clientRectangle.Bottom - 2));
                            g.DrawLine(pen3, (int)(clientRectangle.Right - 2), (int)(clientRectangle.Top + 1), (int)(clientRectangle.Right - 2), (int)(clientRectangle.Bottom - 2));
                        }
                    }
                }
                clientRectangle.Inflate(-2, -2);
            }
            else
            {
                ButtonBaseAdapter.Draw3DLiteBorder(g, clientRectangle, colors, true);
            }
        }
 private void PaintFlatWorker(PaintEventArgs e, Color checkColor, Color checkBackground, Color checkBorder, ButtonBaseAdapter.ColorData colors)
 {
     Graphics graphics = e.Graphics;
     ButtonBaseAdapter.LayoutData layout = this.Layout(e).Layout();
     base.PaintButtonBackground(e, base.Control.ClientRectangle, null);
     base.PaintImage(e, layout);
     base.DrawCheckFlat(e, layout, checkColor, colors.options.highContrast ? colors.buttonFace : checkBackground, checkBorder, colors);
     base.PaintField(e, layout, colors, checkColor, true);
 }
 internal static ButtonBaseAdapter.LayoutOptions PaintFlatLayout(Graphics g, bool up, bool check, int borderSize, Rectangle clientRectangle, Padding padding, bool isDefault, Font font, string text, bool enabled, ContentAlignment textAlign, RightToLeft rtl)
 {
     ButtonBaseAdapter.LayoutOptions options = ButtonBaseAdapter.CommonLayout(clientRectangle, padding, isDefault, font, text, enabled, textAlign, rtl);
     options.borderSize        = borderSize + (check ? 1 : 0);
     options.paddingSize       = check ? 1 : 2;
     options.focusOddEvenFixup = false;
     options.textOffset        = !up;
     options.shadowedText      = SystemInformation.HighContrast;
     return(options);
 }
 internal static ButtonBaseAdapter.LayoutOptions PaintPopupLayout(Graphics g, bool up, int paintedBorder, Rectangle clientRectangle, Padding padding, bool isDefault, Font font, string text, bool enabled, ContentAlignment textAlign, RightToLeft rtl)
 {
     ButtonBaseAdapter.LayoutOptions options = ButtonBaseAdapter.CommonLayout(clientRectangle, padding, isDefault, font, text, enabled, textAlign, rtl);
     options.borderSize   = paintedBorder;
     options.paddingSize  = 2 - paintedBorder;
     options.hintTextUp   = false;
     options.textOffset   = !up;
     options.shadowedText = SystemInformation.HighContrast;
     return(options);
 }
 protected void DrawCheckBackground(PaintEventArgs e, Rectangle bounds, Color checkColor, Color checkBackground, bool disabledColors, ButtonBaseAdapter.ColorData colors)
 {
     if (this.Control.CheckState == CheckState.Indeterminate)
     {
         ButtonBaseAdapter.DrawDitheredFill(e.Graphics, colors.buttonFace, checkBackground, bounds);
     }
     else
     {
         DrawCheckBackground(this.Control.Enabled, this.Control.CheckState, e.Graphics, bounds, checkColor, checkBackground, disabledColors, colors);
     }
 }
 protected void DrawCheckBackground(PaintEventArgs e, Rectangle bounds, Color checkColor, Color checkBackground, bool disabledColors, ButtonBaseAdapter.ColorData colors)
 {
     if (this.Control.CheckState == CheckState.Indeterminate)
     {
         ButtonBaseAdapter.DrawDitheredFill(e.Graphics, colors.buttonFace, checkBackground, bounds);
     }
     else
     {
         DrawCheckBackground(this.Control.Enabled, this.Control.CheckState, e.Graphics, bounds, checkColor, checkBackground, disabledColors, colors);
     }
 }
示例#9
0
 internal static ButtonBaseAdapter.LayoutOptions PaintPopupLayout(Graphics g, bool show3D, int checkSize, Rectangle clientRectangle, Padding padding, bool isDefault, Font font, string text, bool enabled, ContentAlignment textAlign, RightToLeft rtl)
 {
     ButtonBaseAdapter.LayoutOptions options = ButtonBaseAdapter.CommonLayout(clientRectangle, padding, isDefault, font, text, enabled, textAlign, rtl);
     options.shadowedText = false;
     if (show3D)
     {
         options.checkSize = (int)((checkSize * CheckableControlBaseAdapter.GetDpiScaleRatio(g)) + 1f);
         return(options);
     }
     options.checkSize        = (int)(checkSize * CheckableControlBaseAdapter.GetDpiScaleRatio(g));
     options.checkPaddingSize = 1;
     return(options);
 }
        internal override void PaintDown(PaintEventArgs e, CheckState state)
        {
            ButtonBaseAdapter.ColorData  colors = base.PaintPopupRender(e.Graphics).Calculate();
            ButtonBaseAdapter.LayoutData layout = this.PaintPopupLayout(e, false, SystemInformation.HighContrast ? 2 : 1).Layout();
            Graphics  g = e.Graphics;
            Rectangle clientRectangle = base.Control.ClientRectangle;

            base.PaintButtonBackground(e, clientRectangle, null);
            if (base.Control.IsDefault)
            {
                clientRectangle.Inflate(-1, -1);
            }
            clientRectangle.Inflate(-1, -1);
            base.PaintImage(e, layout);
            base.PaintField(e, layout, colors, colors.windowText, true);
            clientRectangle.Inflate(1, 1);
            ButtonBaseAdapter.DrawDefaultBorder(g, clientRectangle, colors.options.highContrast ? colors.windowText : colors.windowFrame, base.Control.IsDefault);
            ControlPaint.DrawBorder(g, clientRectangle, colors.options.highContrast ? colors.windowText : colors.buttonShadow, ButtonBorderStyle.Solid);
        }
        protected void DrawCheckFlat(PaintEventArgs e, ButtonBaseAdapter.LayoutData layout, Color checkColor, Color checkBackground, Color checkBorder, ButtonBaseAdapter.ColorData colors)
        {
            Rectangle checkBounds = layout.checkBounds;

            if (!layout.options.everettButtonCompat)
            {
                checkBounds.Width--;
                checkBounds.Height--;
            }
            using (WindowsGraphics graphics = WindowsGraphics.FromGraphics(e.Graphics))
            {
                using (WindowsPen pen = new WindowsPen(graphics.DeviceContext, checkBorder))
                {
                    graphics.DrawRectangle(pen, checkBounds);
                }
                if (layout.options.everettButtonCompat)
                {
                    checkBounds.Width--;
                    checkBounds.Height--;
                }
                checkBounds.Inflate(-1, -1);
            }
            if (this.Control.CheckState == CheckState.Indeterminate)
            {
                checkBounds.Width++;
                checkBounds.Height++;
                ButtonBaseAdapter.DrawDitheredFill(e.Graphics, colors.buttonFace, checkBackground, checkBounds);
            }
            else
            {
                using (WindowsGraphics graphics2 = WindowsGraphics.FromGraphics(e.Graphics))
                {
                    using (WindowsBrush brush = new WindowsSolidBrush(graphics2.DeviceContext, checkBackground))
                    {
                        checkBounds.Width++;
                        checkBounds.Height++;
                        graphics2.FillRectangle(brush, checkBounds);
                    }
                }
            }
            this.DrawCheckOnly(e, layout, colors, checkColor, checkBackground, true);
        }
示例#12
0
 internal override void PaintUp(PaintEventArgs e, CheckState state)
 {
     if (base.Control.Appearance == Appearance.Button)
     {
         new ButtonPopupAdapter(base.Control).PaintUp(e, base.Control.CheckState);
     }
     else
     {
         Graphics graphics = e.Graphics;
         ButtonBaseAdapter.ColorData  colors = base.PaintPopupRender(e.Graphics).Calculate();
         ButtonBaseAdapter.LayoutData layout = this.PaintPopupLayout(e, false).Layout();
         Region clip = e.Graphics.Clip;
         base.PaintButtonBackground(e, base.Control.ClientRectangle, null);
         base.PaintImage(e, layout);
         base.DrawCheckBackground(e, layout.checkBounds, colors.windowText, colors.options.highContrast ? colors.buttonFace : colors.highlight, true, colors);
         ButtonBaseAdapter.DrawFlatBorder(e.Graphics, layout.checkBounds, colors.buttonShadow);
         base.DrawCheckOnly(e, layout, colors, colors.windowText, colors.highlight, true);
         base.PaintField(e, layout, colors, colors.windowText, true);
     }
 }
        internal override void PaintUp(PaintEventArgs e, CheckState state)
        {
            ButtonBaseAdapter.ColorData  colors = base.PaintPopupRender(e.Graphics).Calculate();
            ButtonBaseAdapter.LayoutData layout = this.PaintPopupLayout(e, state == CheckState.Unchecked, 1).Layout();
            Graphics  g = e.Graphics;
            Rectangle clientRectangle = base.Control.ClientRectangle;
            Brush     background      = null;

            if (state == CheckState.Indeterminate)
            {
                background = ButtonBaseAdapter.CreateDitherBrush(colors.highlight, colors.buttonFace);
            }
            try
            {
                base.PaintButtonBackground(e, clientRectangle, background);
            }
            finally
            {
                if (background != null)
                {
                    background.Dispose();
                    background = null;
                }
            }
            if (base.Control.IsDefault)
            {
                clientRectangle.Inflate(-1, -1);
            }
            base.PaintImage(e, layout);
            base.PaintField(e, layout, colors, colors.windowText, true);
            ButtonBaseAdapter.DrawDefaultBorder(g, clientRectangle, colors.options.highContrast ? colors.windowText : colors.buttonShadow, base.Control.IsDefault);
            if (state == CheckState.Unchecked)
            {
                ButtonBaseAdapter.DrawFlatBorder(g, clientRectangle, colors.options.highContrast ? colors.windowText : colors.buttonShadow);
            }
            else
            {
                ButtonBaseAdapter.Draw3DLiteBorder(g, clientRectangle, colors, false);
            }
        }
 protected void DrawCheckBox(PaintEventArgs e, ButtonBaseAdapter.LayoutData layout)
 {
     Graphics g = e.Graphics;
     ButtonState state = this.GetState();
     if (this.Control.CheckState == CheckState.Indeterminate)
     {
         if (Application.RenderWithVisualStyles)
         {
             CheckBoxRenderer.DrawCheckBox(g, new Point(layout.checkBounds.Left, layout.checkBounds.Top), CheckBoxRenderer.ConvertFromButtonState(state, true, this.Control.MouseIsOver));
         }
         else
         {
             ControlPaint.DrawMixedCheckBox(g, layout.checkBounds, state);
         }
     }
     else if (Application.RenderWithVisualStyles)
     {
         CheckBoxRenderer.DrawCheckBox(g, new Point(layout.checkBounds.Left, layout.checkBounds.Top), CheckBoxRenderer.ConvertFromButtonState(state, false, this.Control.MouseIsOver));
     }
     else
     {
         ControlPaint.DrawCheckBox(g, layout.checkBounds, state);
     }
 }
 internal LayoutData(ButtonBaseAdapter.LayoutOptions options)
 {
     this.options = options;
 }
 internal static Rectangle DrawPopupBorder(Graphics g, Rectangle r, ButtonBaseAdapter.ColorData colors)
 {
     using (WindowsGraphics graphics = WindowsGraphics.FromGraphics(g))
     {
         using (WindowsPen pen = new WindowsPen(graphics.DeviceContext, colors.highlight))
         {
             using (WindowsPen pen2 = new WindowsPen(graphics.DeviceContext, colors.buttonShadow))
             {
                 using (WindowsPen pen3 = new WindowsPen(graphics.DeviceContext, colors.buttonFace))
                 {
                     graphics.DrawLine(pen, r.Right - 1, r.Top, r.Right - 1, r.Bottom);
                     graphics.DrawLine(pen, r.Left, r.Bottom - 1, r.Right, r.Bottom - 1);
                     graphics.DrawLine(pen2, r.Left, r.Top, r.Left, r.Bottom);
                     graphics.DrawLine(pen2, r.Left, r.Top, r.Right - 1, r.Top);
                     graphics.DrawLine(pen3, r.Right - 2, r.Top + 1, r.Right - 2, r.Bottom - 1);
                     graphics.DrawLine(pen3, r.Left + 1, r.Bottom - 2, r.Right - 1, r.Bottom - 2);
                 }
             }
         }
     }
     r.Inflate(-1, -1);
     return r;
 }
 internal ColorData(ButtonBaseAdapter.ColorOptions options)
 {
     this.options = options;
 }
            private void CalcCheckmarkRectangle(ButtonBaseAdapter.LayoutData layout)
            {
                int fullCheckSize = this.FullCheckSize;
                layout.checkBounds = new Rectangle(this.client.X, this.client.Y, fullCheckSize, fullCheckSize);
                ContentAlignment alignment = this.RtlTranslateContent(this.checkAlign);
                Rectangle rectangle = Rectangle.Inflate(layout.face, -this.paddingSize, -this.paddingSize);
                layout.field = rectangle;
                if (fullCheckSize > 0)
                {
                    if ((alignment & (ContentAlignment.BottomRight | ContentAlignment.MiddleRight | ContentAlignment.TopRight)) != ((ContentAlignment) 0))
                    {
                        layout.checkBounds.X = (rectangle.X + rectangle.Width) - layout.checkBounds.Width;
                    }
                    else if ((alignment & (ContentAlignment.BottomCenter | ContentAlignment.MiddleCenter | ContentAlignment.TopCenter)) != ((ContentAlignment) 0))
                    {
                        layout.checkBounds.X = rectangle.X + ((rectangle.Width - layout.checkBounds.Width) / 2);
                    }
                    if ((alignment & (ContentAlignment.BottomRight | ContentAlignment.BottomCenter | ContentAlignment.BottomLeft)) != ((ContentAlignment) 0))
                    {
                        layout.checkBounds.Y = (rectangle.Y + rectangle.Height) - layout.checkBounds.Height;
                    }
                    else if ((alignment & (ContentAlignment.TopRight | ContentAlignment.TopCenter | ContentAlignment.TopLeft)) != ((ContentAlignment) 0))
                    {
                        layout.checkBounds.Y = rectangle.Y + 2;
                    }
                    else
                    {
                        layout.checkBounds.Y = rectangle.Y + ((rectangle.Height - layout.checkBounds.Height) / 2);
                    }
                    switch (alignment)
                    {
                        case ContentAlignment.TopLeft:
                        case ContentAlignment.MiddleLeft:
                        case ContentAlignment.BottomLeft:
                            layout.checkArea.X = rectangle.X;
                            layout.checkArea.Width = fullCheckSize + 1;
                            layout.checkArea.Y = rectangle.Y;
                            layout.checkArea.Height = rectangle.Height;
                            layout.field.X += fullCheckSize + 1;
                            layout.field.Width -= fullCheckSize + 1;
                            break;

                        case ContentAlignment.TopCenter:
                            layout.checkArea.X = rectangle.X;
                            layout.checkArea.Width = rectangle.Width;
                            layout.checkArea.Y = rectangle.Y;
                            layout.checkArea.Height = fullCheckSize;
                            layout.field.Y += fullCheckSize;
                            layout.field.Height -= fullCheckSize;
                            break;

                        case ContentAlignment.TopRight:
                        case ContentAlignment.BottomRight:
                        case ContentAlignment.MiddleRight:
                            layout.checkArea.X = (rectangle.X + rectangle.Width) - fullCheckSize;
                            layout.checkArea.Width = fullCheckSize + 1;
                            layout.checkArea.Y = rectangle.Y;
                            layout.checkArea.Height = rectangle.Height;
                            layout.field.Width -= fullCheckSize + 1;
                            break;

                        case ContentAlignment.MiddleCenter:
                            layout.checkArea = layout.checkBounds;
                            break;

                        case ContentAlignment.BottomCenter:
                            layout.checkArea.X = rectangle.X;
                            layout.checkArea.Width = rectangle.Width;
                            layout.checkArea.Y = (rectangle.Y + rectangle.Height) - fullCheckSize;
                            layout.checkArea.Height = fullCheckSize;
                            layout.field.Height -= fullCheckSize;
                            break;
                    }
                    layout.checkBounds.Width -= this.checkPaddingSize;
                    layout.checkBounds.Height -= this.checkPaddingSize;
                }
            }
 protected void DrawCheckOnly(PaintEventArgs e, ButtonBaseAdapter.LayoutData layout, Color checkColor, Color checkBackground, bool disabledColors)
 {
     if (this.Control.Checked)
     {
         if (!this.Control.Enabled && disabledColors)
         {
             checkColor = SystemColors.ControlDark;
         }
         float dpiScaleRatio = CheckableControlBaseAdapter.GetDpiScaleRatio(e.Graphics);
         using (WindowsGraphics graphics = WindowsGraphics.FromGraphics(e.Graphics))
         {
             using (WindowsBrush brush = new WindowsSolidBrush(graphics.DeviceContext, checkColor))
             {
                 int n = 5;
                 Rectangle rect = new Rectangle(layout.checkBounds.X + GetScaledNumber(n, dpiScaleRatio), layout.checkBounds.Y + GetScaledNumber(n - 1, dpiScaleRatio), GetScaledNumber(2, dpiScaleRatio), GetScaledNumber(4, dpiScaleRatio));
                 graphics.FillRectangle(brush, rect);
                 Rectangle rectangle2 = new Rectangle(layout.checkBounds.X + GetScaledNumber(n - 1, dpiScaleRatio), layout.checkBounds.Y + GetScaledNumber(n, dpiScaleRatio), GetScaledNumber(4, dpiScaleRatio), GetScaledNumber(2, dpiScaleRatio));
                 graphics.FillRectangle(brush, rectangle2);
             }
         }
     }
 }
        private void PaintWorker(PaintEventArgs e, bool up, CheckState state)
        {
            ButtonBaseAdapter.LayoutData data2;
            up = up && (state == CheckState.Unchecked);
            ButtonBaseAdapter.ColorData colors = base.PaintRender(e.Graphics).Calculate();
            if (Application.RenderWithVisualStyles)
            {
                data2 = this.PaintLayout(e, true).Layout();
            }
            else
            {
                data2 = this.PaintLayout(e, up).Layout();
            }
            Graphics   g       = e.Graphics;
            ButtonBase control = base.Control;

            if (Application.RenderWithVisualStyles)
            {
                this.PaintThemedButtonBackground(e, base.Control.ClientRectangle, up);
            }
            else
            {
                Brush background = null;
                if (state == CheckState.Indeterminate)
                {
                    background = ButtonBaseAdapter.CreateDitherBrush(colors.highlight, colors.buttonFace);
                }
                try
                {
                    Rectangle clientRectangle = base.Control.ClientRectangle;
                    if (up)
                    {
                        clientRectangle.Inflate(-2, -2);
                    }
                    else
                    {
                        clientRectangle.Inflate(-1, -1);
                    }
                    base.PaintButtonBackground(e, clientRectangle, background);
                }
                finally
                {
                    if (background != null)
                    {
                        background.Dispose();
                        background = null;
                    }
                }
            }
            base.PaintImage(e, data2);
            if (Application.RenderWithVisualStyles)
            {
                data2.focus.Inflate(1, 1);
            }
            base.PaintField(e, data2, colors, colors.windowText, true);
            if (!Application.RenderWithVisualStyles)
            {
                Rectangle r = base.Control.ClientRectangle;
                if (base.Control.IsDefault)
                {
                    r.Inflate(-1, -1);
                }
                ButtonBaseAdapter.DrawDefaultBorder(g, r, colors.windowFrame, base.Control.IsDefault);
                if (up)
                {
                    base.Draw3DBorder(g, r, colors, up);
                }
                else
                {
                    ControlPaint.DrawBorder(g, r, colors.buttonShadow, ButtonBorderStyle.Solid);
                }
            }
        }
 protected void DrawCheckBox(PaintEventArgs e, ButtonBaseAdapter.LayoutData layout)
 {
     Graphics g = e.Graphics;
     Rectangle checkBounds = layout.checkBounds;
     if (!Application.RenderWithVisualStyles)
     {
         checkBounds.X--;
     }
     ButtonState state = this.GetState();
     if (Application.RenderWithVisualStyles)
     {
         RadioButtonRenderer.DrawRadioButton(g, new Point(checkBounds.Left, checkBounds.Top), RadioButtonRenderer.ConvertFromButtonState(state, this.Control.MouseIsOver));
     }
     else
     {
         ControlPaint.DrawRadioButton(g, checkBounds, state);
     }
 }
 internal static void DrawCheckOnly(int checkSize, bool controlChecked, bool controlEnabled, CheckState controlCheckState, Graphics g, ButtonBaseAdapter.LayoutData layout, ButtonBaseAdapter.ColorData colors, Color checkColor, Color checkBackground, bool disabledColors)
 {
     if (controlChecked)
     {
         if (!controlEnabled && disabledColors)
         {
             checkColor = colors.buttonShadow;
         }
         else if ((controlCheckState == CheckState.Indeterminate) && disabledColors)
         {
             checkColor = SystemInformation.HighContrast ? colors.highlight : colors.buttonShadow;
         }
         Rectangle checkBounds = layout.checkBounds;
         if (checkBounds.Width == checkSize)
         {
             checkBounds.Width++;
             checkBounds.Height++;
         }
         checkBounds.Width++;
         checkBounds.Height++;
         Bitmap image = null;
         if (controlCheckState == CheckState.Checked)
         {
             image = GetCheckBoxImage(checkColor, checkBounds, ref checkImageCheckedBackColor, ref checkImageChecked);
         }
         else
         {
             image = GetCheckBoxImage(checkColor, checkBounds, ref checkImageIndeterminateBackColor, ref checkImageIndeterminate);
         }
         if (layout.options.everettButtonCompat)
         {
             checkBounds.Y--;
         }
         else
         {
             checkBounds.Y -= 2;
         }
         ControlPaint.DrawImageColorized(g, image, checkBounds, checkColor);
     }
 }
 protected void DrawCheckFlat(PaintEventArgs e, ButtonBaseAdapter.LayoutData layout, Color checkColor, Color checkBackground, Color checkBorder)
 {
     this.DrawCheckBackgroundFlat(e, layout.checkBounds, checkBorder, checkBackground, true);
     this.DrawCheckOnly(e, layout, checkColor, checkBackground, true);
 }
        internal override void PaintDown(PaintEventArgs e, CheckState state)
        {
            bool flag = (base.Control.FlatAppearance.BorderSize != 1) || !base.Control.FlatAppearance.BorderColor.IsEmpty;

            ButtonBaseAdapter.ColorData  colors = base.PaintFlatRender(e.Graphics).Calculate();
            ButtonBaseAdapter.LayoutData layout = this.PaintFlatLayout(e, !base.Control.FlatAppearance.CheckedBackColor.IsEmpty || (SystemInformation.HighContrast ? (state != CheckState.Indeterminate) : (state == CheckState.Unchecked)), (!flag && SystemInformation.HighContrast) && (state == CheckState.Checked), base.Control.FlatAppearance.BorderSize).Layout();
            if (!base.Control.FlatAppearance.BorderColor.IsEmpty)
            {
                colors.windowFrame = base.Control.FlatAppearance.BorderColor;
            }
            Graphics  g = e.Graphics;
            Rectangle clientRectangle = base.Control.ClientRectangle;
            Color     backColor       = base.Control.BackColor;

            if (!base.Control.FlatAppearance.MouseDownBackColor.IsEmpty)
            {
                backColor = base.Control.FlatAppearance.MouseDownBackColor;
            }
            else
            {
                switch (state)
                {
                case CheckState.Unchecked:
                case CheckState.Checked:
                    backColor = colors.options.highContrast ? colors.buttonShadow : colors.lowHighlight;
                    break;

                case CheckState.Indeterminate:
                    backColor = ButtonBaseAdapter.MixedColor(colors.options.highContrast ? colors.buttonShadow : colors.lowHighlight, colors.buttonFace);
                    break;
                }
            }
            this.PaintBackground(e, clientRectangle, backColor);
            if (base.Control.IsDefault)
            {
                clientRectangle.Inflate(-1, -1);
            }
            base.PaintImage(e, layout);
            base.PaintField(e, layout, colors, colors.windowText, false);
            if (base.Control.Focused && base.Control.ShowFocusCues)
            {
                ButtonBaseAdapter.DrawFlatFocus(g, layout.focus, colors.options.highContrast ? colors.windowText : colors.constrastButtonShadow);
            }
            if ((!base.Control.IsDefault || !base.Control.Focused) || (base.Control.FlatAppearance.BorderSize != 0))
            {
                ButtonBaseAdapter.DrawDefaultBorder(g, clientRectangle, colors.windowFrame, base.Control.IsDefault);
            }
            if (flag)
            {
                if (base.Control.FlatAppearance.BorderSize != 1)
                {
                    ButtonBaseAdapter.DrawFlatBorderWithSize(g, clientRectangle, colors.windowFrame, base.Control.FlatAppearance.BorderSize);
                }
                else
                {
                    ButtonBaseAdapter.DrawFlatBorder(g, clientRectangle, colors.windowFrame);
                }
            }
            else if ((state == CheckState.Checked) && SystemInformation.HighContrast)
            {
                ButtonBaseAdapter.DrawFlatBorder(g, clientRectangle, colors.windowFrame);
                ButtonBaseAdapter.DrawFlatBorder(g, clientRectangle, colors.buttonShadow);
            }
            else if (state == CheckState.Indeterminate)
            {
                ButtonBaseAdapter.Draw3DLiteBorder(g, clientRectangle, colors, false);
            }
            else
            {
                ButtonBaseAdapter.DrawFlatBorder(g, clientRectangle, colors.windowFrame);
            }
        }
 protected void DrawCheckFlat(PaintEventArgs e, ButtonBaseAdapter.LayoutData layout, Color checkColor, Color checkBackground, Color checkBorder, ButtonBaseAdapter.ColorData colors)
 {
     Rectangle checkBounds = layout.checkBounds;
     if (!layout.options.everettButtonCompat)
     {
         checkBounds.Width--;
         checkBounds.Height--;
     }
     using (WindowsGraphics graphics = WindowsGraphics.FromGraphics(e.Graphics))
     {
         using (WindowsPen pen = new WindowsPen(graphics.DeviceContext, checkBorder))
         {
             graphics.DrawRectangle(pen, checkBounds);
         }
         if (layout.options.everettButtonCompat)
         {
             checkBounds.Width--;
             checkBounds.Height--;
         }
         checkBounds.Inflate(-1, -1);
     }
     if (this.Control.CheckState == CheckState.Indeterminate)
     {
         checkBounds.Width++;
         checkBounds.Height++;
         ButtonBaseAdapter.DrawDitheredFill(e.Graphics, colors.buttonFace, checkBackground, checkBounds);
     }
     else
     {
         using (WindowsGraphics graphics2 = WindowsGraphics.FromGraphics(e.Graphics))
         {
             using (WindowsBrush brush = new WindowsSolidBrush(graphics2.DeviceContext, checkBackground))
             {
                 checkBounds.Width++;
                 checkBounds.Height++;
                 graphics2.FillRectangle(brush, checkBounds);
             }
         }
     }
     this.DrawCheckOnly(e, layout, colors, checkColor, checkBackground, true);
 }
 protected void DrawCheckOnly(PaintEventArgs e, ButtonBaseAdapter.LayoutData layout, ButtonBaseAdapter.ColorData colors, Color checkColor, Color checkBackground, bool disabledColors)
 {
     DrawCheckOnly(11, this.Control.Checked, this.Control.Enabled, this.Control.CheckState, e.Graphics, layout, colors, checkColor, checkBackground, disabledColors);
 }
 internal override void DrawImageCore(Graphics graphics, Image image, Rectangle imageBounds, Point imageStart, ButtonBaseAdapter.LayoutData layout)
 {
     ControlPaint.DrawImageReplaceColor(graphics, image, imageBounds, Color.Black, base.Control.ForeColor);
 }
 internal void LayoutTextAndImage(ButtonBaseAdapter.LayoutData layout)
 {
     int num3;
     ContentAlignment align = this.RtlTranslateContent(this.imageAlign);
     ContentAlignment alignment2 = this.RtlTranslateContent(this.textAlign);
     TextImageRelation relation = this.RtlTranslateRelation(this.textImageRelation);
     Rectangle withinThis = Rectangle.Inflate(layout.field, -this.textImageInset, -this.textImageInset);
     if (this.OnePixExtraBorder)
     {
         withinThis.Inflate(1, 1);
     }
     if (((this.imageSize == Size.Empty) || (this.text == null)) || ((this.text.Length == 0) || (relation == TextImageRelation.Overlay)))
     {
         Size textSize = this.GetTextSize(withinThis.Size);
         Size imageSize = this.imageSize;
         if (layout.options.everettButtonCompat && (this.imageSize != Size.Empty))
         {
             imageSize = new Size(imageSize.Width + 1, imageSize.Height + 1);
         }
         layout.imageBounds = LayoutUtils.Align(imageSize, withinThis, align);
         layout.textBounds = LayoutUtils.Align(textSize, withinThis, alignment2);
     }
     else
     {
         Size proposedSize = LayoutUtils.SubAlignedRegion(withinThis.Size, this.imageSize, relation);
         Size size4 = this.GetTextSize(proposedSize);
         Rectangle rectangle2 = withinThis;
         Size b = LayoutUtils.AddAlignedRegion(size4, this.imageSize, relation);
         rectangle2.Size = LayoutUtils.UnionSizes(rectangle2.Size, b);
         Rectangle bounds = LayoutUtils.Align(b, rectangle2, ContentAlignment.MiddleCenter);
         bool flag = (ImageAlignToRelation(align) & relation) != TextImageRelation.Overlay;
         bool flag2 = (TextAlignToRelation(alignment2) & relation) != TextImageRelation.Overlay;
         if (flag)
         {
             LayoutUtils.SplitRegion(rectangle2, this.imageSize, (AnchorStyles) relation, out layout.imageBounds, out layout.textBounds);
         }
         else if (flag2)
         {
             LayoutUtils.SplitRegion(rectangle2, size4, (AnchorStyles) LayoutUtils.GetOppositeTextImageRelation(relation), out layout.textBounds, out layout.imageBounds);
         }
         else
         {
             LayoutUtils.SplitRegion(bounds, this.imageSize, (AnchorStyles) relation, out layout.imageBounds, out layout.textBounds);
             LayoutUtils.ExpandRegionsToFillBounds(rectangle2, (AnchorStyles) relation, ref layout.imageBounds, ref layout.textBounds);
         }
         layout.imageBounds = LayoutUtils.Align(this.imageSize, layout.imageBounds, align);
         layout.textBounds = LayoutUtils.Align(size4, layout.textBounds, alignment2);
     }
     switch (relation)
     {
         case TextImageRelation.TextBeforeImage:
         case TextImageRelation.ImageBeforeText:
         {
             int num = Math.Min(layout.textBounds.Bottom, layout.field.Bottom);
             int introduced18 = Math.Min(layout.textBounds.Y, layout.field.Y + ((layout.field.Height - layout.textBounds.Height) / 2));
             layout.textBounds.Y = Math.Max(introduced18, layout.field.Y);
             layout.textBounds.Height = num - layout.textBounds.Y;
             break;
         }
     }
     if ((relation == TextImageRelation.TextAboveImage) || (relation == TextImageRelation.ImageAboveText))
     {
         int num2 = Math.Min(layout.textBounds.Right, layout.field.Right);
         int introduced19 = Math.Min(layout.textBounds.X, layout.field.X + ((layout.field.Width - layout.textBounds.Width) / 2));
         layout.textBounds.X = Math.Max(introduced19, layout.field.X);
         layout.textBounds.Width = num2 - layout.textBounds.X;
     }
     if ((relation == TextImageRelation.ImageBeforeText) && (layout.imageBounds.Size.Width != 0))
     {
         layout.imageBounds.Width = Math.Max(0, Math.Min(withinThis.Width - layout.textBounds.Width, layout.imageBounds.Width));
         layout.textBounds.X = layout.imageBounds.X + layout.imageBounds.Width;
     }
     if ((relation == TextImageRelation.ImageAboveText) && (layout.imageBounds.Size.Height != 0))
     {
         layout.imageBounds.Height = Math.Max(0, Math.Min(withinThis.Height - layout.textBounds.Height, layout.imageBounds.Height));
         layout.textBounds.Y = layout.imageBounds.Y + layout.imageBounds.Height;
     }
     layout.textBounds = Rectangle.Intersect(layout.textBounds, layout.field);
     if (this.hintTextUp)
     {
         layout.textBounds.Y--;
     }
     if (this.textOffset)
     {
         layout.textBounds.Offset(1, 1);
     }
     if (layout.options.everettButtonCompat)
     {
         layout.imageStart = layout.imageBounds.Location;
         layout.imageBounds = Rectangle.Intersect(layout.imageBounds, layout.field);
     }
     else if (!Application.RenderWithVisualStyles)
     {
         layout.textBounds.X++;
     }
     if (!this.useCompatibleTextRendering)
     {
         num3 = Math.Min(layout.textBounds.Bottom, withinThis.Bottom);
         layout.textBounds.Y = Math.Max(layout.textBounds.Y, withinThis.Y);
     }
     else
     {
         num3 = Math.Min(layout.textBounds.Bottom, layout.field.Bottom);
         layout.textBounds.Y = Math.Max(layout.textBounds.Y, layout.field.Y);
     }
     layout.textBounds.Height = num3 - layout.textBounds.Y;
 }