コード例 #1
0
        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);
            }
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
        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);
                }
            }
        }