-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cs
72 lines (59 loc) · 1.75 KB
/
main.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
namespace App
{
using System;
using Gtk;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
class HourWarning : Window
{
public static async Task SetInterval(System.Action action, TimeSpan timeout)
{
await Task.Delay(timeout).ConfigureAwait(false);
action();
await SetInterval(action, timeout);
}
async void showAtOneHour(Gtk.Label label)
{
int time = 3600;
await SetInterval(() =>
{
if (time > 0)
{
label.Text = Convert.ToString(time, 10);
time -= 1;
}
else
{
MessageBox.Show("Tá na hora de descansar um pouco ,_,");
Thread.Sleep(-1);
}
}, TimeSpan.FromSeconds(1));
}
public HourWarning() : base("HourWarning")
{
SetDefaultSize(250, 250);
SetPosition(WindowPosition.Center);
VBox box = new VBox(true, 0);
Gtk.Label title = new Gtk.Label("Hour Warning");
Gtk.Label seconds = new Gtk.Label("0");
Gtk.Button btnStart = new Gtk.Button("START");
btnStart.Clicked += (obj, evt) => showAtOneHour(seconds);
box.Add(title);
box.Add(seconds);
box.Add(btnStart);
DeleteEvent += delegate
{
Gtk.Application.Quit();
};
Add(box);
ShowAll();
}
public static void Main()
{
Gtk.Application.Init();
new HourWarning();
Gtk.Application.Run();
}
}
}