namespace VaioxOnline { using Microsoft.VisualBasic.CompilerServices; using System; using System.ComponentModel; using System.Drawing; using System.Drawing.Drawing2D; using System.Drawing.Text; using System.Windows.Forms; internal class FlatTabControl : TabControl { private Color _ActiveColor = Helpers._FlatColor; private Color _BaseColor = Color.FromArgb(0x2d, 0x2f, 0x31); private Color BGColor = Color.FromArgb(60, 70, 0x49); private int H; private int W; public FlatTabControl() { base.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw | ControlStyles.UserPaint, true); this.DoubleBuffered = true; this.BackColor = Color.FromArgb(60, 70, 0x49); this.Font = new Font("Segoe UI", 10f); base.SizeMode = TabSizeMode.Fixed; base.ItemSize = new Size(120, 40); } protected override void CreateHandle() { base.CreateHandle(); base.Alignment = TabAlignment.Top; } 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; Graphics g = Helpers.G; g.SmoothingMode = SmoothingMode.HighQuality; g.PixelOffsetMode = PixelOffsetMode.HighQuality; g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; g.Clear(this._BaseColor); try { base.SelectedTab.BackColor = this.BGColor; } catch (Exception exception1) { ProjectData.SetProjectError(exception1); ProjectData.ClearProjectError(); } int num = base.TabCount - 1; for (int i = 0; i <= num; i++) { Rectangle rectangle = new Rectangle(new Point(base.GetTabRect(i).Location.X + 2, base.GetTabRect(i).Location.Y), new Size(base.GetTabRect(i).Width, base.GetTabRect(i).Height)); Rectangle rect = new Rectangle(rectangle.Location, new Size(rectangle.Width, rectangle.Height)); if (i == base.SelectedIndex) { g.FillRectangle(new SolidBrush(this._BaseColor), rect); g.FillRectangle(new SolidBrush(this._ActiveColor), rect); if (base.ImageList > null) { try { if (base.ImageList.Images[base.TabPages[i].ImageIndex] > null) { g.DrawImage(base.ImageList.Images[base.TabPages[i].ImageIndex], new Point(rect.Location.X + 8, rect.Location.Y + 6)); g.DrawString(" " + base.TabPages[i].Text, this.Font, Brushes.White, rect, Helpers.CenterSF); } else { g.DrawString(base.TabPages[i].Text, this.Font, Brushes.White, rect, Helpers.CenterSF); } } catch (Exception exception3) { ProjectData.SetProjectError(exception3); Exception exception = exception3; throw new Exception(exception.Message); } } else { g.DrawString(base.TabPages[i].Text, this.Font, Brushes.White, rect, Helpers.CenterSF); } } else { StringFormat format; g.FillRectangle(new SolidBrush(this._BaseColor), rect); if (base.ImageList > null) { try { if (base.ImageList.Images[base.TabPages[i].ImageIndex] > null) { g.DrawImage(base.ImageList.Images[base.TabPages[i].ImageIndex], new Point(rect.Location.X + 8, rect.Location.Y + 6)); format = new StringFormat { LineAlignment = StringAlignment.Center, Alignment = StringAlignment.Center }; g.DrawString(" " + base.TabPages[i].Text, this.Font, new SolidBrush(Color.White), rect, format); } else { format = new StringFormat { LineAlignment = StringAlignment.Center, Alignment = StringAlignment.Center }; g.DrawString(base.TabPages[i].Text, this.Font, new SolidBrush(Color.White), rect, format); } } catch (Exception exception4) { ProjectData.SetProjectError(exception4); Exception exception2 = exception4; throw new Exception(exception2.Message); } } else { format = new StringFormat { LineAlignment = StringAlignment.Center, Alignment = StringAlignment.Center }; g.DrawString(base.TabPages[i].Text, this.Font, new SolidBrush(Color.White), rect, format); } } } g = null; base.OnPaint(e); Helpers.G.Dispose(); e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; e.Graphics.DrawImageUnscaled(Helpers.B, 0, 0); Helpers.B.Dispose(); } [Category("Colors")] public Color ActiveColor { get => this._ActiveColor set { this._ActiveColor = value; } } [Category("Colors")] public Color BaseColor { get => this._BaseColor set { this._BaseColor = value; } } } }