-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
107 lines (98 loc) · 3.38 KB
/
Program.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.Diagnostics;
using System.Threading;
using System.Media;
using System.Drawing.Drawing2D;
using Microsoft.Win32;
namespace KeepYourEyes
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
private static Stopwatch Stopwatch1 = new Stopwatch();
public static bool firsttime = false;
public static NotifyIcon notificationIcon;
[STAThread]
static void Main()
{
SetStartup(true);
const string appName = "KeepYourEyes";
bool createdNew;
var mutex = new Mutex(true, appName, out createdNew);
if (!createdNew)
{
//app is already running! Exiting the application
MessageBox.Show("Multiple applactions not allowed!");
Application.ExitThread();
Environment.Exit(0);
}
//int timeout, string tipTitle, string tipText, ToolTipIcon tipIcon
GC.Collect();
Application.SetHighDpiMode(HighDpiMode.SystemAware);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
//
if (firsttime)
{
Application.Run(new Settings());
firsttime = false;
}
else
{
Stopwatch1.Start();
NotifyIcon notifyIcon = new NotifyIcon();
notifyIcon.BalloonTipIcon = ToolTipIcon.Info;
notifyIcon.BalloonTipText = "Welcome to TutorialsPanel.com!!";
notifyIcon.BalloonTipTitle = "Welcome Message";
notifyIcon.Visible = true;
notifyIcon.ShowBalloonTip(2000);
while (true)
{
GC.Collect();
Thread.Sleep(1000);
if (Stopwatch1.Elapsed.Minutes == 20)
{
Thread t = new Thread(new ThreadStart(beep));
Application.Run(new Form1());
Stopwatch1.Stop();
Stopwatch1.Reset();
Stopwatch1.Start();
}
#if DEBUG
Debug.WriteLine($"Time so far: "+Stopwatch1.Elapsed + " MEMORY: "+ GC.GetTotalMemory(true)); // debug stuff goes here
#endif
}
}
}
private static void SetStartup(bool p)
{
string name = "KeepYourEyes";
RegistryKey rk = Registry.CurrentUser.OpenSubKey
("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
if (p == true)
rk.SetValue(name, Application.ExecutablePath);
else
rk.DeleteValue(name, false);
}
public static void beep()
{
for (int i = 0; i < 5; i++)
{
GC.Collect();
using (var soundPlayer = new SoundPlayer(Properties.Resources.Alarm))
{
soundPlayer.Load();
soundPlayer.Play();
}
}
GC.Collect();
}
}
}