-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimerwindow.cs
More file actions
560 lines (496 loc) · 21.2 KB
/
timerwindow.cs
File metadata and controls
560 lines (496 loc) · 21.2 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
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using Gtk;
using UI = Gtk.Builder.ObjectAttribute;
namespace Appbatrozlinux
{
class timerwindow : Window
{
[UI] private Entry entry1 = null;
[UI] private Entry entry2 = null;
[UI] private Entry entry3 = null;
[UI] private Entry entry4 = null;
[UI] private Entry entry5 = null;
[UI] private Entry entry6 = null;
[UI] private Entry entry7 = null;
[UI] private Entry entry8 = null;
[UI] private Entry entry9 = null;
[UI] private Entry entry10 = null;
[UI] private Entry entry11 = null;
[UI] private Entry entry12 = null;
[UI] private Entry entry13 = null;
[UI] private Entry entry14 = null;
[UI] private Entry entry15 = null;
[UI] private Entry entry16 = null;
[UI] private Entry entry17 = null;
[UI] private Entry entry18 = null;
[UI] private Entry entry19 = null;
[UI] private Entry entry20 = null;
[UI] private Entry entry21 = null;
[UI] private Entry entry22 = null;
[UI] private Entry entry23 = null;
[UI] private Entry entry31 = null;
[UI] private RadioButton radiobutton1 = null;
[UI] private RadioButton radiobutton2 = null;
[UI] private RadioButton radiobutton3 = null;
[UI] private RadioButton radiobutton3n = null;
[UI] private RadioButton radiobutton4 = null;
[UI] private RadioButton radiobutton5 = null;
[UI] private RadioButton radiobutton5n = null;
[UI] private RadioButton radiobutton6 = null;
[UI] private RadioButton radiobutton7 = null;
[UI] private RadioButton radiobutton7n = null;
[UI] private RadioButton radiobutton8 = null;
[UI] private RadioButton radiobutton9 = null;
[UI] private RadioButton radiobutton9n = null;
[UI] private RadioButton radiobutton10 = null;
[UI] private RadioButton radiobutton11 = null;
[UI] private RadioButton radiobutton11n = null;
[UI] private RadioButton radiobutton12 = null;
[UI] private RadioButton radiobutton13 = null;
[UI] private RadioButton radiobutton13n = null;
[UI] private RadioButton radiobutton14 = null;
[UI] private RadioButton radiobutton15 = null;
[UI] private RadioButton radiobutton15n = null;
[UI] private RadioButton radiobutton16 = null;
[UI] private RadioButton radiobutton17 = null;
[UI] private RadioButton radiobutton17n = null;
[UI] private RadioButton radiobutton18 = null;
[UI] private RadioButton radiobutton19n = null;
string c1, c2, c3, c4, c5, c6, c7, c8, c9, c10;
string[] part;
int count =0;
public timerwindow() : this(new Builder("timerwindow.glade")) { }
private timerwindow(Builder builder) : base(builder.GetRawOwnedObject("timerwindow"))
{
builder.Autoconnect(this);
}
private void cle(){
entry1.Text = "";
entry2.Text = "";
entry3.Text = "";
entry4.Text = "";
entry5.Text = "";
entry6.Text = "";
entry7.Text = "";
entry8.Text = "";
entry9.Text = "";
entry10.Text = "";
entry11.Text = "";
entry12.Text = "";
entry13.Text = "";
entry14.Text = "";
entry15.Text = "";
entry16.Text = "";
entry17.Text = "";
entry18.Text = "";
entry19.Text = "";
entry20.Text = "";
entry21.Text = "";
entry22.Text = "";
entry23.Text = "";
entry31.Text="";
MessageDialog md = new MessageDialog(null, DialogFlags.Modal, MessageType.Other, ButtonsType.Ok, "Success");
md.Run();
md.Destroy();
}
public static void ExecuteCommand(string command)
{
Process proc = new System.Diagnostics.Process();
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = "/bin/bash";
startInfo.Arguments = "-c \" " + command + " \"";
process.StartInfo = startInfo;
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.RedirectStandardOutput = true;
process.Start();
process.Close();
}
public void ffun(bool status)
{
try
{
if (radiobutton1.Active == true)
{
c1 = " &&read -p 'Press any key to continue...' &&";
}
if (radiobutton2.Active == true)
{
c1 = " ||";
}
if (radiobutton3.Active == true)
{
c2 = " &&read -p 'Press any key to continue...' &&";
}
if (radiobutton4.Active == true)
{
c2 = " ||";
}
if (radiobutton5.Active == true)
{
c3 = " &&read -p 'Press any key to continue...' &&";
}
if (radiobutton6.Active == true)
{
c3 = " ||";
}
if (radiobutton7.Active == true)
{
c4 = " &&read -p 'Press any key to continue...' &&";
}
if (radiobutton8.Active == true)
{
c4 = " ||";
}
if (radiobutton9.Active == true)
{
c5 = " &&read -p 'Press any key to continue...' &&";
}
if (radiobutton10.Active == true)
{
c5 = " ||";
}
if (radiobutton11.Active == true)
{
c6 = " &&read -p 'Press any key to continue...' &&";
}
if (radiobutton12.Active == true)
{
c6 = " ||";
}
if (radiobutton13.Active == true)
{
c7 = " &&read -p 'Press any key to continue...' &&";
}
if (radiobutton14.Active == true)
{
c7 = " ||";
}
if (radiobutton15.Active == true)
{
c8 = " &&read -p 'Press any key to continue...' &&";
}
if (radiobutton16.Active == true)
{
c8 = " ||";
}
if (radiobutton17.Active == true)
{
c9 = " &&read -p 'Press any key to continue...' &&";
}
if (radiobutton18.Active == true)
{
c9 = " ||";
}
if (radiobutton3n.Active == true)
{
c1 = " &";
}
if (radiobutton5n.Active == true)
{
c2 = " &";
}
if (radiobutton7n.Active == true)
{
c3 = " &";
}
if (radiobutton9n.Active == true)
{
c4 = " &";
}
if (radiobutton11n.Active == true)
{
c5 = " &";
}
if (radiobutton13n.Active == true)
{
c6 = " &";
}
if (radiobutton15n.Active == true)
{
c7 = " &";
}
if (radiobutton17n.Active == true)
{
c8 = " &";
}
if (radiobutton19n.Active == true)
{
c9 = " &";
}
string en2,en4,en6,en8,en10,en12,en14,en16,en18,en20;
if(entry2.Text==""){
en2="";
}
else{
en2="'"+entry2.Text+"'";
}
if(entry4.Text==""){
en4="";
}
else{
en4="'"+entry4.Text+"'";
}
if(entry6.Text==""){
en6="";
}
else{
en6="'"+entry6.Text+"'";
}
if(entry8.Text==""){
en8="";
}
else{
en8="'"+entry8.Text+"'";
}
if(entry10.Text==""){
en10="";
}
else{
en10="'"+entry10.Text+"'";
}
if(entry12.Text==""){
en12="";
}
else{
en12="'"+entry12.Text+"'";
}
if(entry14.Text==""){
en14="";
}
else{
en14="'"+entry14.Text+"'";
}
if(entry16.Text==""){
en16="";
}
else{
en16="'"+entry16.Text+"'";
}
if(entry18.Text==""){
en18="";
}
else{
en18="'"+entry18.Text+"'";
}
if(entry20.Text==""){
en20="";
}
else{
en20="'"+entry20.Text+"'";
}
//
string cn1,cn3,cn5,cn7,cn9,cn11,cn13,cn15,cn17,cn19;
if(entry1.Text==""){
cn1="xdg-open";
}
else{
cn1=""+entry1.Text+"";
}
if(entry3.Text==""){
cn3="xdg-open";
}
else{
cn3=""+entry3.Text+"";
}
if(entry5.Text==""){
cn5="xdg-open";
}
else{
cn5=""+entry5.Text+"";
}
if(entry7.Text==""){
cn7="xdg-open";
}
else{
cn7=""+entry7.Text+"";
}
if(entry9.Text==""){
cn9="xdg-open";
}
else{
cn9=""+entry9.Text+"";
}
if(entry11.Text==""){
cn11="xdg-open";
}
else{
cn11=""+entry11.Text+"";
}
if(entry13.Text==""){
cn13="xdg-open";
}
else{
cn13=""+entry13.Text+"";
}
if(entry15.Text==""){
cn15="xdg-open";
}
else{
cn15=""+entry15.Text+"";
}
if(entry17.Text==""){
cn17="xdg-open";
}
else{
cn17=""+entry17.Text+"";
}
if(entry19.Text==""){
cn19="xdg-open";
}
else{
cn19=""+entry19.Text+"";
}
//
String txt = "";
if (entry1.Text != "" || entry2.Text != "")
{
txt = "echo '" + entry31.Text + "' |" +cn1+" " + en2 ;
}
if (entry3.Text != "" || entry4.Text != "")
{
txt = "echo '" + entry31.Text + "' |" +cn1+" " + en2 + " "+c1 + "echo '" + entry31.Text + "' |" +cn3+" " + en4;
}
if (entry5.Text != "" || entry6.Text != "")
{
txt = "echo '" + entry31.Text + "' |" +cn1+" " + en2 + " "+c1 + "echo '" + entry31.Text + "' |" +cn3+" " + en4 + " "+c2 + "echo '" + entry31.Text + "' |" +cn5+" " + en6 ;
}
if (entry7.Text != "" || entry8.Text != "")
{
txt = "echo '" + entry31.Text + "' |" +cn1+" " + en2 + " "+c1 + "echo '" + entry31.Text + "' |" +cn3+" " +en4 + " "+c2 + "echo '" + entry31.Text + "' |" +cn5+" " + en6 + " "+c3 + "echo '" + entry31.Text + "' |" +cn7+" " + en8 ;
}
if (entry9.Text != "" || entry10.Text != "")
{
txt = "echo '" + entry31.Text + "' |" +cn1+" " + en2 + " "+c1 + "echo '" + entry31.Text + "' |" +cn3+" " + en4 + " "+c2 + "echo '" + entry31.Text + "' |" +cn5+" " + en6 + " "+c3 + "echo '" + entry31.Text + "' |" +cn7+" " + en8 + " "+c4 + "echo '" + entry31.Text + "' |" +cn9+" " + en10 ;
}
if (entry11.Text != "" || entry12.Text != "")
{
txt = "echo '" + entry31.Text + "' |" +cn1+" " + en2 + " "+c1 + "echo '" + entry31.Text + "' |" +cn3+" " + en4 + " "+c2 + "echo '" + entry31.Text + "' |" +cn5+" " + en6 + " "+c3 + "echo '" + entry31.Text + "' |" +cn7+" " + en8 + " "+c4 + "echo '" + entry31.Text + "' |" +cn9+" " + en10 + " "+c5 + "echo '" + entry31.Text + "' |" +cn11+" " + en12 ;
}
if (entry13.Text != "" || entry14.Text != "")
{
txt = "echo '" + entry31.Text + "' |" +cn1+" " + en2 + " "+c1 + "echo '" + entry31.Text + "' |" +cn3+" " + en4 + " "+c2 + "echo '" + entry31.Text + "' |" +cn5+" " + en6 + " "+c3 + "echo '" + entry31.Text + "' |" +cn7+" " + en8 + " "+c4 + "echo '" + entry31.Text + "' |" +cn9+" " + en10 + " "+c5 + "echo '" + entry31.Text + "' |" +cn11+" " + en12 + " "+c6 + "echo '" + entry31.Text + "' |" +cn13+" " + en14 ;
}
if (entry15.Text != "" || entry16.Text != "")
{
txt = "echo '" + entry31.Text + "' |" +cn1+" " + en2 + " "+c1 + "echo '" + entry31.Text + "' |" +cn3+" " + en4 + " "+c2 + "echo '" + entry31.Text + "' |" +cn5+" " + en6 + " "+c3 + "echo '" + entry31.Text + "' |" +cn7+" " + en8 + " "+c4 + "echo '" + entry31.Text + "' |" +cn9+" " + en10 + " "+c5 + "echo '" + entry31.Text + "' |" +cn11+" " + en12 + " "+c6 + "echo '" + entry31.Text + "' |" +cn13+" " + en14 + " "+c7 + "echo '" + entry31.Text + "' |" +cn15+" " + en16 ;
}
if (entry17.Text != "" || entry18.Text != "")
{
txt = "echo '" + entry31.Text + "' |" +cn1+" " + en2 + " "+c1 + "echo '" + entry31.Text + "' |" +cn3+" " + en4 + " "+c2 + "echo '" + entry31.Text + "' |" +cn5+" " + en6 + " "+c3 + "echo '" + entry31.Text + "' |" +cn7+" " + en8 + " "+c4 + "echo '" + entry31.Text + "' |" +cn9+" " + en10 + " "+c5 + "echo '" + entry31.Text + "' |" +cn11+" " + en12 + " "+c6 + "echo '" + entry31.Text + "' |" +cn13+" " + en14 + " "+c7 + "echo '" + entry31.Text + "' |" +cn15+" " + en16 + " "+c8 + "echo '" + entry31.Text + "' |" +cn17+" " + en18 ;
}
if (entry19.Text != "" || entry20.Text != "")
{
txt = "echo '" + entry31.Text + "' |" +cn1+" " + en2 + " "+c1 + "echo '" + entry31.Text + "' |" +cn3+" " + en4 + " "+c2 + "echo '" + entry31.Text + "' |" +cn5+" " + en6 + " "+c3 + "echo '" + entry31.Text + "' |" +cn7+" " + en8 + " "+c4 + "echo '" + entry31.Text + "' |" +cn9+" " +en10 + " "+c5 + "echo '" + entry31.Text + "' |" +cn11+" " + en12 + " "+c6 + "echo '" + entry31.Text + "' |" +cn13+" " + en14 + " "+c7 + "echo '" + entry31.Text + "' |" +cn15+" " + en16 + " "+c8 + "echo '" + entry31.Text + "' |" +cn17+" " + en18 + " "+c9 + "echo '" + entry31.Text + "' |" +cn19+" " + en20 ;
}
if (status == true) {
string ftxt;
if (txt.Contains(" &&read -p 'Press any key to continue...' &&"))
{
ftxt = '"' + txt + " &&read -p 'Press any key to continue...'"+ '"';
}
else {
ftxt = '"' + txt + '"';
}
var last = "";
if (entry23.Text != "") {
string filepath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal) + "/appbatrozlnx/appbatrozicon/";
System.IO.FileInfo file = new System.IO.FileInfo(filepath);
file.Directory.Create();
var nicon=entry23.Text.Split('/').Last();
var chicon=file+nicon;
if (!File.Exists(chicon)){
File.Copy(entry23.Text, file.FullName+"/"+nicon);
}
last = file.FullName + entry23.Text.Split('/').Last();
}
string folder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop) + "/";
if(entry21.Text==""){
MessageDialog md = new MessageDialog(null, DialogFlags.Modal, MessageType.Other, ButtonsType.Ok, "Title is empty");
md.Run();
md.Destroy();
}
else{
string dskfl;
if (txt.Contains(" &&read -p 'Press any key to continue...' &&"))
{
dskfl = "[Desktop Entry]" + "\n" +
"Name=" + entry21.Text + "\n" + "StartupWMClass=" + entry22.Text + "\n" + "Comment=" + entry21.Text + "\n" + "GenericName=Shortcut" + "\n" + "Exec= bash -c " + ftxt + "\n" + "Icon=" + last + "\n" + "Type=Application\nCategories=Application;\nTerminal=true" + "\n" + "MimeType=text/html;text/xml;application/xhtml+xml;application/xml;application/vnd.mozilla.xul+xml; application/rss+xml;application/rdf+xml;image/gif;image/jpeg;image/png;x-scheme-handler/http;x-scheme-handler/https;" + "\n" + "Keywords=Shortcut;Appbatroz;";
}
else
{
dskfl = "[Desktop Entry]" + "\n" +
"Name=" + entry21.Text + "\n" + "StartupWMClass=" + entry22.Text + "\n" + "Comment=" + entry21.Text + "\n" + "GenericName=Shortcut" + "\n" + "Exec= bash -c " + ftxt + "\n" + "Icon=" + last + "\n" + "Type=Application\nCategories=Application;\nTerminal=false" + "\n" + "MimeType=text/html;text/xml;application/xhtml+xml;application/xml;application/vnd.mozilla.xul+xml; application/rss+xml;application/rdf+xml;image/gif;image/jpeg;image/png;x-scheme-handler/http;x-scheme-handler/https;" + "\n" + "Keywords=Shortcut;Appbatroz;";
}
string folders = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop) +"/";
// Filename
string fileName = entry21.Text +".desktop";
// Fullpath. You can direct hardcode it if you like.
string fullPath = folders + fileName;
// ExecuteCommand(txt);
File.WriteAllText(fullPath, dskfl);
cle();
}
}
else
{
if(txt.Contains(" &&read -p 'Press any key to continue...' &&")){
part = txt.Split(new string[] { " &&read -p 'Press any key to continue...' &&" }, StringSplitOptions.None);
ExecuteCommand(part[0]);
Console.Write(part[0]);
}
else{
ExecuteCommand(txt);
cle();
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
protected void save_Clicked(object sender, EventArgs e)
{
ffun(true);
}
protected void run_Clicked(object sender, EventArgs e)
{
ffun(false);
}
private void OpenOFD()
{
Gtk.FileChooserDialog filechooser =
new Gtk.FileChooserDialog("Choose the file to open",
this,
FileChooserAction.Open,
"Cancel", ResponseType.Cancel,
"Open", ResponseType.Accept);
if (filechooser.Run() == (int)ResponseType.Accept)
{
entry23.Text = filechooser.Filename;
//file.Close();
}
filechooser.Destroy();
}
protected void icon_Clicked(object sender, EventArgs e)
{
OpenOFD();
}
protected void next_onclicked(object sender, EventArgs e)
{
if(count != (part.Length-1)){
count++;
ExecuteCommand(part[count]);
}
else{
count =0;
cle();
}
}
}
}