namespace VaioxOnline { using Microsoft.VisualBasic.CompilerServices; 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("Scroll")] internal class FlatTrackBar : Control { private Color _HatchColor = Color.FromArgb(0x17, 0x94, 0x5c); private int _Maximum = 10; private int _Minimum; private bool _ShowValue = false; private Color _TrackColor = Helpers._FlatColor; private int _Value; private Color BaseColor = Color.FromArgb(0x2d, 0x2f, 0x31); private bool Bool; private int H; private Rectangle Knob; private Color SliderColor = Color.FromArgb(0x19, 0x1b, 0x1d); private _Style Style_; private Rectangle Track; private int Val; private int W; [field: CompilerGenerated, DebuggerBrowsable(0)] public event ScrollEventHandler Scroll; public FlatTrackBar() { base.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw | ControlStyles.UserPaint, true); this.DoubleBuffered = true; base.Height = 0x12; this.BackColor = Color.FromArgb(60, 70, 0x49); } protected override void OnKeyDown(KeyEventArgs e) { base.OnKeyDown(e); if (e.KeyCode == Keys.Subtract) { if (this.Value != 0) { this.Value--; } } else if ((e.KeyCode == Keys.Add) && (this.Value != this._Maximum)) { this.Value++; } } protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); if (e.Button == MouseButtons.Left) { this.Val = (int) Math.Round((double) ((((double) (this._Value - this._Minimum)) / ((double) (this._Maximum - this._Minimum))) * (base.Width - 11))); this.Track = new Rectangle(this.Val, 0, 10, 20); this.Bool = this.Track.Contains(e.Location); } } protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); if ((this.Bool && (e.X > -1)) && (e.X < (base.Width + 1))) { this.Value = this._Minimum + ((int) Math.Round((double) ((this._Maximum - this._Minimum) * (((double) e.X) / ((double) base.Width))))); } } protected override void OnMouseUp(MouseEventArgs e) { base.OnMouseUp(e); this.Bool = false; } 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(1, 6, this.W - 2, 8); GraphicsPath path = new GraphicsPath(); GraphicsPath path2 = new GraphicsPath(); Graphics g = Helpers.G; g.SmoothingMode = SmoothingMode.HighQuality; g.PixelOffsetMode = PixelOffsetMode.HighQuality; g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; g.Clear(this.BackColor); this.Val = (int) Math.Round((double) ((((double) (this._Value - this._Minimum)) / ((double) (this._Maximum - this._Minimum))) * (this.W - 10))); this.Track = new Rectangle(this.Val, 0, 10, 20); this.Knob = new Rectangle(this.Val, 4, 11, 14); path.AddRectangle(rect); g.SetClip(path); g.FillRectangle(new SolidBrush(this.BaseColor), new Rectangle(0, 7, this.W, 8)); g.FillRectangle(new SolidBrush(this._TrackColor), new Rectangle(0, 7, this.Track.X + this.Track.Width, 8)); g.ResetClip(); HatchBrush brush = new HatchBrush(HatchStyle.Plaid, this.HatchColor, this._TrackColor); g.FillRectangle(brush, new Rectangle(-10, 7, this.Track.X + this.Track.Width, 8)); switch (this.Style) { case _Style.Slider: path2.AddRectangle(this.Track); g.FillPath(new SolidBrush(this.SliderColor), path2); break; case _Style.Knob: path2.AddEllipse(this.Knob); g.FillPath(new SolidBrush(this.SliderColor), path2); break; } if (this.ShowValue) { StringFormat format = new StringFormat { Alignment = StringAlignment.Far, LineAlignment = StringAlignment.Far }; g.DrawString(Conversions.ToString(this.Value), new Font("Segoe UI", 8f), Brushes.White, new Rectangle(1, 6, this.W, this.H), format); } 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 = 0x17; } protected override void OnTextChanged(EventArgs e) { base.OnTextChanged(e); base.Invalidate(); } [Category("Colors")] public Color HatchColor { get => this._HatchColor set { this._HatchColor = value; } } public int Maximum { get => this._Maximum set { if (value < 0) { } this._Maximum = value; if (value < this._Value) { this._Value = value; } if (value < this._Minimum) { this._Minimum = value; } base.Invalidate(); } } public int Minimum { get { int num; return num; } set { if (value < 0) { } this._Minimum = value; if (value > this._Value) { this._Value = value; } if (value > this._Maximum) { this._Maximum = value; } base.Invalidate(); } } public bool ShowValue { get => this._ShowValue set { this._ShowValue = value; } } public _Style Style { get => this.Style_ set { this.Style_ = value; } } [Category("Colors")] public Color TrackColor { get => this._TrackColor set { this._TrackColor = value; } } public int Value { get => this._Value set { if (value != this._Value) { if ((value > this._Maximum) || (value < this._Minimum)) { } this._Value = value; base.Invalidate(); ScrollEventHandler scrollEvent = this.ScrollEvent; if (scrollEvent != null) { scrollEvent(this); } } } } [Flags] public enum _Style { Slider, Knob } public delegate void ScrollEventHandler(object sender); } }