internal override void PaintUp(PaintEventArgs e, CheckState state) { if (base.Control.Appearance == Appearance.Button) { this.ButtonAdapter.PaintUp(e, base.Control.CheckState); } else { ButtonBaseAdapter.ColorData colors = base.PaintRender(e.Graphics).Calculate(); ButtonBaseAdapter.LayoutData layout = this.Layout(e).Layout(); base.PaintButtonBackground(e, base.Control.ClientRectangle, null); int num = layout.focus.X & 1; if (!Application.RenderWithVisualStyles) { num = 1 - num; } if (!layout.options.everettButtonCompat) { layout.textBounds.Offset(-1, -1); } layout.imageBounds.Offset(-1, -1); layout.focus.Offset(-(num + 1), -2); layout.focus.Width = (layout.textBounds.Width + layout.imageBounds.Width) - 1; layout.focus.Intersect(layout.textBounds); if (((layout.options.textAlign != (ContentAlignment.BottomLeft | ContentAlignment.MiddleLeft | ContentAlignment.TopLeft)) && layout.options.useCompatibleTextRendering) && layout.options.font.Italic) { layout.focus.Width += 2; } base.PaintImage(e, layout); base.DrawCheckBox(e, layout); base.PaintField(e, layout, colors, colors.windowText, true); } }
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); } }
internal override void PaintUp(PaintEventArgs e, CheckState state) { if (base.Control.Appearance == Appearance.Button) { this.ButtonAdapter.PaintUp(e, base.Control.Checked ? CheckState.Checked : CheckState.Unchecked); } else { ButtonBaseAdapter.ColorData colors = base.PaintRender(e.Graphics).Calculate(); ButtonBaseAdapter.LayoutData layout = this.Layout(e).Layout(); base.PaintButtonBackground(e, base.Control.ClientRectangle, null); base.PaintImage(e, layout); base.DrawCheckBox(e, layout); base.PaintField(e, layout, colors, colors.windowText, true); } }
internal override void PaintUp(PaintEventArgs e, CheckState state) { Graphics graphics = e.Graphics; if (base.Control.Appearance == Appearance.Button) { new ButtonPopupAdapter(base.Control).PaintUp(e, base.Control.Checked ? CheckState.Checked : CheckState.Unchecked); } else { ButtonBaseAdapter.ColorData colors = base.PaintPopupRender(e.Graphics).Calculate(); ButtonBaseAdapter.LayoutData layout = this.Layout(e).Layout(); base.PaintButtonBackground(e, base.Control.ClientRectangle, null); base.PaintImage(e, layout); base.DrawCheckBackgroundFlat(e, layout.checkBounds, colors.buttonShadow, colors.options.highContrast ? colors.buttonFace : colors.highlight, true); base.DrawCheckOnly(e, layout, colors.windowText, colors.highlight, true); base.PaintField(e, layout, colors, colors.windowText, true); } }
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); }
internal override void PaintUp(PaintEventArgs e, CheckState state) { if (base.Control.Appearance == Appearance.Button) { new ButtonFlatAdapter(base.Control).PaintUp(e, base.Control.Checked ? CheckState.Checked : CheckState.Unchecked); } else { ButtonBaseAdapter.ColorData colors = base.PaintFlatRender(e.Graphics).Calculate(); if (base.Control.Enabled) { this.PaintFlatWorker(e, colors.windowText, colors.highlight, colors.windowFrame, colors); } else { this.PaintFlatWorker(e, colors.buttonShadow, colors.buttonFace, colors.buttonShadow, colors); } } }
internal override void PaintDown(PaintEventArgs e, CheckState state) { if (base.Control.Appearance == Appearance.Button) { new ButtonPopupAdapter(base.Control).PaintDown(e, base.Control.CheckState); } else { Graphics g = e.Graphics; ButtonBaseAdapter.ColorData colors = base.PaintPopupRender(e.Graphics).Calculate(); ButtonBaseAdapter.LayoutData layout = this.PaintPopupLayout(e, true).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.buttonFace, true, colors); CheckBoxBaseAdapter.DrawPopupBorder(g, layout.checkBounds, colors); base.DrawCheckOnly(e, layout, colors, colors.windowText, colors.buttonFace, 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); } }
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 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 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); } }
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); } } }
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); base.PaintField(e, layout, colors, checkColor, true); }
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); }
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 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); } } } } }
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 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); } }
internal ButtonBaseAdapter.ColorData Calculate() { ButtonBaseAdapter.ColorData data = new ButtonBaseAdapter.ColorData(this) { buttonFace = this.backColor }; if (this.backColor == SystemColors.Control) { data.buttonShadow = SystemColors.ControlDark; data.buttonShadowDark = SystemColors.ControlDarkDark; data.highlight = SystemColors.ControlLightLight; } else if (!this.highContrast) { data.buttonShadow = ControlPaint.Dark(this.backColor); data.buttonShadowDark = ControlPaint.DarkDark(this.backColor); data.highlight = ControlPaint.LightLight(this.backColor); } else { data.buttonShadow = ControlPaint.Dark(this.backColor); data.buttonShadowDark = ControlPaint.LightLight(this.backColor); data.highlight = ControlPaint.LightLight(this.backColor); } float percentage = 0.9f; if (data.buttonFace.GetBrightness() < 0.5) { percentage = 1.2f; } data.lowButtonFace = Color.FromArgb(Adjust255(percentage, data.buttonFace.R), Adjust255(percentage, data.buttonFace.G), Adjust255(percentage, data.buttonFace.B)); percentage = 0.9f; if (data.highlight.GetBrightness() < 0.5) { percentage = 1.2f; } data.lowHighlight = Color.FromArgb(Adjust255(percentage, data.highlight.R), Adjust255(percentage, data.highlight.G), Adjust255(percentage, data.highlight.B)); if (this.highContrast && (this.backColor != SystemColors.Control)) { data.highlight = data.lowHighlight; } data.windowFrame = this.foreColor; if (data.buttonFace.GetBrightness() < 0.5) { data.constrastButtonShadow = data.lowHighlight; } else { data.constrastButtonShadow = data.buttonShadow; } if (!this.enabled && this.disabledTextDim) { data.windowText = data.buttonShadow; } else { data.windowText = data.windowFrame; } IntPtr hdc = this.graphics.GetHdc(); try { using (WindowsGraphics graphics = WindowsGraphics.FromHdc(hdc)) { data.buttonFace = graphics.GetNearestColor(data.buttonFace); data.buttonShadow = graphics.GetNearestColor(data.buttonShadow); data.buttonShadowDark = graphics.GetNearestColor(data.buttonShadowDark); data.constrastButtonShadow = graphics.GetNearestColor(data.constrastButtonShadow); data.windowText = graphics.GetNearestColor(data.windowText); data.highlight = graphics.GetNearestColor(data.highlight); data.lowHighlight = graphics.GetNearestColor(data.lowHighlight); data.lowButtonFace = graphics.GetNearestColor(data.lowButtonFace); data.windowFrame = graphics.GetNearestColor(data.windowFrame); } } finally { this.graphics.ReleaseHdc(); } return data; }