namespace PerpetuumSoft.Widgets.Licensing
{
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Windows.Forms;

    internal class WarningForm : Form
    {
        private IContainer components;
        private Button continueButton;
        private int restTime = 3;
        private TextBox textBox1;
        private Timer timer1;

        public WarningForm()
        {
            this.InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            base.Close();
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            this.components = new Container();
            this.continueButton = new Button();
            this.timer1 = new Timer(this.components);
            this.textBox1 = new TextBox();
            base.SuspendLayout();
            this.continueButton.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
            this.continueButton.DialogResult = DialogResult.Cancel;
            this.continueButton.Enabled = false;
            this.continueButton.set_FlatStyle(3);
            this.continueButton.Location = new Point(8, 120);
            this.continueButton.Name = "continueButton";
            this.continueButton.Size = new Size(0x60, 0x17);
            this.continueButton.TabIndex = 1;
            this.continueButton.Text = "Continue";
            this.continueButton.Click += new EventHandler(this.button1_Click);
            this.timer1.Interval = 0x3e8;
            this.timer1.Tick += new EventHandler(this.timer1_Tick);
            this.textBox1.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Top;
            this.textBox1.set_AutoSize(false);
            this.textBox1.Font = new Font("Microsoft Sans Serif", 9.75f, FontStyle.Regular, (GraphicsUnit) 3, 0xcc);
            this.textBox1.Location = new Point(8, 8);
            this.textBox1.Multiline = true;
            this.textBox1.Name = "textBox1";
            this.textBox1.ReadOnly = true;
            this.textBox1.Size = new Size(0x1a0, 0x68);
            this.textBox1.TabIndex = 2;
            this.textBox1.Text = "The program has detected that you are possibly using one and the same license key on more than one computer. In order to use this program on this computer, you should acquire an additional license. To do that, please contact PerpetuumSoft at sales@PerpetuumSoft.com";
            this.set_AutoScaleBaseSize(new Size(5, 13));
            base.ClientSize = new Size(0x1b2, 0x98);
            base.ControlBox = false;
            base.Controls.Add(this.textBox1);
            base.Controls.Add(this.continueButton);
            base.FormBorderStyle = FormBorderStyle.FixedDialog;
            base.MaximizeBox = false;
            base.MinimizeBox = false;
            base.Name = "WarningForm";
            base.set_StartPosition(1);
            this.Text = "Warning Form";
            base.Closing += new CancelEventHandler(this.WarningForm_Closing);
            base.add_VisibleChanged(new EventHandler(this.WarningForm_VisibleChanged));
            base.ResumeLayout(false);
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            this.restTime--;
            this.continueButton.Text = "Continue (" + this.restTime.ToString() + ")";
            if (this.restTime == 0)
            {
                this.timer1.Enabled = false;
                this.continueButton.Enabled = true;
            }
        }

        private void WarningForm_Closing(object sender, CancelEventArgs e)
        {
            e.Cancel = this.restTime != 0;
        }

        private void WarningForm_VisibleChanged(object sender, EventArgs e)
        {
            if (base.Visible)
            {
                this.timer1.Enabled = true;
            }
        }
    }
}
