protected virtual void OnPaintForeground(PaintEventArgs e) { if (this.useCustomForeColor) { this.foreColor = this.ForeColor; } else if (this.isHovered && !this.isPressed && base.Enabled) { this.foreColor = MetroPaint.ForeColor.Link.Normal(this.Theme); } else if (this.isHovered && this.isPressed && base.Enabled) { this.foreColor = MetroPaint.ForeColor.Link.Press(this.Theme); } else if (base.Enabled) { this.foreColor = (!this.useStyleColors ? MetroPaint.ForeColor.Link.Hover(this.Theme) : MetroPaint.GetStyleColor(this.Style)); } else { this.foreColor = MetroPaint.ForeColor.Link.Disabled(this.Theme); } TextRenderer.DrawText(e.Graphics, this.Text, MetroFonts.Link(this.metroLinkSize, this.metroLinkWeight), base.ClientRectangle, this.foreColor, MetroPaint.GetTextFormatFlags(this.TextAlign)); this.OnCustomPaintForeground(new MetroPaintEventArgs(Color.Empty, this.foreColor, e.Graphics)); if (this.displayFocusRectangle && this.isFocused) { ControlPaint.DrawFocusRectangle(e.Graphics, base.ClientRectangle); } if (this._image != null) { this.DrawIcon(e.Graphics); } }
protected override void OnDrawItem(DrawItemEventArgs e) { if (e.Index >= 0) { Color backColor, foreColor; if (e.State == (DrawItemState.NoAccelerator | DrawItemState.NoFocusRect) || e.State == DrawItemState.None) { backColor = MetroPaint.BackColor.Form(Theme); foreColor = MetroPaint.ForeColor.Link.Normal(Theme); } else { backColor = MetroPaint.GetStyleColor(Style); foreColor = MetroPaint.ForeColor.Tile.Normal(Theme); } using (SolidBrush b = new SolidBrush(backColor)) { e.Graphics.FillRectangle(b, new Rectangle(e.Bounds.Left, e.Bounds.Top, e.Bounds.Width, e.Bounds.Height)); } Rectangle textRect = new Rectangle(0, e.Bounds.Top, e.Bounds.Width, e.Bounds.Height); TextRenderer.DrawText(e.Graphics, Items[e.Index].ToString(), MetroFonts.Link(metroLinkSize, metroLinkWeight), textRect, foreColor, backColor, TextFormatFlags.Left | TextFormatFlags.VerticalCenter); } else { base.OnDrawItem(e); } }
protected override void OnPaint(PaintEventArgs e) { base.ItemHeight = GetPreferredSize(Size.Empty).Height; Color backColor, borderColor, foreColor; if (Parent != null) { backColor = Parent.BackColor; } else { backColor = MetroPaint.BackColor.Form(Theme); } if (isHovered && !isPressed && Enabled) { foreColor = MetroPaint.ForeColor.ComboBox.Hover(Theme); borderColor = MetroPaint.BorderColor.ComboBox.Hover(Theme); } else if (isHovered && isPressed && Enabled) { foreColor = MetroPaint.ForeColor.ComboBox.Press(Theme); borderColor = MetroPaint.BorderColor.ComboBox.Press(Theme); } else if (!Enabled) { foreColor = MetroPaint.ForeColor.ComboBox.Disabled(Theme); borderColor = MetroPaint.BorderColor.ComboBox.Disabled(Theme); } else { foreColor = MetroPaint.ForeColor.ComboBox.Normal(Theme); borderColor = MetroPaint.BorderColor.ComboBox.Normal(Theme); } e.Graphics.Clear(backColor); using (Pen p = new Pen(borderColor)) { Rectangle boxRect = new Rectangle(0, 0, Width - 1, Height - 1); e.Graphics.DrawRectangle(p, boxRect); } using (SolidBrush b = new SolidBrush(foreColor)) { e.Graphics.FillPolygon(b, new Point[] { new Point(Width - 20, (Height / 2) - 2), new Point(Width - 9, (Height / 2) - 2), new Point(Width - 15, (Height / 2) + 4) }); } Rectangle textRect = new Rectangle(2, 2, Width - 20, Height - 4); TextRenderer.DrawText(e.Graphics, Text, MetroFonts.Link(metroLinkSize, metroLinkWeight), textRect, foreColor, backColor, TextFormatFlags.Left | TextFormatFlags.VerticalCenter); if (false && isFocused) { ControlPaint.DrawFocusRectangle(e.Graphics, ClientRectangle); } }
// Token: 0x0600010D RID: 269 RVA: 0x00004D10 File Offset: 0x00002F10 protected override void OnPaint(PaintEventArgs e) { base.ItemHeight = this.GetPreferredSize(Size.Empty).Height; Color color; if (base.Parent != null) { color = base.Parent.BackColor; } else { color = MetroPaint.BackColor.Form(base.Theme); } Color color2; Color color3; if (this.isHovered && !this.isPressed && base.Enabled) { color2 = MetroPaint.ForeColor.ComboBox.Hover(base.Theme); color3 = MetroPaint.BorderColor.ComboBox.Hover(base.Theme); } else if (this.isHovered && this.isPressed && base.Enabled) { color2 = MetroPaint.ForeColor.ComboBox.Press(base.Theme); color3 = MetroPaint.BorderColor.ComboBox.Press(base.Theme); } else if (!base.Enabled) { color2 = MetroPaint.ForeColor.ComboBox.Disabled(base.Theme); color3 = MetroPaint.BorderColor.ComboBox.Disabled(base.Theme); } else { color2 = MetroPaint.ForeColor.ComboBox.Normal(base.Theme); color3 = MetroPaint.BorderColor.ComboBox.Normal(base.Theme); } e.Graphics.Clear(color); using (Pen pen = new Pen(color3)) { Rectangle rect = new Rectangle(0, 0, base.Width - 1, base.Height - 1); e.Graphics.DrawRectangle(pen, rect); } using (SolidBrush solidBrush = new SolidBrush(color2)) { e.Graphics.FillPolygon(solidBrush, new Point[] { new Point(base.Width - 20, base.Height / 2 - 2), new Point(base.Width - 9, base.Height / 2 - 2), new Point(base.Width - 15, base.Height / 2 + 4) }); } Rectangle bounds = new Rectangle(2, 2, base.Width - 20, base.Height - 4); TextRenderer.DrawText(e.Graphics, this.Text, MetroFonts.Link(this.metroLinkSize, this.metroLinkWeight), bounds, color2, color, TextFormatFlags.VerticalCenter); }
// Token: 0x060000F3 RID: 243 RVA: 0x00004B14 File Offset: 0x00002D14 public override Size GetPreferredSize(Size proposedSize) { base.GetPreferredSize(proposedSize); Size result; using (Graphics graphics = base.CreateGraphics()) { proposedSize = new Size(int.MaxValue, int.MaxValue); result = TextRenderer.MeasureText(graphics, this.Text, MetroFonts.Link(this.metroLinkSize, this.metroLinkWeight), proposedSize, MetroPaint.GetTextFormatFlags(this.TextAlign)); result.Width += 16; } return(result); }
// Token: 0x06000119 RID: 281 RVA: 0x0000519C File Offset: 0x0000339C public override Size GetPreferredSize(Size proposedSize) { base.GetPreferredSize(proposedSize); Size result; using (Graphics graphics = base.CreateGraphics()) { string text = (this.Text.Length > 0) ? this.Text : "MeasureText"; proposedSize = new Size(int.MaxValue, int.MaxValue); result = TextRenderer.MeasureText(graphics, text, MetroFonts.Link(this.metroLinkSize, this.metroLinkWeight), proposedSize, TextFormatFlags.VerticalCenter | TextFormatFlags.LeftAndRightPadding); result.Height += 4; } return(result); }
public override Size GetPreferredSize(Size proposedSize) { Size preferredSize; base.GetPreferredSize(proposedSize); using (var g = CreateGraphics()) { proposedSize = new Size(int.MaxValue, int.MaxValue); preferredSize = TextRenderer.MeasureText(g, Text, MetroFonts.Link(metroLinkSize, metroLinkWeight), proposedSize, MetroPaint.GetTextFormatFlags(TextAlign)); preferredSize.Width += 16; } return(preferredSize); }
public override Size GetPreferredSize(Size proposedSize) { Size preferredSize; base.GetPreferredSize(proposedSize); using (var g = CreateGraphics()) { string measureText = Text.Length > 0 ? Text : "MeasureText"; proposedSize = new Size(int.MaxValue, int.MaxValue); preferredSize = TextRenderer.MeasureText(g, measureText, MetroFonts.Link(metroLinkSize, metroLinkWeight), proposedSize, TextFormatFlags.Left | TextFormatFlags.LeftAndRightPadding | TextFormatFlags.VerticalCenter); preferredSize.Height += 4; } return(preferredSize); }
protected override void OnPaint(PaintEventArgs e) { Color backColor, foreColor; if (useCustomBackground) { backColor = BackColor; } else { backColor = MetroPaint.BackColor.Form(Theme); } if (useCustomForeColor) { foreColor = ForeColor; } else { if (isHovered && !isPressed && Enabled) { foreColor = MetroPaint.ForeColor.Link.Hover(Theme); } else if (isHovered && isPressed && Enabled) { foreColor = MetroPaint.ForeColor.Link.Press(Theme); } else if (!Enabled) { foreColor = MetroPaint.ForeColor.Link.Disabled(Theme); } else { foreColor = !useStyleColors?MetroPaint.ForeColor.Link.Normal(Theme) : MetroPaint.GetStyleColor(Style); } } e.Graphics.Clear(backColor); TextRenderer.DrawText(e.Graphics, Text, MetroFonts.Link(metroLinkSize, metroLinkWeight), ClientRectangle, foreColor, backColor, MetroPaint.GetTextFormatFlags(TextAlign)); if (false && isFocused) { ControlPaint.DrawFocusRectangle(e.Graphics, ClientRectangle); } }
protected virtual void OnPaintForeground(PaintEventArgs e) { if (useCustomForeColor) { foreColor = ForeColor; } else { if (isHovered && !isPressed && Enabled) { //foreColor = MetroPaint.ForeColor.Link.Hover(Theme); foreColor = MetroPaint.ForeColor.Link.Normal(Theme); } else if (isHovered && isPressed && Enabled) { foreColor = MetroPaint.ForeColor.Link.Press(Theme); } else if (!Enabled) { foreColor = MetroPaint.ForeColor.Link.Disabled(Theme); } else { foreColor = !useStyleColors?MetroPaint.ForeColor.Link.Hover(Theme) : MetroPaint.GetStyleColor(Style); } } TextRenderer.DrawText(e.Graphics, Text, MetroFonts.Link(metroLinkSize, metroLinkWeight), ClientRectangle, foreColor, MetroPaint.GetTextFormatFlags(TextAlign, !this.AutoSize)); OnCustomPaintForeground(new MetroPaintEventArgs(Color.Empty, foreColor, e.Graphics)); if (displayFocusRectangle && isFocused) { ControlPaint.DrawFocusRectangle(e.Graphics, ClientRectangle); } if (_image != null) { DrawIcon(e.Graphics); } }
// Token: 0x060001AD RID: 429 RVA: 0x000061E8 File Offset: 0x000043E8 protected override void OnPaint(PaintEventArgs e) { Color color; if (this.useCustomBackground) { color = this.BackColor; } else { color = MetroPaint.BackColor.Form(base.Theme); } Color foreColor; if (this.useCustomForeColor) { foreColor = this.ForeColor; } else if (this.isHovered && !this.isPressed && base.Enabled) { foreColor = MetroPaint.ForeColor.Link.Hover(base.Theme); } else if (this.isHovered && this.isPressed && base.Enabled) { foreColor = MetroPaint.ForeColor.Link.Press(base.Theme); } else if (!base.Enabled) { foreColor = MetroPaint.ForeColor.Link.Disabled(base.Theme); } else { foreColor = ((!this.useStyleColors) ? MetroPaint.ForeColor.Link.Normal(base.Theme) : MetroPaint.GetStyleColor(base.Style)); } e.Graphics.Clear(color); TextRenderer.DrawText(e.Graphics, this.Text, MetroFonts.Link(this.metroLinkSize, this.metroLinkWeight), base.ClientRectangle, foreColor, color, MetroPaint.GetTextFormatFlags(this.TextAlign)); }
// Token: 0x060000E6 RID: 230 RVA: 0x00004764 File Offset: 0x00002964 protected override void OnPaint(PaintEventArgs e) { Color color; if (this.useCustomBackground) { color = this.BackColor; } else { color = MetroPaint.BackColor.Form(base.Theme); } Color foreColor; Color color2; if (this.useCustomForeColor) { foreColor = this.ForeColor; if (this.isHovered && !this.isPressed && base.Enabled) { color2 = MetroPaint.BorderColor.CheckBox.Hover(base.Theme); } else if (this.isHovered && this.isPressed && base.Enabled) { color2 = MetroPaint.BorderColor.CheckBox.Press(base.Theme); } else if (!base.Enabled) { color2 = MetroPaint.BorderColor.CheckBox.Disabled(base.Theme); } else { color2 = MetroPaint.BorderColor.CheckBox.Normal(base.Theme); } } else if (this.isHovered && !this.isPressed && base.Enabled) { foreColor = MetroPaint.ForeColor.CheckBox.Hover(base.Theme); color2 = MetroPaint.BorderColor.CheckBox.Hover(base.Theme); } else if (this.isHovered && this.isPressed && base.Enabled) { foreColor = MetroPaint.ForeColor.CheckBox.Press(base.Theme); color2 = MetroPaint.BorderColor.CheckBox.Press(base.Theme); } else if (!base.Enabled) { foreColor = MetroPaint.ForeColor.CheckBox.Disabled(base.Theme); color2 = MetroPaint.BorderColor.CheckBox.Disabled(base.Theme); } else { foreColor = ((!this.useStyleColors) ? MetroPaint.ForeColor.CheckBox.Normal(base.Theme) : MetroPaint.GetStyleColor(base.Style)); color2 = MetroPaint.BorderColor.CheckBox.Normal(base.Theme); } e.Graphics.Clear(color); using (Pen pen = new Pen(color2)) { Rectangle rect = new Rectangle(0, base.Height / 2 - 6, 12, 12); e.Graphics.DrawRectangle(pen, rect); } if (base.Checked) { Color color3 = (base.CheckState == CheckState.Indeterminate) ? color2 : MetroPaint.GetStyleColor(base.Style); using (SolidBrush solidBrush = new SolidBrush(color3)) { Rectangle rect2 = new Rectangle(2, base.Height / 2 - 4, 9, 9); e.Graphics.FillRectangle(solidBrush, rect2); } } Rectangle bounds = new Rectangle(16, 0, base.Width - 16, base.Height); TextRenderer.DrawText(e.Graphics, this.Text, MetroFonts.Link(this.metroLinkSize, this.metroLinkWeight), bounds, foreColor, color, MetroPaint.GetTextFormatFlags(this.TextAlign)); }
public void ShowMenu() { menu.Font = MetroFonts.Link(FontSize, FontWeight); menu.Show(this, 0, Height); }
// Token: 0x0600010E RID: 270 RVA: 0x00004F38 File Offset: 0x00003138 protected override void OnDrawItem(DrawItemEventArgs e) { if (e.Index >= 0) { Color color; Color foreColor; if (e.State == (DrawItemState.NoAccelerator | DrawItemState.NoFocusRect) || e.State == DrawItemState.None) { color = MetroPaint.BackColor.Form(base.Theme); foreColor = MetroPaint.ForeColor.Link.Normal(base.Theme); } else { color = MetroPaint.GetStyleColor(base.Style); foreColor = MetroPaint.ForeColor.Tile.Normal(base.Theme); } using (SolidBrush solidBrush = new SolidBrush(color)) { e.Graphics.FillRectangle(solidBrush, new Rectangle(e.Bounds.Left, e.Bounds.Top, e.Bounds.Width, e.Bounds.Height)); } Rectangle bounds = new Rectangle(0, e.Bounds.Top, e.Bounds.Width, e.Bounds.Height); TextRenderer.DrawText(e.Graphics, base.GetItemText(base.Items[e.Index]), MetroFonts.Link(this.metroLinkSize, this.metroLinkWeight), bounds, foreColor, color, TextFormatFlags.VerticalCenter); return; } base.OnDrawItem(e); }
// Token: 0x06000314 RID: 788 RVA: 0x0000A9C4 File Offset: 0x00008BC4 protected override void OnPaint(PaintEventArgs e) { Color color; if (this.useCustomBackground) { color = this.BackColor; } else { color = MetroPaint.BackColor.Form(base.Theme); } Color foreColor; Color color2; if (this.isHovered && !this.isPressed && base.Enabled) { foreColor = MetroPaint.ForeColor.CheckBox.Hover(base.Theme); color2 = MetroPaint.BorderColor.CheckBox.Hover(base.Theme); } else if (this.isHovered && this.isPressed && base.Enabled) { foreColor = MetroPaint.ForeColor.CheckBox.Press(base.Theme); color2 = MetroPaint.BorderColor.CheckBox.Press(base.Theme); } else if (!base.Enabled) { foreColor = MetroPaint.ForeColor.CheckBox.Disabled(base.Theme); color2 = MetroPaint.BorderColor.CheckBox.Disabled(base.Theme); } else { foreColor = ((!this.useStyleColors) ? MetroPaint.ForeColor.CheckBox.Normal(base.Theme) : MetroPaint.GetStyleColor(base.Style)); color2 = MetroPaint.BorderColor.CheckBox.Normal(base.Theme); } e.Graphics.Clear(color); using (Pen pen = new Pen(color2)) { Rectangle rect = new Rectangle(this.DisplayStatus ? 30 : 0, 0, base.ClientRectangle.Width - (this.DisplayStatus ? 31 : 1), base.ClientRectangle.Height - 1); e.Graphics.DrawRectangle(pen, rect); } Color color3 = base.Checked ? MetroPaint.GetStyleColor(base.Style) : MetroPaint.BorderColor.CheckBox.Normal(base.Theme); using (SolidBrush solidBrush = new SolidBrush(color3)) { Rectangle rect2 = new Rectangle(this.DisplayStatus ? 32 : 2, 2, base.ClientRectangle.Width - (this.DisplayStatus ? 34 : 4), base.ClientRectangle.Height - 4); e.Graphics.FillRectangle(solidBrush, rect2); } using (SolidBrush solidBrush2 = new SolidBrush(color)) { int x = base.Checked ? (base.Width - 11) : (this.DisplayStatus ? 30 : 0); Rectangle rect3 = new Rectangle(x, 0, 11, base.ClientRectangle.Height); e.Graphics.FillRectangle(solidBrush2, rect3); } using (SolidBrush solidBrush3 = new SolidBrush(MetroPaint.BorderColor.CheckBox.Hover(base.Theme))) { int x2 = base.Checked ? (base.Width - 10) : (this.DisplayStatus ? 30 : 0); Rectangle rect4 = new Rectangle(x2, 0, 10, base.ClientRectangle.Height); e.Graphics.FillRectangle(solidBrush3, rect4); } if (this.DisplayStatus) { Rectangle bounds = new Rectangle(0, 0, 30, base.ClientRectangle.Height); TextRenderer.DrawText(e.Graphics, this.Text, MetroFonts.Link(this.metroLinkSize, this.metroLinkWeight), bounds, foreColor, color, MetroPaint.GetTextFormatFlags(this.TextAlign)); } }
protected virtual void OnPaintForeground(PaintEventArgs e) { Color color; Color color1; int num; int num1; int num2; int num3; int width; int width1; if (this.isHovered && !this.isPressed && base.Enabled) { color1 = MetroPaint.ForeColor.CheckBox.Hover(this.Theme); color = MetroPaint.BorderColor.CheckBox.Hover(this.Theme); } else if (this.isHovered && this.isPressed && base.Enabled) { color1 = MetroPaint.ForeColor.CheckBox.Press(this.Theme); color = MetroPaint.BorderColor.CheckBox.Press(this.Theme); } else if (base.Enabled) { color1 = (!this.useStyleColors ? MetroPaint.ForeColor.CheckBox.Normal(this.Theme) : MetroPaint.GetStyleColor(this.Style)); color = MetroPaint.BorderColor.CheckBox.Normal(this.Theme); } else { color1 = MetroPaint.ForeColor.CheckBox.Disabled(this.Theme); color = MetroPaint.BorderColor.CheckBox.Disabled(this.Theme); } using (Pen pen = new Pen(color)) { num1 = (this.DisplayStatus ? 30 : 0); int width2 = base.ClientRectangle.Width; num = (this.DisplayStatus ? 31 : 1); Rectangle clientRectangle = base.ClientRectangle; Rectangle rectangle = new Rectangle(num1, 0, width2 - num, clientRectangle.Height - 1); e.Graphics.DrawRectangle(pen, rectangle); } using (SolidBrush solidBrush = new SolidBrush((base.Checked ? MetroPaint.GetStyleColor(this.Style) : MetroPaint.BorderColor.CheckBox.Normal(this.Theme)))) { num3 = (this.DisplayStatus ? 32 : 2); int width3 = base.ClientRectangle.Width; num2 = (this.DisplayStatus ? 34 : 4); Rectangle clientRectangle1 = base.ClientRectangle; Rectangle rectangle1 = new Rectangle(num3, 2, width3 - num2, clientRectangle1.Height - 4); e.Graphics.FillRectangle(solidBrush, rectangle1); } Color backColor = this.BackColor; if (!this.useCustomBackColor) { backColor = MetroPaint.BackColor.Form(this.Theme); } using (SolidBrush solidBrush1 = new SolidBrush(backColor)) { if (base.Checked) { width = base.Width - 11; } else { width = (this.DisplayStatus ? 30 : 0); } int num4 = width; Rectangle clientRectangle2 = base.ClientRectangle; Rectangle rectangle2 = new Rectangle(num4, 0, 11, clientRectangle2.Height); e.Graphics.FillRectangle(solidBrush1, rectangle2); } using (SolidBrush solidBrush2 = new SolidBrush(MetroPaint.BorderColor.CheckBox.Hover(this.Theme))) { if (base.Checked) { width1 = base.Width - 10; } else { width1 = (this.DisplayStatus ? 30 : 0); } int num5 = width1; Rectangle clientRectangle3 = base.ClientRectangle; Rectangle rectangle3 = new Rectangle(num5, 0, 10, clientRectangle3.Height); e.Graphics.FillRectangle(solidBrush2, rectangle3); } if (this.DisplayStatus) { Rectangle clientRectangle4 = base.ClientRectangle; Rectangle rectangle4 = new Rectangle(0, 0, 30, clientRectangle4.Height); TextRenderer.DrawText(e.Graphics, this.Text, MetroFonts.Link(this.metroLinkSize, this.metroLinkWeight), rectangle4, color1, MetroPaint.GetTextFormatFlags(this.TextAlign)); } if (this.displayFocusRectangle && this.isFocused) { ControlPaint.DrawFocusRectangle(e.Graphics, base.ClientRectangle); } }
protected virtual void OnPaintForeground(PaintEventArgs e) { Color borderColor, foreColor; if (isHovered && !isPressed && Enabled) { foreColor = MetroPaint.ForeColor.CheckBox.Hover(Theme); borderColor = MetroPaint.BorderColor.CheckBox.Hover(Theme); } else if (isHovered && isPressed && Enabled) { foreColor = MetroPaint.ForeColor.CheckBox.Press(Theme); borderColor = MetroPaint.BorderColor.CheckBox.Press(Theme); } else if (!Enabled) { foreColor = MetroPaint.ForeColor.CheckBox.Disabled(Theme); borderColor = MetroPaint.BorderColor.CheckBox.Disabled(Theme); } else { foreColor = !useStyleColors?MetroPaint.ForeColor.CheckBox.Normal(Theme) : MetroPaint.GetStyleColor(Style); borderColor = MetroPaint.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 ? MetroPaint.GetStyleColor(Style) : MetroPaint.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 = MetroPaint.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(MetroPaint.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, MetroFonts.Link(metroLinkSize, metroLinkWeight), textRect, foreColor, MetroPaint.GetTextFormatFlags(TextAlign)); } if (displayFocusRectangle && isFocused) { ControlPaint.DrawFocusRectangle(e.Graphics, ClientRectangle); } }
protected override void OnPaint(PaintEventArgs e) { Color backColor, borderColor, foreColor; if (useCustomBackground) { backColor = BackColor; } else { backColor = MetroPaint.BackColor.Form(Theme); } if (isHovered && !isPressed && Enabled) { foreColor = MetroPaint.ForeColor.CheckBox.Hover(Theme); borderColor = MetroPaint.BorderColor.CheckBox.Hover(Theme); } else if (isHovered && isPressed && Enabled) { foreColor = MetroPaint.ForeColor.CheckBox.Press(Theme); borderColor = MetroPaint.BorderColor.CheckBox.Press(Theme); } else if (!Enabled) { foreColor = MetroPaint.ForeColor.CheckBox.Disabled(Theme); borderColor = MetroPaint.BorderColor.CheckBox.Disabled(Theme); } else { foreColor = !useStyleColors?MetroPaint.ForeColor.CheckBox.Normal(Theme) : MetroPaint.GetStyleColor(Style); borderColor = MetroPaint.BorderColor.CheckBox.Normal(Theme); } e.Graphics.Clear(backColor); using (Pen p = new Pen(borderColor)) { Rectangle boxRect = new Rectangle(0, Height / 2 - 6, 12, 12); e.Graphics.DrawRectangle(p, boxRect); } if (Checked) { Color fillColor = CheckState == CheckState.Indeterminate ? borderColor : MetroPaint.GetStyleColor(Style); using (SolidBrush b = new SolidBrush(fillColor)) { Rectangle boxRect = new Rectangle(2, Height / 2 - 4, 9, 9); e.Graphics.FillRectangle(b, boxRect); } } Rectangle textRect = new Rectangle(16, 0, Width - 16, Height); TextRenderer.DrawText(e.Graphics, Text, MetroFonts.Link(metroLinkSize, metroLinkWeight), textRect, foreColor, backColor, MetroPaint.GetTextFormatFlags(TextAlign)); if (false && isFocused) { ControlPaint.DrawFocusRectangle(e.Graphics, ClientRectangle); } }