namespace VaioxOnline { using System; using System.ComponentModel; using System.Diagnostics; using System.Drawing; using System.Drawing.Drawing2D; using System.Drawing.Text; using System.Runtime.CompilerServices; using System.Threading; using System.Windows.Forms; [DefaultEvent("CheckedChanged")] internal class FlatCheckBox : Control { private Color _BaseColor = Color.FromArgb(0x2d, 0x2f, 0x31); private Color _BorderColor = Helpers._FlatColor; private bool _Checked; private Color _TextColor = Color.FromArgb(0xf3, 0xf3, 0xf3); private int H; private _Options O; private MouseState State = MouseState.None; private int W; [field: CompilerGenerated, DebuggerBrowsable(0)] public event CheckedChangedEventHandler CheckedChanged; public FlatCheckBox() { base.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw | ControlStyles.UserPaint, true); this.DoubleBuffered = true; this.BackColor = Color.FromArgb(60, 70, 0x49); this.Cursor = Cursors.Hand; this.Font = new Font("Segoe UI", 10f); base.Size = new Size(0x70, 0x16); } protected override void OnClick(EventArgs e) { this._Checked = !this._Checked; CheckedChangedEventHandler checkedChangedEvent = this.CheckedChangedEvent; if (checkedChangedEvent != null) { checkedChangedEvent(this); } base.OnClick(e); } protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); this.State = MouseState.Down; base.Invalidate(); } protected override void OnMouseEnter(EventArgs e) { base.OnMouseEnter(e); this.State = MouseState.Over; base.Invalidate(); } protected override void OnMouseLeave(EventArgs e) { base.OnMouseLeave(e); this.State = MouseState.None; base.Invalidate(); } protected override void OnMouseUp(MouseEventArgs e) { base.OnMouseUp(e); this.State = MouseState.Over; base.Invalidate(); } protected override void OnPaint(PaintEventArgs e) { Helpers.B = new Bitmap(base.Width, base.Height); Helpers.G = Graphics.FromImage(Helpers.B); this.W = base.Width - 1; this.H = base.Height - 1; Rectangle rect = new Rectangle(0, 2, base.Height - 5, base.Height - 5); Graphics g = Helpers.G; g.SmoothingMode = SmoothingMode.HighQuality; g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; g.Clear(this.BackColor); switch (this.O) { case _Options.Style1: g.FillRectangle(new SolidBrush(this._BaseColor), rect); switch (this.State) { case MouseState.Over: g.DrawRectangle(new Pen(this._BorderColor), rect); goto Label_00EC; case MouseState.Down: g.DrawRectangle(new Pen(this._BorderColor), rect); goto Label_00EC; } break; case _Options.Style2: g.FillRectangle(new SolidBrush(this._BaseColor), rect); switch (this.State) { case MouseState.Over: g.DrawRectangle(new Pen(this._BorderColor), rect); g.FillRectangle(new SolidBrush(Color.FromArgb(0x76, 0xd5, 170)), rect); break; case MouseState.Down: g.DrawRectangle(new Pen(this._BorderColor), rect); g.FillRectangle(new SolidBrush(Color.FromArgb(0x76, 0xd5, 170)), rect); break; } if (this.Checked) { g.DrawString("\x00fc", new Font("Wingdings", 18f), new SolidBrush(this._BorderColor), new Rectangle(5, 7, this.H - 9, this.H - 9), Helpers.CenterSF); } if (!base.Enabled) { g.FillRectangle(new SolidBrush(Color.FromArgb(0x36, 0x3a, 0x3d)), rect); g.DrawString(this.Text, this.Font, new SolidBrush(Color.FromArgb(0x30, 0x77, 0x5b)), new Rectangle(20, 2, this.W, this.H), Helpers.NearSF); } g.DrawString(this.Text, this.Font, new SolidBrush(this._TextColor), new Rectangle(20, 2, this.W, this.H), Helpers.NearSF); goto Label_038B; default: goto Label_038B; } Label_00EC: if (this.Checked) { g.DrawString("\x00fc", new Font("Wingdings", 18f), new SolidBrush(this._BorderColor), new Rectangle(5, 7, this.H - 9, this.H - 9), Helpers.CenterSF); } if (!base.Enabled) { g.FillRectangle(new SolidBrush(Color.FromArgb(0x36, 0x3a, 0x3d)), rect); g.DrawString(this.Text, this.Font, new SolidBrush(Color.FromArgb(140, 0x8e, 0x8f)), new Rectangle(20, 2, this.W, this.H), Helpers.NearSF); } g.DrawString(this.Text, this.Font, new SolidBrush(this._TextColor), new Rectangle(20, 2, this.W, this.H), Helpers.NearSF); Label_038B: g = null; base.OnPaint(e); Helpers.G.Dispose(); e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; e.Graphics.DrawImageUnscaled(Helpers.B, 0, 0); Helpers.B.Dispose(); } protected override void OnResize(EventArgs e) { base.OnResize(e); base.Height = 0x16; } protected override void OnTextChanged(EventArgs e) { base.OnTextChanged(e); base.Invalidate(); } [Category("Colors")] public Color BaseColor { get => this._BaseColor set { this._BaseColor = value; } } [Category("Colors")] public Color BorderColor { get => this._BorderColor set { this._BorderColor = value; } } public bool Checked { get => this._Checked set { this._Checked = value; base.Invalidate(); } } [Category("Options")] public _Options Options { get => this.O set { this.O = value; } } [Flags] public enum _Options { Style1, Style2 } public delegate void CheckedChangedEventHandler(object sender); } }