protected virtual void OnPaintForeground(PaintEventArgs e) { Color foreColor; if (useCustomForeColor) { foreColor = ForeColor; } else { if (isHovered && !isPressed && Enabled) { foreColor = WellsMetroPaint.ForeColor.Link.Hover(Theme); } else if (isHovered && isPressed && Enabled) { foreColor = WellsMetroPaint.ForeColor.Link.Press(Theme); } else if (!Enabled) { foreColor = WellsMetroPaint.ForeColor.Link.Disabled(Theme); } else { foreColor = !useStyleColors?WellsMetroPaint.ForeColor.Link.Normal(Theme) : WellsMetroPaint.GetStyleColor(Style); } } TextRenderer.DrawText(e.Graphics, Text, WellsMetroFonts.Link(metroLinkSize, metroLinkWeight), ClientRectangle, foreColor, WellsMetroPaint.GetTextFormatFlags(TextAlign)); OnCustomPaintForeground(new WellsMetroPaintEventArgs(Color.Empty, foreColor, e.Graphics)); if (displayFocusRectangle && isFocused) { ControlPaint.DrawFocusRectangle(e.Graphics, ClientRectangle); } }
protected virtual void OnPaintForeground(PaintEventArgs e) { Color borderColor, foreColor; if (isHovered && !isPressed && Enabled) { foreColor = WellsMetroPaint.ForeColor.CheckBox.Hover(Theme); borderColor = WellsMetroPaint.BorderColor.CheckBox.Hover(Theme); } else if (isHovered && isPressed && Enabled) { foreColor = WellsMetroPaint.ForeColor.CheckBox.Press(Theme); borderColor = WellsMetroPaint.BorderColor.CheckBox.Press(Theme); } else if (!Enabled) { foreColor = WellsMetroPaint.ForeColor.CheckBox.Disabled(Theme); borderColor = WellsMetroPaint.BorderColor.CheckBox.Disabled(Theme); } else { foreColor = !useStyleColors?WellsMetroPaint.ForeColor.CheckBox.Normal(Theme) : WellsMetroPaint.GetStyleColor(Style); borderColor = WellsMetroPaint.BorderColor.CheckBox.Normal(Theme); } using (Pen p = new Pen(borderColor)) { Rectangle boxRect = new Rectangle((DisplayStatus ? 30 : 0), 0, ClientRectangle.Width - (DisplayStatus ? 31 : 1), ClientRectangle.Height - 1); e.Graphics.DrawRectangle(p, boxRect); } Color fillColor = Checked ? WellsMetroPaint.GetStyleColor(Style) : WellsMetroPaint.BorderColor.CheckBox.Normal(Theme); using (SolidBrush b = new SolidBrush(fillColor)) { Rectangle boxRect = new Rectangle(DisplayStatus ? 32 : 2, 2, ClientRectangle.Width - (DisplayStatus ? 34 : 4), ClientRectangle.Height - 4); e.Graphics.FillRectangle(b, boxRect); } Color backColor = BackColor; if (!useCustomBackColor) { backColor = WellsMetroPaint.BackColor.Form(Theme); } using (SolidBrush b = new SolidBrush(backColor)) { int left = Checked ? Width - 11 : (DisplayStatus ? 30 : 0); Rectangle boxRect = new Rectangle(left, 0, 11, ClientRectangle.Height); e.Graphics.FillRectangle(b, boxRect); } using (SolidBrush b = new SolidBrush(WellsMetroPaint.BorderColor.CheckBox.Hover(Theme))) { int left = Checked ? Width - 10 : (DisplayStatus ? 30 : 0); Rectangle boxRect = new Rectangle(left, 0, 10, ClientRectangle.Height); e.Graphics.FillRectangle(b, boxRect); } if (DisplayStatus) { Rectangle textRect = new Rectangle(0, 0, 30, ClientRectangle.Height); TextRenderer.DrawText(e.Graphics, Text, WellsMetroFonts.Link(metroLinkSize, metroLinkWeight), textRect, foreColor, WellsMetroPaint.GetTextFormatFlags(TextAlign)); } if (displayFocusRectangle && isFocused) { ControlPaint.DrawFocusRectangle(e.Graphics, ClientRectangle); } }