-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form1.cs.bak
515 lines (493 loc) · 16 KB
/
Form1.cs.bak
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
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
using System.Diagnostics;
namespace _05final_object
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.DateTimePicker dateTimePicker1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.RadioButton radioButton1;
private System.Windows.Forms.RadioButton radioButton2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.RadioButton radioButton3;
private System.Windows.Forms.RadioButton radioButton4;
private System.ComponentModel.IContainer components;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Timer timer2;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
int alltime=0;
string nowtime="";
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.MenuItem menuItem1;
string pcid="";
string run2="";
string run3="";
string run4="";
string run5="";
string run6="";
public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.dateTimePicker1 = new System.Windows.Forms.DateTimePicker();
this.button1 = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.radioButton2 = new System.Windows.Forms.RadioButton();
this.radioButton1 = new System.Windows.Forms.RadioButton();
this.label1 = new System.Windows.Forms.Label();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.radioButton4 = new System.Windows.Forms.RadioButton();
this.radioButton3 = new System.Windows.Forms.RadioButton();
this.label2 = new System.Windows.Forms.Label();
this.timer2 = new System.Windows.Forms.Timer(this.components);
this.textBox2 = new System.Windows.Forms.TextBox();
this.textBox3 = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.SuspendLayout();
//
// timer1
//
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// dateTimePicker1
//
this.dateTimePicker1.Location = new System.Drawing.Point(104, 40);
this.dateTimePicker1.Name = "dateTimePicker1";
this.dateTimePicker1.Size = new System.Drawing.Size(88, 21);
this.dateTimePicker1.TabIndex = 0;
//
// button1
//
this.button1.Location = new System.Drawing.Point(240, 144);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(88, 32);
this.button1.TabIndex = 1;
this.button1.Text = "開始";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// textBox1
//
this.textBox1.Enabled = false;
this.textBox1.Location = new System.Drawing.Point(176, 152);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(32, 21);
this.textBox1.TabIndex = 2;
this.textBox1.Text = "";
//
// groupBox1
//
this.groupBox1.Controls.Add(this.radioButton2);
this.groupBox1.Controls.Add(this.radioButton1);
this.groupBox1.Location = new System.Drawing.Point(16, 24);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(72, 144);
this.groupBox1.TabIndex = 3;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "選擇模式";
//
// radioButton2
//
this.radioButton2.Location = new System.Drawing.Point(8, 88);
this.radioButton2.Name = "radioButton2";
this.radioButton2.Size = new System.Drawing.Size(56, 32);
this.radioButton2.TabIndex = 1;
this.radioButton2.Text = "倒計";
//
// radioButton1
//
this.radioButton1.Checked = true;
this.radioButton1.Location = new System.Drawing.Point(8, 32);
this.radioButton1.Name = "radioButton1";
this.radioButton1.Size = new System.Drawing.Size(56, 40);
this.radioButton1.TabIndex = 0;
this.radioButton1.TabStop = true;
this.radioButton1.Text = "定時";
this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged);
//
// label1
//
this.label1.Location = new System.Drawing.Point(104, 152);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(72, 16);
this.label1.TabIndex = 4;
this.label1.Text = "倒計時間:";
//
// groupBox2
//
this.groupBox2.Controls.Add(this.radioButton4);
this.groupBox2.Controls.Add(this.radioButton3);
this.groupBox2.Location = new System.Drawing.Point(104, 80);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(184, 48);
this.groupBox2.TabIndex = 5;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "倒計時分選擇";
//
// radioButton4
//
this.radioButton4.Checked = true;
this.radioButton4.Location = new System.Drawing.Point(112, 24);
this.radioButton4.Name = "radioButton4";
this.radioButton4.Size = new System.Drawing.Size(32, 16);
this.radioButton4.TabIndex = 1;
this.radioButton4.TabStop = true;
this.radioButton4.Text = "分";
//
// radioButton3
//
this.radioButton3.Location = new System.Drawing.Point(16, 24);
this.radioButton3.Name = "radioButton3";
this.radioButton3.Size = new System.Drawing.Size(32, 16);
this.radioButton3.TabIndex = 0;
this.radioButton3.Text = "時";
//
// label2
//
this.label2.Location = new System.Drawing.Point(8, 184);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(320, 8);
this.label2.TabIndex = 6;
this.label2.Text = "label2";
this.label2.Visible = false;
//
// timer2
//
this.timer2.Tick += new System.EventHandler(this.timer2_Tick);
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(200, 40);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(24, 21);
this.textBox2.TabIndex = 7;
this.textBox2.Text = "";
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(248, 40);
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(24, 21);
this.textBox3.TabIndex = 8;
this.textBox3.Text = "";
//
// label3
//
this.label3.Location = new System.Drawing.Point(224, 40);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(24, 24);
this.label3.TabIndex = 9;
this.label3.Text = "時";
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label4
//
this.label4.Location = new System.Drawing.Point(272, 40);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(24, 24);
this.label4.TabIndex = 10;
this.label4.Text = "分";
this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// mainMenu1
//
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem1});
//
// menuItem1
//
this.menuItem1.Index = 0;
this.menuItem1.Text = "關於本軟體";
this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.BackColor = System.Drawing.Color.WhiteSmoke;
this.ClientSize = new System.Drawing.Size(336, 193);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.label2);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.label1);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.button1);
this.Controls.Add(this.dateTimePicker1);
this.Menu = this.mainMenu1;
this.Name = "Form1";
this.Text = "時間代理小秘書";
this.Load += new System.EventHandler(this.Form1_Load);
this.groupBox1.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void radioButton1_CheckedChanged(object sender, System.EventArgs e)
{
if(this.radioButton1.Checked==true)
{
this.dateTimePicker1.Enabled=true;
this.textBox1.Enabled=false;
this.textBox2.Enabled=true;
this.textBox3.Enabled=true;
}
else if(this.radioButton2.Checked==true)
{
this.dateTimePicker1.Enabled=false;
this.textBox1.Enabled=true;
this.textBox2.Enabled=false;
this.textBox3.Enabled=false;
}
}
private void button1_Click(object sender, System.EventArgs e)
{
try{this.textBox2.Text=int.Parse(this.textBox2.Text).ToString();}catch{}
if(this.textBox3.Text.Length==1){this.textBox3.Text="0"+this.textBox3.Text;}
if(this.radioButton1.Checked==true)
{
try
{
// this.label2.Text=this.dateTimePicker1.Value.ToString().Substring(0,10);//-
// this.label2.Text=this.label2.Text+"___"+System.DateTime.Now.ToString().Substring(0,16);
this.timer1.Interval=500;
this.timer1.Start();
//this.timer1.
// Process ps=new Process();
// ps.StartInfo.FileName=this.name2url;
// this.label1.Text =this.name2url;
// ps.Start();
}
catch
{
//this.label1.Text =this.name1url;
}
}
else if(this.radioButton2.Checked==true)
{
try
{
this.alltime=int.Parse(this.textBox1.Text);
this.nowtime=System.DateTime.Now.ToString().Substring(0,16);
this.timer2.Interval=10000;
this.timer2.Start();
}
catch{}
}
this.button1.Enabled=false;
this.groupBox1.Enabled=false;
this.groupBox2.Enabled=false;
this.dateTimePicker1.Enabled=false;
this.textBox2.Enabled=false;
this.textBox3.Enabled=false;
}
private void timer1_Tick(object sender, System.EventArgs e)
{
//this.label2.Text=this.dateTimePicker1.Value.ToString().Substring(0,10)+" "+this.textBox2.Text+":"+this.textBox3.Text+"==="+System.DateTime.Now.ToString().Substring(0,16);
if(this.dateTimePicker1.Value.ToString().Substring(0,10)+" "+this.textBox2.Text+":"+this.textBox3.Text==System.DateTime.Now.ToString().Substring(0,16))
{
this.timer1.Stop();
this.closeall();
}
else if(this.dateTimePicker1.Value.ToString().Substring(0,10)+" "+this.textBox2.Text+":"+this.textBox3.Text==System.DateTime.Now.ToString().Substring(0,15))
{
this.timer1.Stop();
this.closeall();
}
}
private void timer2_Tick(object sender, System.EventArgs e)
{
//this.label2.Text=this.nowtime.Substring(0,13)+"==="+System.DateTime.Now.ToString().Substring(0,13);
if(this.radioButton3.Checked==true)
{
if(this.nowtime.Substring(0,13)!=System.DateTime.Now.ToString().Substring(0,13))
{this.nowtime=System.DateTime.Now.ToString().Substring(0,16);this.alltime--;}
}
else if(this.radioButton4.Checked==true)
{
if(this.nowtime!=System.DateTime.Now.ToString().Substring(0,16))
{this.nowtime=System.DateTime.Now.ToString().Substring(0,16);this.alltime--;}
}
if(this.alltime==0)
{
this.timer2.Stop();
this.closeall();
//this.label2.Text="afgafgasdfg";
}
}
private void Form1_Load(object sender, System.EventArgs e)
{
this.textBox2.Text=System.DateTime.Now.Hour.ToString();
this.textBox3.Text=System.DateTime.Now.Minute.ToString();
try
{
string check;
FileStream input=new FileStream(Directory.GetCurrentDirectory()+"\\"+"cfg.ini",FileMode.Open,FileAccess.Read);
System.Text.Encoding en=System.Text.Encoding.Default;
// System.Text.Encoding en=System.Text.Encoding.GetEncoding("gb2312");
StreamReader sr=new StreamReader(input,en);
check=sr.ReadToEnd();
int cpcid=check.IndexOf("run1=",0);
int crun2=check.IndexOf("run2=",0);
int crun3=check.IndexOf("run3=",0);
int crun4=check.IndexOf("run4=",0);
int crun5=check.IndexOf("run5=",0);
int crun6=check.IndexOf("run6=",0);
try
{
if(check.Substring(cpcid+5,check.IndexOf(";",cpcid)-(cpcid+5)).Length<1){MessageBox.Show("run1含有不正確的路徑或程式名,確認是否該連接有效(打開cfg.ini查看是否有效)","無效操作");}
else{this.pcid=check.Substring(cpcid+5,check.IndexOf(";",cpcid)-(cpcid+5));}
}
catch{}
try
{
if(check.Substring(crun2+5,check.IndexOf(";",crun2)-(crun2+5)).Length<1){MessageBox.Show("run2含有不正確的路徑或程式名,確認是否該連接有效(打開cfg.ini查看是否有效)","無效操作");}
else{this.run2=check.Substring(crun2+5,check.IndexOf(";",crun2)-(crun2+5));}
}
catch{}
try
{
if(check.Substring(crun3+5,check.IndexOf(";",crun3)-(crun3+5)).Length<1){MessageBox.Show("run3含有不正確的路徑或程式名,確認是否該連接有效(打開cfg.ini查看是否有效)","無效操作");}
else{this.run3=check.Substring(crun3+5,check.IndexOf(";",crun3)-(crun3+5));}
}
catch{}
try
{
if(check.Substring(crun4+5,check.IndexOf(";",crun4)-(crun4+5)).Length<1){MessageBox.Show("run4含有不正確的路徑或程式名,確認是否該連接有效(打開cfg.ini查看是否有效)","無效操作");}
else{this.run4=check.Substring(crun4+5,check.IndexOf(";",crun4)-(crun4+5));}
}
catch{}
try
{
if(check.Substring(crun5+5,check.IndexOf(";",crun5)-(crun5+5)).Length<1){MessageBox.Show("run5含有不正確的路徑或程式名,確認是否該連接有效(打開cfg.ini查看是否有效)","無效操作");}
else{this.run5=check.Substring(crun5+5,check.IndexOf(";",crun5)-(crun5+5));}
}
catch{}
try
{
if(check.Substring(crun6+5,check.IndexOf(";",crun6)-(crun6+5)).Length<1){MessageBox.Show("run6含有不正確的路徑或程式名,確認是否該連接有效(打開cfg.ini查看是否有效)","無效操作");}
else{this.run6=check.Substring(crun6+5,check.IndexOf(";",crun6)-(crun6+5));}
}
catch{}
}
catch
{
MessageBox.Show("無法打開連接,確認是否執行檔目錄中含有cfg.ini;確認是否該連接有效(打開cfg.ini查看是否有效)","無效操作");
// MessageBox.Show("无法打开连接,确认是否执行文件目录中含有cfg.ini;确认是否该连接有效(打开cfg.ini查看是否有效)","无效操作");
// try
// {
}
}
void closeall()
{
try
{
Process ps=new Process();
ps.StartInfo.FileName=this.pcid;
//this.label2.Text =this.pcid;
ps.Start();
}
catch{}
try
{
Process ps2=new Process();
ps2.StartInfo.FileName=this.run2;
ps2.Start();
}
catch{}
try
{
Process ps3=new Process();
ps3.StartInfo.FileName=this.run3;
ps3.Start();
}
catch{}
try
{
Process ps4=new Process();
ps4.StartInfo.FileName=this.run4;
ps4.Start();
}
catch{}
try
{
Process ps5=new Process();
ps5.StartInfo.FileName=this.run5;
ps5.Start();
}
catch{}
try
{
Process ps6=new Process();
ps6.StartInfo.FileName=this.run6;
ps6.Start();
}
catch{}
}
private void menuItem1_Click(object sender, System.EventArgs e)
{
Form2 a=new Form2();
a.Show();
}
}
}