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.Windows.Forms;

    internal class FlatAlertBox : Control
    {
        [CompilerGenerated, DebuggerBrowsable(DebuggerBrowsableState.Never), AccessedThroughProperty("T")]
        private Timer _T;
        private string _Text;
        private Color ErrorColor = Color.FromArgb(0x57, 0x47, 0x47);
        private Color ErrorText = Color.FromArgb(0xfe, 0x8e, 0x7a);
        private int H;
        private Color InfoColor = Color.FromArgb(70, 0x5b, 0x5e);
        private Color InfoText = Color.FromArgb(0x61, 0xb9, 0xba);
        private _Kind K;
        private MouseState State = MouseState.None;
        private Color SuccessColor = Color.FromArgb(60, 0x55, 0x4f);
        private Color SuccessText = Color.FromArgb(0x23, 0xa9, 110);
        private int W;
        private int X;

        public FlatAlertBox()
        {
            base.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw | ControlStyles.UserPaint, true);
            this.DoubleBuffered = true;
            this.BackColor = Color.FromArgb(60, 70, 0x49);
            base.Size = new Size(0x240, 0x2a);
            base.Location = new Point(10, 0x3d);
            this.Font = new Font("Segoe UI", 10f);
            this.Cursor = Cursors.Hand;
        }

        protected override void OnClick(EventArgs e)
        {
            base.OnClick(e);
            this.Visible = false;
        }

        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 OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);
            this.X = e.X;
            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, 0, this.W, this.H);
            Graphics g = Helpers.G;
            g.SmoothingMode = SmoothingMode.HighQuality;
            g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
            g.Clear(this.BackColor);
            switch (this.K)
            {
                case _Kind.Success:
                    g.FillRectangle(new SolidBrush(this.SuccessColor), rect);
                    g.FillEllipse(new SolidBrush(this.SuccessText), new Rectangle(8, 9, 0x18, 0x18));
                    g.FillEllipse(new SolidBrush(this.SuccessColor), new Rectangle(10, 11, 20, 20));
                    g.DrawString("\x00fc", new Font("Wingdings", 22f), new SolidBrush(this.SuccessText), new Rectangle(7, 7, this.W, this.H), Helpers.NearSF);
                    g.DrawString(this.Text, this.Font, new SolidBrush(this.SuccessText), new Rectangle(0x30, 12, this.W, this.H), Helpers.NearSF);
                    g.FillEllipse(new SolidBrush(Color.FromArgb(0x23, Color.Black)), new Rectangle(this.W - 30, this.H - 0x1d, 0x11, 0x11));
                    g.DrawString("r", new Font("Marlett", 8f), new SolidBrush(this.SuccessColor), new Rectangle(this.W - 0x1c, 0x10, this.W, this.H), Helpers.NearSF);
                    if (this.State == MouseState.Over)
                    {
                        g.DrawString("r", new Font("Marlett", 8f), new SolidBrush(Color.FromArgb(0x19, Color.White)), new Rectangle(this.W - 0x1c, 0x10, this.W, this.H), Helpers.NearSF);
                    }
                    break;

                case _Kind.Error:
                    g.FillRectangle(new SolidBrush(this.ErrorColor), rect);
                    g.FillEllipse(new SolidBrush(this.ErrorText), new Rectangle(8, 9, 0x18, 0x18));
                    g.FillEllipse(new SolidBrush(this.ErrorColor), new Rectangle(10, 11, 20, 20));
                    g.DrawString("r", new Font("Marlett", 16f), new SolidBrush(this.ErrorText), new Rectangle(6, 11, this.W, this.H), Helpers.NearSF);
                    g.DrawString(this.Text, this.Font, new SolidBrush(this.ErrorText), new Rectangle(0x30, 12, this.W, this.H), Helpers.NearSF);
                    g.FillEllipse(new SolidBrush(Color.FromArgb(0x23, Color.Black)), new Rectangle(this.W - 0x20, this.H - 0x1d, 0x11, 0x11));
                    g.DrawString("r", new Font("Marlett", 8f), new SolidBrush(this.ErrorColor), new Rectangle(this.W - 30, 0x11, this.W, this.H), Helpers.NearSF);
                    if (this.State == MouseState.Over)
                    {
                        g.DrawString("r", new Font("Marlett", 8f), new SolidBrush(Color.FromArgb(0x19, Color.White)), new Rectangle(this.W - 30, 15, this.W, this.H), Helpers.NearSF);
                    }
                    break;

                case _Kind.Info:
                    g.FillRectangle(new SolidBrush(this.InfoColor), rect);
                    g.FillEllipse(new SolidBrush(this.InfoText), new Rectangle(8, 9, 0x18, 0x18));
                    g.FillEllipse(new SolidBrush(this.InfoColor), new Rectangle(10, 11, 20, 20));
                    g.DrawString("\x00a1", new Font("Segoe UI", 20f, FontStyle.Bold), new SolidBrush(this.InfoText), new Rectangle(12, -4, this.W, this.H), Helpers.NearSF);
                    g.DrawString(this.Text, this.Font, new SolidBrush(this.InfoText), new Rectangle(0x30, 12, this.W, this.H), Helpers.NearSF);
                    g.FillEllipse(new SolidBrush(Color.FromArgb(0x23, Color.Black)), new Rectangle(this.W - 0x20, this.H - 0x1d, 0x11, 0x11));
                    g.DrawString("r", new Font("Marlett", 8f), new SolidBrush(this.InfoColor), new Rectangle(this.W - 30, 0x11, this.W, this.H), Helpers.NearSF);
                    if (this.State == MouseState.Over)
                    {
                        g.DrawString("r", new Font("Marlett", 8f), new SolidBrush(Color.FromArgb(0x19, Color.White)), new Rectangle(this.W - 30, 0x11, this.W, this.H), Helpers.NearSF);
                    }
                    break;
            }
            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 = 0x2a;
        }

        protected override void OnTextChanged(EventArgs e)
        {
            base.OnTextChanged(e);
            base.Invalidate();
        }

        public void ShowControl(_Kind Kind, string Str, int Interval)
        {
            this.K = Kind;
            this.Text = Str;
            this.Visible = true;
            this.T = new Timer();
            this.T.Interval = Interval;
            this.T.Enabled = true;
        }

        private void T_Tick(object sender, EventArgs e)
        {
            this.Visible = false;
            this.T.Enabled = false;
            this.T.Dispose();
        }

        [Category("Options")]
        public _Kind kind
        {
            get => 
                this.K
            set
            {
                this.K = value;
            }
        }

        private Timer T
        {
            [CompilerGenerated]
            get => 
                this._T
            [MethodImpl(MethodImplOptions.Synchronized), CompilerGenerated]
            set
            {
                EventHandler handler = new EventHandler(this.T_Tick);
                Timer timer = this._T;
                if (timer != null)
                {
                    timer.Tick -= handler;
                }
                this._T = value;
                timer = this._T;
                if (timer != null)
                {
                    timer.Tick += handler;
                }
            }
        }

        [Category("Options")]
        public override string Text
        {
            get => 
                base.Text
            set
            {
                base.Text = value;
                if (this._Text > null)
                {
                    this._Text = value;
                }
            }
        }

        [Category("Options")]
        public bool Visible
        {
            get => 
                !base.Visible
            set
            {
                base.Visible = value;
            }
        }

        [Flags]
        public enum _Kind
        {
            Success,
            Error,
            Info
        }
    }
}

