aboutsummaryrefslogtreecommitdiff
path: root/Histacom2/OS/Win95/Win95Apps/Win95Installer.cs
blob: 6f8a63efd518698d72169dd48d507ce7ce4c1989 (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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Histacom2.OS.Win95.Win95Apps
{
    public partial class Win95Installer : UserControl
    {
        public int installStage = 0;
        private string prog;
        private Timer installbar = new Timer();

        public event EventHandler InstallCompleted;

        protected void OnInstallCompleted(EventArgs e)
        {
            if (InstallCompleted != null) InstallCompleted(this, e);
        }

        public Win95Installer(string progName)
        {
            InitializeComponent();
            label1.Font = new Font(TitleScreen.pfc.Families[0], 16F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)));
            label2.Font = new Font(TitleScreen.pfc.Families[0], 16F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)));
            label3.Font = new Font(TitleScreen.pfc.Families[0], 16F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)));
            label4.Font = new Font(TitleScreen.pfc.Families[0], 16F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)));
            label5.Font = new Font(TitleScreen.pfc.Families[0], 16F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)));
            label6.Font = new Font(TitleScreen.pfc.Families[0], 16F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)));
            label7.Font = new Font(TitleScreen.pfc.Families[0], 16F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)));
            checkBox1.Font = new Font(TitleScreen.pfc.Families[0], 16F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)));
            cancelbutton1.Paint += (sender, args) => Engine.Paintbrush.PaintClassicBorders(sender, args, 2);
            nextbutton1.Paint += (sender, args) => Engine.Paintbrush.PaintClassicBorders(sender, args, 2);
            backbutton1.Paint += (sender, args) => Engine.Paintbrush.PaintClassicBorders(sender, args, 2);
            prog = progName;
        }

        private void Win95Installer_Load(object sender, EventArgs e)
        {
            label1.Text = label1.Text.Replace("GenericName", prog);
            label3.Text = label3.Text.Replace("GenericName", prog);
            label4.Text = label4.Text.Replace("GenericName", prog);
            label7.Text = label7.Text.Replace("GenericName", prog);
            installbar.Tick += Installbar_Tick;
        }

        private void Installbar_Tick(object sender, EventArgs e)
        {
            if (progressBar1.Value < 100)
            {
                progressBar1.Value = progressBar1.Value + 1;
            }
            else
            {
                OnInstallCompleted(EventArgs.Empty);
                panel3.Hide();
                panel4.Show();
                backbutton1.Hide();
                nextbutton1.Hide();
                cancelbutton1.Enabled = true;
                cancelbutton1.Text = "Finish";
                installbar.Stop();
            }
        }

        private void nextbutton1_Click(object sender, EventArgs e)
        {
            switch (installStage)
            {
                case 0:
                    label1.Hide();
                    panel1.Show();
                    backbutton1.Enabled = true;
                    if (!checkBox1.Checked) nextbutton1.Enabled = false;
                    installStage = 1;
                    break;
                case 1:
                    panel1.Hide();
                    panel2.Show();
                    installStage = 2;
                    break;
                case 2:
                    panel2.Hide();
                    panel3.Show();
                    backbutton1.Enabled = false;
                    nextbutton1.Enabled = false;
                    cancelbutton1.Enabled = false;
                    installbar.Start();
                    break;
            }
        }

        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            if (checkBox1.Checked) nextbutton1.Enabled = true;
            else nextbutton1.Enabled = false;
        }

        private void backbutton1_Click(object sender, EventArgs e)
        {
            switch (installStage)
            {
                case 1:
                    panel1.Hide();
                    label1.Show();
                    backbutton1.Enabled = false;
                    nextbutton1.Enabled = true;
                    installStage = 0;
                    break;
                case 2:
                    panel2.Hide();
                    panel1.Show();
                    if (!checkBox1.Checked) nextbutton1.Enabled = false;
                    installStage = 1;
                    break;
            }
        }

        private void cancelbutton1_Click(object sender, EventArgs e)
        {
            ParentForm.Close();
        }
    }
}