internal override void PaintUp(PaintEventArgs e, CheckState state) { if (Control.Appearance == Appearance.Button) { ButtonPopupAdapter adapter = new ButtonPopupAdapter(Control); adapter.PaintUp(e, Control.CheckState); } else { ColorData colors = PaintPopupRender(e).Calculate(); LayoutData layout = PaintPopupLayout(show3D: false).Layout(); PaintButtonBackground(e, Control.ClientRectangle, null); PaintImage(e, layout); DrawCheckBackground( e, layout.checkBounds, colors.windowText, colors.options.HighContrast ? colors.buttonFace : colors.highlight, disabledColors: true, colors); ControlPaint.DrawBorderSolid( e, layout.checkBounds, (colors.options.HighContrast && !Control.Enabled) ? colors.windowFrame : colors.buttonShadow); DrawCheckOnly(e, layout, colors, colors.windowText, colors.highlight); AdjustFocusRectangle(layout); PaintField(e, layout, colors, colors.windowText, true); } }
private void DDB_Draw3DBorder(PaintEventArgs e, Rectangle r, bool raised) { if (Control.BackColor != SystemColors.Control && SystemInformation.HighContrast) { if (raised) { Color c = ControlPaint.LightLight(Control.BackColor); ControlPaint.DrawBorder( e, r, c, 1, ButtonBorderStyle.Outset, c, 1, ButtonBorderStyle.Outset, c, 2, ButtonBorderStyle.Inset, c, 2, ButtonBorderStyle.Inset); } else { ControlPaint.DrawBorderSolid(e, r, ControlPaint.Dark(Control.BackColor)); } } else { if (raised) { Color c = ControlPaint.Light(Control.BackColor); ControlPaint.DrawBorder( e, r, c, 1, ButtonBorderStyle.Solid, c, 1, ButtonBorderStyle.Solid, Control.BackColor, 2, ButtonBorderStyle.Outset, Control.BackColor, 2, ButtonBorderStyle.Outset); Rectangle inside = r; inside.Offset(1, 1); inside.Width -= 3; inside.Height -= 3; c = ControlPaint.LightLight(Control.BackColor); ControlPaint.DrawBorder( e, inside, c, 1, ButtonBorderStyle.Solid, c, 1, ButtonBorderStyle.Solid, c, 1, ButtonBorderStyle.None, c, 1, ButtonBorderStyle.None); } else { ControlPaint.DrawBorderSolid(e, r, ControlPaint.Dark(Control.BackColor)); } } }
internal override void PaintUp(PaintEventArgs e, CheckState state) { ColorData colors = PaintPopupRender(e).Calculate(); LayoutData layout = PaintPopupLayout(e, state == CheckState.Unchecked, 1).Layout(); Rectangle r = Control.ClientRectangle; if (state == CheckState.Indeterminate) { using Brush backbrush = CreateDitherBrush(colors.highlight, colors.buttonFace); PaintButtonBackground(e, r, backbrush); } else { Control.PaintBackground(e, r, IsHighContrastHighlighted() ? SystemColors.Highlight : Control.BackColor, r.Location); } if (Control.IsDefault) { r.Inflate(-1, -1); } PaintImage(e, layout); PaintField( e, layout, colors, state != CheckState.Indeterminate && IsHighContrastHighlighted() ? SystemColors.HighlightText : colors.windowText, drawFocus: true); DrawDefaultBorder(e, r, colors.options.HighContrast ? colors.windowText : colors.buttonShadow, Control.IsDefault); if (state == CheckState.Unchecked) { ControlPaint.DrawBorderSolid(e, r, colors.options.HighContrast ? colors.windowText : colors.buttonShadow); } else { Draw3DLiteBorder(e, r, colors, false); } }
internal override void PaintDown(PaintEventArgs e, CheckState state) { ColorData colors = PaintPopupRender(e).Calculate(); LayoutData layout = PaintPopupLayout(e, false, SystemInformation.HighContrast ? 2 : 1).Layout(); Rectangle r = Control.ClientRectangle; PaintButtonBackground(e, r, null); if (Control.IsDefault) { r.Inflate(-1, -1); } r.Inflate(-1, -1); PaintImage(e, layout); PaintField(e, layout, colors, colors.windowText, true); r.Inflate(1, 1); DrawDefaultBorder(e, r, colors.options.HighContrast ? colors.windowText : colors.windowFrame, Control.IsDefault); ControlPaint.DrawBorderSolid(e, r, colors.options.HighContrast ? colors.windowText : colors.buttonShadow); }
private void PaintWorker(PaintEventArgs e, bool up, CheckState state) { up = up && state == CheckState.Unchecked; ColorData colors = PaintRender(e).Calculate(); LayoutData layout; if (Application.RenderWithVisualStyles) { // Don't have the text-pressed-down effect when we use themed painting to be consistent with Win32. layout = PaintLayout(e, true).Layout(); } else { layout = PaintLayout(e, up).Layout(); } _ = Control as Button; if (Application.RenderWithVisualStyles) { PaintThemedButtonBackground(e, Control.ClientRectangle, up); } else { Brush backbrush = null; if (state == CheckState.Indeterminate) { backbrush = CreateDitherBrush(colors.highlight, colors.buttonFace); } try { Rectangle bounds = Control.ClientRectangle; if (up) { // We are going to draw a 2 pixel border bounds.Inflate(-BorderWidth, -BorderWidth); } else { // We are going to draw a 1 pixel border. bounds.Inflate(-1, -1); } PaintButtonBackground(e, bounds, backbrush); } finally { backbrush?.Dispose(); } } PaintImage(e, layout); // Inflate the focus rectangle to be consistent with the behavior of Win32 app if (Application.RenderWithVisualStyles) { layout.focus.Inflate(1, 1); } if (up & IsHighContrastHighlighted()) { Color highlightTextColor = SystemColors.HighlightText; PaintField(e, layout, colors, highlightTextColor, false); if (Control.Focused && Control.ShowFocusCues) { // Drawing focus rectangle of HighlightText color ControlPaint.DrawHighContrastFocusRectangle(e.GraphicsInternal, layout.focus, highlightTextColor); } } else if (up & IsHighContrastHighlighted()) { PaintField(e, layout, colors, SystemColors.HighlightText, true); } else { PaintField(e, layout, colors, colors.windowText, true); } if (!Application.RenderWithVisualStyles) { Rectangle r = Control.ClientRectangle; if (Control.IsDefault) { r.Inflate(-1, -1); } DrawDefaultBorder(e, r, colors.windowFrame, Control.IsDefault); if (up) { Draw3DBorder(e, r, colors, raised: up); } else { // Not Draw3DBorder(..., raised: false); ControlPaint.DrawBorderSolid(e, r, colors.buttonShadow); } } }
internal override void PaintUp(PaintEventArgs e, CheckState state) { bool hasCustomBorder = (Control.FlatAppearance.BorderSize != BORDERSIZE || !Control.FlatAppearance.BorderColor.IsEmpty); ColorData colors = PaintFlatRender(e).Calculate(); LayoutData layout = PaintFlatLayout( up: !Control.FlatAppearance.CheckedBackColor.IsEmpty || (SystemInformation.HighContrast ? state != CheckState.Indeterminate : state == CheckState.Unchecked), check: !hasCustomBorder && SystemInformation.HighContrast && state == CheckState.Checked, Control.FlatAppearance.BorderSize).Layout(); // Paint with the BorderColor if set. if (!Control.FlatAppearance.BorderColor.IsEmpty) { colors.windowFrame = Control.FlatAppearance.BorderColor; } Rectangle r = Control.ClientRectangle; Color backColor = Control.BackColor; if (!Control.FlatAppearance.CheckedBackColor.IsEmpty) { switch (state) { case CheckState.Checked: backColor = Control.FlatAppearance.CheckedBackColor; break; case CheckState.Indeterminate: backColor = Control.FlatAppearance.CheckedBackColor.MixColor(colors.buttonFace); break; } } else { switch (state) { case CheckState.Checked: backColor = colors.highlight; break; case CheckState.Indeterminate: backColor = colors.highlight.MixColor(colors.buttonFace); break; } } PaintBackground(e, r, IsHighContrastHighlighted() ? SystemColors.Highlight : backColor); if (Control.IsDefault) { r.Inflate(-1, -1); } PaintImage(e, layout); PaintField(e, layout, colors, IsHighContrastHighlighted() ? SystemColors.HighlightText : colors.windowText, false); if (Control.Focused && Control.ShowFocusCues) { DrawFlatFocus(e, layout.focus, colors.options.HighContrast ? colors.windowText : colors.constrastButtonShadow); } if (!(Control.IsDefault && Control.Focused && (Control.FlatAppearance.BorderSize == 0))) { DrawDefaultBorder(e, r, colors.windowFrame, Control.IsDefault); } // Always check if the BorderSize is not the default.If not, we need to paint with the BorderSize set by the user. if (hasCustomBorder) { if (Control.FlatAppearance.BorderSize != BORDERSIZE) { DrawFlatBorderWithSize(e, r, colors.windowFrame, Control.FlatAppearance.BorderSize); } else { ControlPaint.DrawBorderSolid(e, r, colors.windowFrame); } } else if (state == CheckState.Checked && SystemInformation.HighContrast) { ControlPaint.DrawBorderSolid(e, r, colors.windowFrame); ControlPaint.DrawBorderSolid(e, r, colors.buttonShadow); } else if (state == CheckState.Indeterminate) { Draw3DLiteBorder(e, r, colors, false); } else { ControlPaint.DrawBorderSolid(e, r, colors.windowFrame); } }