-
Notifications
You must be signed in to change notification settings - Fork 0
/
InteractiveOfficeClient.cs
124 lines (104 loc) · 2.89 KB
/
InteractiveOfficeClient.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
using System;
using System.Dynamic;
using System.IO;
using System.Reflection;
using Gdk;
using GLib;
using InteractiveOfficeClient.Windows;
namespace InteractiveOfficeClient
{
using Gtk;
public class InteractiveOfficeClient
{
private static InteractiveOfficeClient Instance = new InteractiveOfficeClient();
private ApplicationTimer _applicationTimer;
private MainWindow mainWindow;
private int _timeLeft;
public int TimeLeft
{
get { return _timeLeft; }
set
{
_timeLeft = value;
mainWindow.UpdateUi();
}
}
private AppState _appState = AppState.Paused;
public bool IsPaused => State == AppState.Paused;
public bool IsWorking => State == AppState.Working;
public bool IsNotifying => State == AppState.NotifyingBreak || State == AppState.NotifyingWork;
public AppState State
{
get { return _appState; }
set
{
Gtk.Application.Invoke(delegate
{
Console.WriteLine($"new state: {value}");
_appState = value;
_applicationTimer.ChangeState(value);
mainWindow.UpdateUi();
});
}
}
private InteractiveOfficeClient()
{
}
static void Main()
{
Instance.Run();
}
public void Run()
{
Application.Init();
mainWindow = new MainWindow(this);
_applicationTimer = new ApplicationTimer(this);
new IopTrayIcon(this);
Application.Run();
}
public void ToggleAppVisibility()
{
mainWindow.Visible = !mainWindow.Visible;
}
public void Show()
{
mainWindow.Deiconify();
mainWindow.Visible = true;
}
public void TriggerNotification()
{
if (IsWorking)
{
TriggerNotification(AppState.NotifyingBreak);
}
else
{
TriggerNotification(AppState.NotifyingWork);
}
}
private void TriggerNotification(AppState newState)
{
Gtk.Application.Invoke(delegate
{
if (IsWorking)
{
ShowBreakNotification();
}
else
{
new FeedbackWindow(this).ShowAll();
}
});
State = newState;
}
private void ShowBreakNotification()
{
new BreakNotificationWindow(this).ShowAll();
}
public void SnoozeBreak()
{
_appState = AppState.Working;
_applicationTimer.Snooze();
}
}
}