This repository was archived by the owner on Jan 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWidget Form.cs
More file actions
314 lines (307 loc) · 10.8 KB
/
Widget Form.cs
File metadata and controls
314 lines (307 loc) · 10.8 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net;
using System.IO;
using Tulpep.NotificationWindow;
using Microsoft;
using System.Threading;
using RestSharp;
using Newtonsoft.Json;
namespace TimeCast
{
public partial class Form2 : Form
{
public static Form2 form;
public string Option1;
public string zero;
public string zeroMinute;
public string zeroHoure;
public string Option2;
public string Option3;
public static int X;
public static int Y;
public String Locked = "False";
static int Houre;
static int minute;
static int secend;
static string Event;
private bool mouseDown;
private Point lastLocation;
public Form2()
{
InitializeComponent();
}
public void Form1_Load(object sender, EventArgs e)
{
if (File.Exists(@"Config.txt"))
{
X = Convert.ToInt32(File.ReadLines(@"Config.txt").Skip(1).Take(1).First());
Y = Convert.ToInt32(File.ReadLines(@"Config.txt").Skip(2).Take(1).First());
this.SetDesktopLocation(X, Y);
}
form = this;
LoadCheck();
StartAPP();
}
public void StartAPP()
{
try
{
if (Option2 == "True")
{
base.TopMost = true;
}
else
{
base.TopMost = false;
}
this.ControlBox = false;
this.Text = String.Empty;
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
var client = new RestClient("http://api.keybit.ir/time/");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
IRestResponse response = client.Execute(request);
Root myDeserializedClass = JsonConvert.DeserializeObject<Root>(response.Content);
label1.Text = myDeserializedClass.date.weekday.name + " " + myDeserializedClass.date.day.number.en + " " + myDeserializedClass.date.month.name;
Houre = Convert.ToInt32(myDeserializedClass.time24.hour.en);
minute = Convert.ToInt32(myDeserializedClass.time24.minute.en);
secend = Convert.ToInt32(myDeserializedClass.time24.second.en);
label2.Text = Houre + " : " + minute + " : " + secend;
timer1.Start();
if (myDeserializedClass.date.day.events.holy == null)
{
}
else
{
if (Option3 == "True")
{
Event = myDeserializedClass.date.day.events.holy.text.ToString();
notifyIcon1.Visible = true;
notifyIcon1.Icon = SystemIcons.Information;
notifyIcon1.BalloonTipTitle = "مناسبت " + myDeserializedClass.date.weekday.name + " " + myDeserializedClass.date.day.number.en + " " + myDeserializedClass.date.month.name.ToString() + " :";
notifyIcon1.BalloonTipText = Event.ToString();
notifyIcon1.ShowBalloonTip(3000);
}
}
if (myDeserializedClass.date.day.events.local == null)
{
}
else
{
if (Option3 == "True")
{
Event = myDeserializedClass.date.day.events.local.text.ToString();
notifyIcon1.Visible = true;
notifyIcon1.Icon = SystemIcons.Information;
notifyIcon1.BalloonTipTitle = "مناسبت " + myDeserializedClass.date.weekday.name + " " + myDeserializedClass.date.day.number.en + " " + myDeserializedClass.date.month.name.ToString() + " :";
notifyIcon1.BalloonTipText = Event.ToString();
notifyIcon1.ShowBalloonTip(3000);
}
}
if(myDeserializedClass.date.day.events.global == null)
{
}
else
{
Event = myDeserializedClass.date.day.events.global.text.ToString();
notifyIcon1.Visible = true;
notifyIcon1.Icon = SystemIcons.Information;
notifyIcon1.BalloonTipTitle = "مناسبت " + myDeserializedClass.date.weekday.name + " " + myDeserializedClass.date.day.number.en + " " + myDeserializedClass.date.month.name.ToString() + " :";
notifyIcon1.BalloonTipText = Event.ToString();
notifyIcon1.ShowBalloonTip(3000);
}
}
catch (Exception ex)
{
Thread.Sleep(20000);
StartAPP();
}
}
public void LoadCheck()
{
if (File.Exists(@"Config.txt"))
{
Option1 = File.ReadLines(@"Config.txt").Skip(2).Take(1).First();
Option2 = File.ReadLines(@"Config.txt").Skip(3).Take(1).First();
Option3 = File.ReadLines(@"Config.txt").Skip(4).Take(1).First();
Locked = File.ReadLines(@"Config.txt").Skip(5).Take(1).First();
}
}
private void label1_Click(object sender, EventArgs e)
{
}
private void label2_Click(object sender, EventArgs e)
{
}
private void timer1_Tick(object sender, EventArgs e)
{
secend++;
zero = "";
zeroMinute = "";
zeroHoure = "";
switch (secend)
{
case 0:
zero = "0";
break;
case 1:
zero = "0";
break;
case 2:
zero = "0";
break;
case 3:
zero = "0";
break;
case 4:
zero = "0";
break;
case 5:
zero = "0";
break;
case 6:
zero = "0";
break;
case 7:
zero = "0";
break;
case 8:
zero = "0";
break;
case 9:
zero = "0";
break;
case 60:
minute++;
secend = 0;
zero = "0";
break;
}
switch (minute)
{
case 0:
zeroMinute = "0";
break;
case 1:
zeroMinute = "0";
break;
case 2:
zeroMinute = "0";
break;
case 3:
zeroMinute = "0";
break;
case 4:
zeroMinute = "0";
break;
case 5:
zeroMinute = "0";
break;
case 6:
zeroMinute = "0";
break;
case 7:
zeroMinute = "0";
break;
case 8:
zeroMinute = "0";
break;
case 9:
zeroMinute = "0";
break;
case 60:
Houre++;
minute = 0;
zeroMinute = "0";
break;
}
switch (Houre)
{
case 0:
zeroHoure = "0";
break;
case 1:
zeroHoure = "0";
break;
case 2:
zeroHoure = "0";
break;
case 3:
zeroHoure = "0";
break;
case 4:
zeroHoure = "0";
break;
case 5:
zeroHoure = "0";
break;
case 6:
zeroHoure = "0";
break;
case 7:
zeroHoure = "0";
break;
case 8:
zeroHoure = "0";
break;
case 9:
zeroHoure = "0";
break;
case 24:
Houre = 0;
zeroHoure = "0";
var client = new RestClient("https://api.keybit.ir/time/");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
IRestResponse response = client.Execute(request);
Root myDeserializedClass = JsonConvert.DeserializeObject<Root>(response.Content);
label1.Text = myDeserializedClass.date.weekday.name + " " + myDeserializedClass.date.day.number.en + " " + myDeserializedClass.date.month.name;
break;
}
label2.Text = zeroHoure + Houre + " : " + zeroMinute + minute + " : " + zero + secend;
}
private void Form2_MouseDown(object sender, MouseEventArgs e)
{
if (Locked == "False")
{
mouseDown = true;
lastLocation = e.Location;
}
}
private void Form2_MouseMove(object sender, MouseEventArgs e)
{
if (Locked == "False")
{
if (mouseDown)
{
this.Location = new Point(
(this.Location.X - lastLocation.X) + e.X, (this.Location.Y - lastLocation.Y) + e.Y);
this.Update();
}
}
}
private void Form2_MouseUp(object sender, MouseEventArgs e)
{
if (Locked == "False")
{
mouseDown = false;
}
}
private void Form2_DoubleClick(object sender, EventArgs e)
{
Form1 f1 = new Form1();
f1.Visible = true;
}
}
}