-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLockOutWindow.cs
More file actions
53 lines (44 loc) · 1.42 KB
/
LockOutWindow.cs
File metadata and controls
53 lines (44 loc) · 1.42 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
namespace AutoLogout
{
public partial class LockoutWindow : Form
{
private readonly Label instructions;
public LockoutWindow(CountdownTimer parent) {
Text = "Pause screen";
Icon = new Icon("Resources/icon-light.ico");
FormBorderStyle = FormBorderStyle.None;
ShowInTaskbar = false;
StartPosition = FormStartPosition.Manual;
BackColor = Color.Black;
AutoScaleMode = AutoScaleMode.Dpi;
AutoScaleDimensions = new SizeF(96F, 96F);
instructions = new Label {
Text = "Timer paused. Click anywhere to show the timer.",
AutoSize = true,
ForeColor = Color.DimGray,
TextAlign = ContentAlignment.MiddleCenter
};
instructions.Click += parent.ReassertTopMost;
Controls.Add(instructions);
Shown += OnShown;
Click += parent.ReassertTopMost;
}
private void OnShown(object? sender, EventArgs? e){
Location = new Point(0, 0);
TopMost = false;
TopMost = true;
if(Screen.PrimaryScreen != null) {
Width = Screen.PrimaryScreen.Bounds.Width;
Height = Screen.PrimaryScreen.Bounds.Height;
}
instructions.Location = new Point(
(Width - instructions.Width) / 2,
(Height - instructions.Height) / 2
);
}
protected override void OnFormClosing(FormClosingEventArgs e)
{
e.Cancel = true; // Prevents window from closing
}
}
}