-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInfectEngine.cs
109 lines (95 loc) · 3.2 KB
/
InfectEngine.cs
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
using System;
using System.Drawing;
using System.Drawing.Text;
using System.Windows.Forms;
using System.Media;
using System.Runtime.InteropServices;
namespace InfecNet
{
public partial class InfectEngine : Form
{
SoundPlayer soundPlayer;
private Keys[] letterKeys = new Keys[] {
Keys.A,
Keys.B,
Keys.C,
Keys.D,
Keys.E,
Keys.F,
Keys.G,
Keys.H,
Keys.I,
Keys.J,
Keys.K,
Keys.L,
Keys.M,
Keys.N,
Keys.O,
Keys.P,
Keys.Q,
Keys.R,
Keys.S,
Keys.T,
Keys.U,
Keys.V,
Keys.W,
Keys.X,
Keys.Y,
Keys.Z
};
Keys key;
Random random;
public static InfectEngine CreateEngine (){
return new InfectEngine ();
}
private InfectEngine()
{
InitializeComponent();
Init ();
this.ShowInTaskbar = false;
this.KeyDown += OnKeyDown;
}
private void OnKeyDown (object sender, KeyEventArgs args){
if (args.KeyCode == key){
Application.Exit ();
}
}
private void Init (){
this.ControlBox = false;
this.Load += FormOnLoad;
soundPlayer = new SoundPlayer ($"BGM/Max Brhon - Cyberpunk [NCS Release].wav");
AddIMG ();
AddText ();
random = new Random ();
key = letterKeys [random.Next (0, letterKeys.Length)];
}
private void AddText (){
Label label = new Label ();
label.Text = "Welcome to InfecNet! You cant close this until you press 1 button on your keyboard!";
label.ForeColor = Color.Red;
label.Anchor = AnchorStyles.Top;
PrivateFontCollection pfc = new PrivateFontCollection();
pfc.AddFontFile($"Font/plasdrip.ttf");
label.Font = new Font (pfc.Families[0], 18, FontStyle.Bold);
label.TextAlign = ContentAlignment.TopCenter;
this.Controls.Add (label);
label.Size = new Size (label.Parent.ClientSize.Width, 100);
label.Location = new Point ((label.Parent.ClientSize.Width / 2) - (label.Width / 2), 0);
}
private void AddIMG (){
PictureBox pic = new PictureBox ();
pic.Anchor = AnchorStyles.None;
pic.Image = Image.FromFile ($"UI/pngfind.com-red-skull-png-616733.png");
pic.Size = new Size (400, 600);
pic.SizeMode = PictureBoxSizeMode.StretchImage;
this.Controls.Add (pic);
pic.Location = new Point ((pic.Parent.ClientSize.Width / 2) - (pic.Width / 2),
(pic.Parent.ClientSize.Height / 2) - (pic.Height / 2) + 20);
pic.Refresh ();
}
private void FormOnLoad (object sender, EventArgs e){
this.BackColor = Color.Black;
soundPlayer.PlayLooping ();
}
}
}