aboutsummaryrefslogtreecommitdiff
path: root/TimeHACK.Main/OS/Win95/Win95Apps/WinClassicTimeDistorter.cs
blob: b0542ba0988df9d36213fb6597c2804f41c18562 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System;
using System.Windows.Forms;
using TimeHACK.Engine;
using TimeHACK.Engine.Template;

namespace TimeHACK.OS.Win95
{
    public partial class WinClassicTimeDistorter : UserControl
    {
        private int _counter;
        private Form _action;

        public WinClassicTimeDistorter(string currentYear, string yearToTravel, int counter, Form action = null)
        {
            InitializeComponent();
            
            btnGo.Paint += (sender, args) => Paintbrush.PaintClassicBorders(sender, args, 2);
            lblYear.Text = currentYear;
            lblDestYear.Text = yearToTravel;
            _action = action;
            _counter = counter;
        }

        private void btnGo_Click(object sender, EventArgs e)
        {
            lblCountDown.Visible = true;
            btnGo.Enabled = false;
            countDownTimer.Start();

            lblCountDown.Text = $"Preparing to travel... ETA: {_counter.ToString()} seconds";
        }

        private void countDownTimer_Tick(object sender, EventArgs e)
        {
            _counter--;

            if (_counter == 0)
            {
                countDownTimer.Stop();

                if (_action != null)
                    _action.ShowDialog();
            }
            lblCountDown.Text = $"Preparing to travel... ETA: {_counter.ToString()} seconds";
        }
    }
}