/// <summary> /// OnPaintForeground method. /// </summary> /// <param name="e">PaintEventArgs instance.</param> protected virtual void OnPaintForeground(PaintEventArgs e) { Color foreColor; if (this.UseCustomForeColor) { foreColor = this.ForeColor; } else { if (this._isHovered && !this._isPressed && this.Enabled) { foreColor = ModernPaint.ForeColor.Link.Hover(this.ThemeStyle); } else if (this._isHovered && this._isPressed && this.Enabled) { foreColor = ModernPaint.ForeColor.Link.Press(this.ThemeStyle); } else if (!this.Enabled) { foreColor = ModernPaint.ForeColor.Link.Disabled(this.ThemeStyle); } else { foreColor = !this.UseStyleColors ? ModernPaint.ForeColor.Link.Normal(this.ThemeStyle) : ModernPaint.GetStyleColor(this.ColorStyle); } } TextRenderer.DrawText(e.Graphics, this.Text, ModernFonts.Link(this.FontSize, this.FontWeight), this.ClientRectangle, foreColor, ModernPaint.GetTextFormatFlags(this.TextAlign)); this.OnCustomPaintForeground(new ModernPaintEventArgs(Color.Empty, foreColor, e.Graphics)); if (this.DisplayFocus && this._isFocused) { ControlPaint.DrawFocusRectangle(e.Graphics, this.ClientRectangle); } }
/// <summary> /// OnPaintForeground method. /// </summary> /// <param name="e">PaintEventArgs instance.</param> protected virtual void OnPaintForeground(PaintEventArgs e) { Color borderColor; Color foreColor; if (this._isHovered && !this._isPressed && this.Enabled) { foreColor = ModernPaint.ForeColor.CheckBox.Hover(this.ThemeStyle); borderColor = ModernPaint.BorderColor.CheckBox.Hover(this.ThemeStyle); } else if (this._isHovered && this._isPressed && this.Enabled) { foreColor = ModernPaint.ForeColor.CheckBox.Press(this.ThemeStyle); borderColor = ModernPaint.BorderColor.CheckBox.Press(this.ThemeStyle); } else if (!this.Enabled) { foreColor = ModernPaint.ForeColor.CheckBox.Disabled(this.ThemeStyle); borderColor = ModernPaint.BorderColor.CheckBox.Disabled(this.ThemeStyle); } else { foreColor = !this.UseStyleColors ? ModernPaint.ForeColor.CheckBox.Normal(this.ThemeStyle) : ModernPaint.GetStyleColor(this.ColorStyle); borderColor = ModernPaint.BorderColor.CheckBox.Normal(this.ThemeStyle); } using (Pen pen = new Pen(borderColor)) { Rectangle boxRectangle = new Rectangle(this.StatusTextRightToLeft ? 0 : (this.ShowStatusText ? 30 : 0), 0, this.ClientRectangle.Width - (this.ShowStatusText ? 31 : 1), this.ClientRectangle.Height - 1); e.Graphics.DrawRectangle(pen, boxRectangle); } Color fillColor = this.Checked ? ModernPaint.GetStyleColor(this.ColorStyle) : ModernPaint.BorderColor.CheckBox.Normal(this.ThemeStyle); using (SolidBrush brush = new SolidBrush(fillColor)) { Rectangle boxRectangle = new Rectangle(this.StatusTextRightToLeft ? 2 : (this.ShowStatusText ? 32 : 2), 2, this.ClientRectangle.Width - (this.ShowStatusText ? 34 : 4), this.ClientRectangle.Height - 4); e.Graphics.FillRectangle(brush, boxRectangle); } Color backColor = this.BackColor; if (!this.UseCustomBackColor) { backColor = ModernPaint.BackColor.Form(this.ThemeStyle); } using (SolidBrush brush = new SolidBrush(backColor)) { int left = this.Checked ? this.Width - 11 : (this.ShowStatusText ? 30 : 0); Rectangle boxRectangle = new Rectangle(this.StatusTextRightToLeft ? left - 30 : left, 0, 11, this.ClientRectangle.Height); e.Graphics.FillRectangle(brush, boxRectangle); } using (SolidBrush brush = new SolidBrush(ModernPaint.BorderColor.CheckBox.Hover(this.ThemeStyle))) { int left = this.Checked ? this.Width - 10 : (this.ShowStatusText ? 30 : 0); Rectangle boxRectangle = new Rectangle(this.StatusTextRightToLeft ? left - 30 : left, 0, 10, this.ClientRectangle.Height); e.Graphics.FillRectangle(brush, boxRectangle); } if (this.ShowStatusText) { Rectangle textRectangle = new Rectangle(this.StatusTextRightToLeft ? this.ClientRectangle.Width - (this.ShowStatusText ? 31 : 1) : 0, 0, 30, this.ClientRectangle.Height); TextRenderer.DrawText(e.Graphics, this.Text, ModernFonts.Link(this.FontSize, this.FontWeight), textRectangle, foreColor, ModernPaint.GetTextFormatFlags(this.TextAlign)); } if (this.DisplayFocus && this._isFocused) { ControlPaint.DrawFocusRectangle(e.Graphics, this.ClientRectangle); } }