-
Notifications
You must be signed in to change notification settings - Fork 5
/
BICompressor.cs
2086 lines (1912 loc) · 80.7 KB
/
BICompressor.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
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
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Globalization;
using System.IO;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Linq;
using System.Collections.Concurrent;
using System.Collections;
using FluentScheduler;
namespace Dorisoy.BICompressor
{
/// <summary>
/// Dorisoy 批量图片压缩器(BICompressor)
/// </summary>
public partial class BICompressor : Form
{
public bool IsRunning = true;
private string Timer = "00:00";
private int TimeInterval = 5;
private Button button2;
private TextBox txt_sourceFilePath;
private Label label4;
private NumericUpDown pud_OnceOfQuantity;
private Label label5;
private Label label6;
private NumericUpDown mud_fileLimitSize;
private Label label7;
private int Weekday = 1;
#region Public Methods
public BICompressor()
{
InitializeComponent();
progressBar1.Maximum = 100;
}
#endregion
private FolderBrowserDialog mProblematicBrowseDialog;
private NumericUpDown mQualityTextBox;
private RadioButton rb_autoCompress;
private RadioButton radioButton1;
private NumericUpDown numericUpDown1;
private Label label2;
private ComboBox comboBox1;
private Label label1;
private Label label3;
private GroupBox groupBox1;
private RadioButton radioButton7;
private RadioButton radioButton6;
private RadioButton radioButton5;
private RadioButton radioButton4;
private RadioButton radioButton3;
private RadioButton radioButton8;
private RadioButton radioButton9;
private ConcurrentQueue<TaskFile> TaskFiles = new ConcurrentQueue<TaskFile>();
public string SavePath1 { get; set; }
public string SavePath2 { get; set; }
public string SavePath3 { get; set; }
#region Private Methods
private void InitializeComponent()
{
this.mInputLabel = new System.Windows.Forms.Label();
this.mInputTextBox = new System.Windows.Forms.TextBox();
this.mInputBrowseButton = new System.Windows.Forms.Button();
this.mInputBrowseDialog = new System.Windows.Forms.FolderBrowserDialog();
this.mOutputLabel = new System.Windows.Forms.Label();
this.mOutputTextBox = new System.Windows.Forms.TextBox();
this.mOutputBrowseButton = new System.Windows.Forms.Button();
this.mOutputBrowseDialog = new System.Windows.Forms.FolderBrowserDialog();
this.mProblematicLabel = new System.Windows.Forms.Label();
this.mProblematicTextBox = new System.Windows.Forms.TextBox();
this.mProblematicBrowseButton = new System.Windows.Forms.Button();
this.mProblematicBrowseDialog = new System.Windows.Forms.FolderBrowserDialog();
this.mResolutionGroupBox = new System.Windows.Forms.GroupBox();
this.label6 = new System.Windows.Forms.Label();
this.mud_fileLimitSize = new System.Windows.Forms.NumericUpDown();
this.label7 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.pud_OnceOfQuantity = new System.Windows.Forms.NumericUpDown();
this.label4 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
this.label2 = new System.Windows.Forms.Label();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.label1 = new System.Windows.Forms.Label();
this.mQualityTextBox = new System.Windows.Forms.NumericUpDown();
this.checkBox2 = new System.Windows.Forms.CheckBox();
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.mResolutionPercentRadioButton = new System.Windows.Forms.RadioButton();
this.mResolutionDimensionTextBox = new System.Windows.Forms.TextBox();
this.mResolutionDimensionRadioButton = new System.Windows.Forms.RadioButton();
this.mResolutionPercentTextBox = new System.Windows.Forms.TextBox();
this.mQualityLabel = new System.Windows.Forms.Label();
this.mCompressButton = new System.Windows.Forms.Button();
this.mBackgroundWorker = new System.ComponentModel.BackgroundWorker();
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
this.progressBar1 = new System.Windows.Forms.ToolStripProgressBar();
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.button2 = new System.Windows.Forms.Button();
this.txt_sourceFilePath = new System.Windows.Forms.TextBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.radioButton7 = new System.Windows.Forms.RadioButton();
this.radioButton6 = new System.Windows.Forms.RadioButton();
this.radioButton5 = new System.Windows.Forms.RadioButton();
this.radioButton4 = new System.Windows.Forms.RadioButton();
this.radioButton3 = new System.Windows.Forms.RadioButton();
this.radioButton8 = new System.Windows.Forms.RadioButton();
this.radioButton9 = new System.Windows.Forms.RadioButton();
this.rb_autoCompress = new System.Windows.Forms.RadioButton();
this.radioButton1 = new System.Windows.Forms.RadioButton();
this.button1 = new System.Windows.Forms.Button();
this.tabPage2 = new System.Windows.Forms.TabPage();
this.dataGridView1 = new System.Windows.Forms.DataGridView();
this.name = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.size = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.status = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Id = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.tabPage3 = new System.Windows.Forms.TabPage();
this.textBox1 = new System.Windows.Forms.TextBox();
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
this.mResolutionGroupBox.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.mud_fileLimitSize)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pud_OnceOfQuantity)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.mQualityTextBox)).BeginInit();
this.statusStrip1.SuspendLayout();
this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
this.groupBox1.SuspendLayout();
this.tabPage2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
this.tabPage3.SuspendLayout();
this.SuspendLayout();
//
// mInputLabel
//
this.mInputLabel.AutoSize = true;
this.mInputLabel.Location = new System.Drawing.Point(10, 63);
this.mInputLabel.Name = "mInputLabel";
this.mInputLabel.Size = new System.Drawing.Size(59, 12);
this.mInputLabel.TabIndex = 0;
this.mInputLabel.Text = "压缩目录:";
this.mInputLabel.Click += new System.EventHandler(this.mInputLabel_Click);
//
// mInputTextBox
//
this.mInputTextBox.Location = new System.Drawing.Point(75, 60);
this.mInputTextBox.Name = "mInputTextBox";
this.mInputTextBox.Size = new System.Drawing.Size(438, 21);
this.mInputTextBox.TabIndex = 0;
this.mInputTextBox.TabStop = false;
this.mInputTextBox.Text = "D:\\BIC-input";
//
// mInputBrowseButton
//
this.mInputBrowseButton.Location = new System.Drawing.Point(535, 58);
this.mInputBrowseButton.Name = "mInputBrowseButton";
this.mInputBrowseButton.Size = new System.Drawing.Size(60, 23);
this.mInputBrowseButton.TabIndex = 1;
this.mInputBrowseButton.Text = "选择";
this.mInputBrowseButton.UseVisualStyleBackColor = true;
this.mInputBrowseButton.Click += new System.EventHandler(this.InputBrowseButton_Click);
//
// mOutputLabel
//
this.mOutputLabel.AutoSize = true;
this.mOutputLabel.Location = new System.Drawing.Point(10, 100);
this.mOutputLabel.Name = "mOutputLabel";
this.mOutputLabel.Size = new System.Drawing.Size(59, 12);
this.mOutputLabel.TabIndex = 0;
this.mOutputLabel.Text = "压缩输出:";
//
// mOutputTextBox
//
this.mOutputTextBox.Location = new System.Drawing.Point(75, 96);
this.mOutputTextBox.Name = "mOutputTextBox";
this.mOutputTextBox.Size = new System.Drawing.Size(438, 21);
this.mOutputTextBox.TabIndex = 0;
this.mOutputTextBox.TabStop = false;
this.mOutputTextBox.Text = "D:\\BIC-out";
//
// mOutputBrowseButton
//
this.mOutputBrowseButton.Location = new System.Drawing.Point(535, 96);
this.mOutputBrowseButton.Name = "mOutputBrowseButton";
this.mOutputBrowseButton.Size = new System.Drawing.Size(123, 21);
this.mOutputBrowseButton.TabIndex = 2;
this.mOutputBrowseButton.Text = "选择";
this.mOutputBrowseButton.UseVisualStyleBackColor = true;
this.mOutputBrowseButton.Click += new System.EventHandler(this.OutputBrowseButton_Click);
//
// mProblematicLabel
//
this.mProblematicLabel.AutoSize = true;
this.mProblematicLabel.Location = new System.Drawing.Point(10, 135);
this.mProblematicLabel.Name = "mProblematicLabel";
this.mProblematicLabel.Size = new System.Drawing.Size(59, 12);
this.mProblematicLabel.TabIndex = 0;
this.mProblematicLabel.Text = "失败转移:";
//
// mProblematicTextBox
//
this.mProblematicTextBox.Location = new System.Drawing.Point(75, 131);
this.mProblematicTextBox.Name = "mProblematicTextBox";
this.mProblematicTextBox.Size = new System.Drawing.Size(438, 21);
this.mProblematicTextBox.TabIndex = 0;
this.mProblematicTextBox.TabStop = false;
this.mProblematicTextBox.Text = "D:\\BIC-pr";
//
// mProblematicBrowseButton
//
this.mProblematicBrowseButton.Location = new System.Drawing.Point(535, 131);
this.mProblematicBrowseButton.Name = "mProblematicBrowseButton";
this.mProblematicBrowseButton.Size = new System.Drawing.Size(123, 21);
this.mProblematicBrowseButton.TabIndex = 3;
this.mProblematicBrowseButton.Text = "选择";
this.mProblematicBrowseButton.UseVisualStyleBackColor = true;
this.mProblematicBrowseButton.Click += new System.EventHandler(this.mProblematicBrowseButton_Click);
//
// mResolutionGroupBox
//
this.mResolutionGroupBox.Controls.Add(this.label6);
this.mResolutionGroupBox.Controls.Add(this.mud_fileLimitSize);
this.mResolutionGroupBox.Controls.Add(this.label7);
this.mResolutionGroupBox.Controls.Add(this.label5);
this.mResolutionGroupBox.Controls.Add(this.pud_OnceOfQuantity);
this.mResolutionGroupBox.Controls.Add(this.label4);
this.mResolutionGroupBox.Controls.Add(this.label3);
this.mResolutionGroupBox.Controls.Add(this.numericUpDown1);
this.mResolutionGroupBox.Controls.Add(this.label2);
this.mResolutionGroupBox.Controls.Add(this.comboBox1);
this.mResolutionGroupBox.Controls.Add(this.label1);
this.mResolutionGroupBox.Controls.Add(this.mQualityTextBox);
this.mResolutionGroupBox.Controls.Add(this.checkBox2);
this.mResolutionGroupBox.Controls.Add(this.checkBox1);
this.mResolutionGroupBox.Controls.Add(this.mResolutionPercentRadioButton);
this.mResolutionGroupBox.Controls.Add(this.mResolutionDimensionTextBox);
this.mResolutionGroupBox.Controls.Add(this.mResolutionDimensionRadioButton);
this.mResolutionGroupBox.Controls.Add(this.mResolutionPercentTextBox);
this.mResolutionGroupBox.Controls.Add(this.mQualityLabel);
this.mResolutionGroupBox.Location = new System.Drawing.Point(14, 250);
this.mResolutionGroupBox.Name = "mResolutionGroupBox";
this.mResolutionGroupBox.Size = new System.Drawing.Size(644, 135);
this.mResolutionGroupBox.TabIndex = 5;
this.mResolutionGroupBox.TabStop = false;
this.mResolutionGroupBox.Text = "选项";
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(447, 70);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(41, 12);
this.label6.TabIndex = 21;
this.label6.Text = "KB压缩";
//
// mud_fileLimitSize
//
this.mud_fileLimitSize.Enabled = false;
this.mud_fileLimitSize.Location = new System.Drawing.Point(364, 67);
this.mud_fileLimitSize.Maximum = new decimal(new int[] {
102400,
0,
0,
0});
this.mud_fileLimitSize.Name = "mud_fileLimitSize";
this.mud_fileLimitSize.Size = new System.Drawing.Size(77, 21);
this.mud_fileLimitSize.TabIndex = 20;
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(317, 69);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(41, 12);
this.label7.TabIndex = 19;
this.label7.Text = "超过:";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(599, 38);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(17, 12);
this.label5.TabIndex = 18;
this.label5.Text = "张";
//
// pud_OnceOfQuantity
//
this.pud_OnceOfQuantity.Enabled = false;
this.pud_OnceOfQuantity.Location = new System.Drawing.Point(542, 35);
this.pud_OnceOfQuantity.Maximum = new decimal(new int[] {
100000000,
0,
0,
0});
this.pud_OnceOfQuantity.Name = "pud_OnceOfQuantity";
this.pud_OnceOfQuantity.Size = new System.Drawing.Size(54, 21);
this.pud_OnceOfQuantity.TabIndex = 17;
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(481, 38);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(65, 12);
this.label4.TabIndex = 16;
this.label4.Text = "每次处理:";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(424, 37);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(35, 12);
this.label3.TabIndex = 15;
this.label3.Text = "/分钟";
this.label3.Click += new System.EventHandler(this.label3_Click);
//
// numericUpDown1
//
this.numericUpDown1.Enabled = false;
this.numericUpDown1.Location = new System.Drawing.Point(364, 33);
this.numericUpDown1.Name = "numericUpDown1";
this.numericUpDown1.Size = new System.Drawing.Size(58, 21);
this.numericUpDown1.TabIndex = 14;
this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(305, 37);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(65, 12);
this.label2.TabIndex = 13;
this.label2.Text = "定时间隔:";
this.label2.Click += new System.EventHandler(this.label2_Click);
//
// comboBox1
//
this.comboBox1.Enabled = false;
this.comboBox1.FormattingEnabled = true;
this.comboBox1.Location = new System.Drawing.Point(230, 35);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(57, 20);
this.comboBox1.TabIndex = 12;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(158, 40);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(65, 12);
this.label1.TabIndex = 11;
this.label1.Text = "执行时间:";
this.label1.Click += new System.EventHandler(this.label1_Click);
//
// mQualityTextBox
//
this.mQualityTextBox.Location = new System.Drawing.Point(230, 63);
this.mQualityTextBox.Name = "mQualityTextBox";
this.mQualityTextBox.Size = new System.Drawing.Size(57, 21);
this.mQualityTextBox.TabIndex = 10;
this.mQualityTextBox.Value = new decimal(new int[] {
60,
0,
0,
0});
this.mQualityTextBox.ValueChanged += new System.EventHandler(this.mQualityTextBox_ValueChanged);
//
// checkBox2
//
this.checkBox2.AutoSize = true;
this.checkBox2.Location = new System.Drawing.Point(119, 103);
this.checkBox2.Name = "checkBox2";
this.checkBox2.Size = new System.Drawing.Size(168, 16);
this.checkBox2.TabIndex = 9;
this.checkBox2.Text = "压缩完是否删除源目录文件";
this.checkBox2.UseVisualStyleBackColor = true;
//
// checkBox1
//
this.checkBox1.AutoSize = true;
this.checkBox1.CheckAlign = System.Drawing.ContentAlignment.BottomLeft;
this.checkBox1.Checked = true;
this.checkBox1.CheckState = System.Windows.Forms.CheckState.Checked;
this.checkBox1.Location = new System.Drawing.Point(6, 103);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(72, 16);
this.checkBox1.TabIndex = 8;
this.checkBox1.Text = "是否覆盖";
this.checkBox1.UseVisualStyleBackColor = true;
//
// mResolutionPercentRadioButton
//
this.mResolutionPercentRadioButton.AutoSize = true;
this.mResolutionPercentRadioButton.Location = new System.Drawing.Point(6, 35);
this.mResolutionPercentRadioButton.Name = "mResolutionPercentRadioButton";
this.mResolutionPercentRadioButton.Size = new System.Drawing.Size(71, 16);
this.mResolutionPercentRadioButton.TabIndex = 3;
this.mResolutionPercentRadioButton.Text = "按比例:";
this.mResolutionPercentRadioButton.UseVisualStyleBackColor = true;
this.mResolutionPercentRadioButton.CheckedChanged += new System.EventHandler(this.ResolutionPercentRadioButton_CheckedChanged);
//
// mResolutionDimensionTextBox
//
this.mResolutionDimensionTextBox.Location = new System.Drawing.Point(77, 67);
this.mResolutionDimensionTextBox.MaxLength = 4;
this.mResolutionDimensionTextBox.Name = "mResolutionDimensionTextBox";
this.mResolutionDimensionTextBox.Size = new System.Drawing.Size(57, 21);
this.mResolutionDimensionTextBox.TabIndex = 5;
//
// mResolutionDimensionRadioButton
//
this.mResolutionDimensionRadioButton.AutoSize = true;
this.mResolutionDimensionRadioButton.Checked = true;
this.mResolutionDimensionRadioButton.Location = new System.Drawing.Point(6, 68);
this.mResolutionDimensionRadioButton.Name = "mResolutionDimensionRadioButton";
this.mResolutionDimensionRadioButton.Size = new System.Drawing.Size(71, 16);
this.mResolutionDimensionRadioButton.TabIndex = 4;
this.mResolutionDimensionRadioButton.TabStop = true;
this.mResolutionDimensionRadioButton.Text = "按尺寸:";
this.mResolutionDimensionRadioButton.UseVisualStyleBackColor = true;
this.mResolutionDimensionRadioButton.CheckedChanged += new System.EventHandler(this.ResolutionDimensionRadioButton_CheckedChanged);
//
// mResolutionPercentTextBox
//
this.mResolutionPercentTextBox.Enabled = false;
this.mResolutionPercentTextBox.Location = new System.Drawing.Point(77, 34);
this.mResolutionPercentTextBox.MaxLength = 3;
this.mResolutionPercentTextBox.Name = "mResolutionPercentTextBox";
this.mResolutionPercentTextBox.Size = new System.Drawing.Size(57, 21);
this.mResolutionPercentTextBox.TabIndex = 6;
//
// mQualityLabel
//
this.mQualityLabel.AutoSize = true;
this.mQualityLabel.Location = new System.Drawing.Point(173, 69);
this.mQualityLabel.Name = "mQualityLabel";
this.mQualityLabel.Size = new System.Drawing.Size(41, 12);
this.mQualityLabel.TabIndex = 0;
this.mQualityLabel.Text = "品质:";
this.mQualityLabel.Click += new System.EventHandler(this.mQualityLabel_Click);
//
// mCompressButton
//
this.mCompressButton.Location = new System.Drawing.Point(9, 435);
this.mCompressButton.Name = "mCompressButton";
this.mCompressButton.Size = new System.Drawing.Size(678, 33);
this.mCompressButton.TabIndex = 8;
this.mCompressButton.Text = "压缩";
this.mCompressButton.UseVisualStyleBackColor = true;
this.mCompressButton.Click += new System.EventHandler(this.CompressButton_Click);
//
// mBackgroundWorker
//
this.mBackgroundWorker.WorkerReportsProgress = true;
this.mBackgroundWorker.WorkerSupportsCancellation = true;
this.mBackgroundWorker.DoWork += new System.ComponentModel.DoWorkEventHandler(this.mBackgroundWorker_DoWork);
this.mBackgroundWorker.ProgressChanged += new System.ComponentModel.ProgressChangedEventHandler(this.mBackgroundWorker_ProgressChanged);
this.mBackgroundWorker.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.mBackgroundWorker_RunWorkerCompleted);
//
// statusStrip1
//
this.statusStrip1.AutoSize = false;
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.progressBar1});
this.statusStrip1.Location = new System.Drawing.Point(0, 471);
this.statusStrip1.Name = "statusStrip1";
this.statusStrip1.Size = new System.Drawing.Size(696, 22);
this.statusStrip1.SizingGrip = false;
this.statusStrip1.TabIndex = 10;
this.statusStrip1.Text = "statusStrip1";
//
// progressBar1
//
this.progressBar1.Name = "progressBar1";
this.progressBar1.Size = new System.Drawing.Size(692, 16);
//
// tabControl1
//
this.tabControl1.Controls.Add(this.tabPage1);
this.tabControl1.Controls.Add(this.tabPage2);
this.tabControl1.Controls.Add(this.tabPage3);
this.tabControl1.Location = new System.Drawing.Point(12, 12);
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(678, 417);
this.tabControl1.TabIndex = 11;
//
// tabPage1
//
this.tabPage1.Controls.Add(this.button2);
this.tabPage1.Controls.Add(this.txt_sourceFilePath);
this.tabPage1.Controls.Add(this.groupBox1);
this.tabPage1.Controls.Add(this.rb_autoCompress);
this.tabPage1.Controls.Add(this.radioButton1);
this.tabPage1.Controls.Add(this.button1);
this.tabPage1.Controls.Add(this.mInputLabel);
this.tabPage1.Controls.Add(this.mResolutionGroupBox);
this.tabPage1.Controls.Add(this.mProblematicBrowseButton);
this.tabPage1.Controls.Add(this.mOutputBrowseButton);
this.tabPage1.Controls.Add(this.mProblematicLabel);
this.tabPage1.Controls.Add(this.mOutputTextBox);
this.tabPage1.Controls.Add(this.mProblematicTextBox);
this.tabPage1.Controls.Add(this.mOutputLabel);
this.tabPage1.Controls.Add(this.mInputBrowseButton);
this.tabPage1.Controls.Add(this.mInputTextBox);
this.tabPage1.Location = new System.Drawing.Point(4, 22);
this.tabPage1.Name = "tabPage1";
this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
this.tabPage1.Size = new System.Drawing.Size(670, 391);
this.tabPage1.TabIndex = 0;
this.tabPage1.Text = "系统配置";
this.tabPage1.UseVisualStyleBackColor = true;
//
// button2
//
this.button2.Location = new System.Drawing.Point(535, 22);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(120, 23);
this.button2.TabIndex = 21;
this.button2.Text = "监控目录";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// txt_sourceFilePath
//
this.txt_sourceFilePath.Location = new System.Drawing.Point(197, 24);
this.txt_sourceFilePath.Name = "txt_sourceFilePath";
this.txt_sourceFilePath.Size = new System.Drawing.Size(316, 21);
this.txt_sourceFilePath.TabIndex = 20;
this.txt_sourceFilePath.Text = "D:\\BIC-mon";
//
// groupBox1
//
this.groupBox1.Controls.Add(this.radioButton7);
this.groupBox1.Controls.Add(this.radioButton6);
this.groupBox1.Controls.Add(this.radioButton5);
this.groupBox1.Controls.Add(this.radioButton4);
this.groupBox1.Controls.Add(this.radioButton3);
this.groupBox1.Controls.Add(this.radioButton8);
this.groupBox1.Controls.Add(this.radioButton9);
this.groupBox1.Location = new System.Drawing.Point(12, 171);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(646, 63);
this.groupBox1.TabIndex = 19;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "计划";
//
// radioButton7
//
this.radioButton7.AutoSize = true;
this.radioButton7.Enabled = false;
this.radioButton7.Location = new System.Drawing.Point(560, 29);
this.radioButton7.Name = "radioButton7";
this.radioButton7.Size = new System.Drawing.Size(59, 16);
this.radioButton7.TabIndex = 30;
this.radioButton7.Text = "星期天";
this.radioButton7.UseVisualStyleBackColor = true;
//
// radioButton6
//
this.radioButton6.AutoSize = true;
this.radioButton6.Enabled = false;
this.radioButton6.Location = new System.Drawing.Point(470, 29);
this.radioButton6.Name = "radioButton6";
this.radioButton6.Size = new System.Drawing.Size(59, 16);
this.radioButton6.TabIndex = 29;
this.radioButton6.Text = "星期六";
this.radioButton6.UseVisualStyleBackColor = true;
//
// radioButton5
//
this.radioButton5.AutoSize = true;
this.radioButton5.Enabled = false;
this.radioButton5.Location = new System.Drawing.Point(380, 29);
this.radioButton5.Name = "radioButton5";
this.radioButton5.Size = new System.Drawing.Size(59, 16);
this.radioButton5.TabIndex = 28;
this.radioButton5.Text = "星期五";
this.radioButton5.UseVisualStyleBackColor = true;
//
// radioButton4
//
this.radioButton4.AutoSize = true;
this.radioButton4.Enabled = false;
this.radioButton4.Location = new System.Drawing.Point(290, 29);
this.radioButton4.Name = "radioButton4";
this.radioButton4.Size = new System.Drawing.Size(59, 16);
this.radioButton4.TabIndex = 27;
this.radioButton4.Text = "星期四";
this.radioButton4.UseVisualStyleBackColor = true;
//
// radioButton3
//
this.radioButton3.AutoSize = true;
this.radioButton3.Enabled = false;
this.radioButton3.Location = new System.Drawing.Point(200, 29);
this.radioButton3.Name = "radioButton3";
this.radioButton3.Size = new System.Drawing.Size(59, 16);
this.radioButton3.TabIndex = 26;
this.radioButton3.Text = "星期三";
this.radioButton3.UseVisualStyleBackColor = true;
//
// radioButton8
//
this.radioButton8.AutoSize = true;
this.radioButton8.Enabled = false;
this.radioButton8.Location = new System.Drawing.Point(110, 29);
this.radioButton8.Name = "radioButton8";
this.radioButton8.Size = new System.Drawing.Size(59, 16);
this.radioButton8.TabIndex = 25;
this.radioButton8.Text = "星期二";
this.radioButton8.UseVisualStyleBackColor = true;
//
// radioButton9
//
this.radioButton9.AutoSize = true;
this.radioButton9.Checked = true;
this.radioButton9.Enabled = false;
this.radioButton9.Location = new System.Drawing.Point(20, 29);
this.radioButton9.Name = "radioButton9";
this.radioButton9.Size = new System.Drawing.Size(59, 16);
this.radioButton9.TabIndex = 24;
this.radioButton9.TabStop = true;
this.radioButton9.Text = "星期一";
this.radioButton9.UseVisualStyleBackColor = true;
//
// rb_autoCompress
//
this.rb_autoCompress.AutoSize = true;
this.rb_autoCompress.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;
this.rb_autoCompress.Location = new System.Drawing.Point(102, 24);
this.rb_autoCompress.Name = "rb_autoCompress";
this.rb_autoCompress.Size = new System.Drawing.Size(71, 16);
this.rb_autoCompress.TabIndex = 8;
this.rb_autoCompress.Text = "自动模式";
this.rb_autoCompress.UseVisualStyleBackColor = true;
this.rb_autoCompress.CheckedChanged += new System.EventHandler(this.radioButton2_CheckedChanged);
//
// radioButton1
//
this.radioButton1.AutoSize = true;
this.radioButton1.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;
this.radioButton1.Checked = true;
this.radioButton1.Location = new System.Drawing.Point(12, 24);
this.radioButton1.Name = "radioButton1";
this.radioButton1.Size = new System.Drawing.Size(71, 16);
this.radioButton1.TabIndex = 7;
this.radioButton1.TabStop = true;
this.radioButton1.Text = "普通模式";
this.radioButton1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.radioButton1.UseVisualStyleBackColor = true;
this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged);
//
// button1
//
this.button1.Location = new System.Drawing.Point(598, 58);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(60, 23);
this.button1.TabIndex = 6;
this.button1.Text = "部分";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// tabPage2
//
this.tabPage2.Controls.Add(this.dataGridView1);
this.tabPage2.Location = new System.Drawing.Point(4, 22);
this.tabPage2.Name = "tabPage2";
this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
this.tabPage2.Size = new System.Drawing.Size(670, 391);
this.tabPage2.TabIndex = 1;
this.tabPage2.Text = "文件队列";
this.tabPage2.UseVisualStyleBackColor = true;
//
// dataGridView1
//
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.name,
this.size,
this.status,
this.Id});
this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill;
this.dataGridView1.Location = new System.Drawing.Point(3, 3);
this.dataGridView1.Name = "dataGridView1";
this.dataGridView1.RowTemplate.Height = 23;
this.dataGridView1.Size = new System.Drawing.Size(664, 385);
this.dataGridView1.TabIndex = 0;
//
// name
//
this.name.HeaderText = "名称";
this.name.Name = "name";
this.name.Width = 400;
//
// size
//
this.size.HeaderText = "大小";
this.size.Name = "size";
//
// status
//
this.status.HeaderText = "状态";
this.status.Name = "status";
this.status.Width = 150;
//
// Id
//
this.Id.HeaderText = "标识";
this.Id.Name = "Id";
this.Id.Visible = false;
//
// tabPage3
//
this.tabPage3.Controls.Add(this.textBox1);
this.tabPage3.Location = new System.Drawing.Point(4, 22);
this.tabPage3.Name = "tabPage3";
this.tabPage3.Size = new System.Drawing.Size(670, 391);
this.tabPage3.TabIndex = 2;
this.tabPage3.Text = "日志";
this.tabPage3.UseVisualStyleBackColor = true;
//
// textBox1
//
this.textBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.textBox1.Location = new System.Drawing.Point(0, 0);
this.textBox1.Margin = new System.Windows.Forms.Padding(5);
this.textBox1.Multiline = true;
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(670, 391);
this.textBox1.TabIndex = 0;
//
// openFileDialog1
//
this.openFileDialog1.FileName = "openFileDialog1";
//
// BICompressor
//
this.ClientSize = new System.Drawing.Size(696, 493);
this.Controls.Add(this.tabControl1);
this.Controls.Add(this.statusStrip1);
this.Controls.Add(this.mCompressButton);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.Name = "BICompressor";
this.Text = "Dorisoy.BICompressor";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.BICompressorForm_Closing);
this.Load += new System.EventHandler(this.BICompressorForm_Load);
this.mResolutionGroupBox.ResumeLayout(false);
this.mResolutionGroupBox.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.mud_fileLimitSize)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pud_OnceOfQuantity)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.mQualityTextBox)).EndInit();
this.statusStrip1.ResumeLayout(false);
this.statusStrip1.PerformLayout();
this.tabControl1.ResumeLayout(false);
this.tabPage1.ResumeLayout(false);
this.tabPage1.PerformLayout();
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.tabPage2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
this.tabPage3.ResumeLayout(false);
this.tabPage3.PerformLayout();
this.ResumeLayout(false);
}
private void BICompressorForm_Load(object sender, EventArgs e)
{
mResolutionDimensionTextBox.Text = mDefaultResolutionDimension.ToString();
mResolutionPercentTextBox.Text = mDefaultResolutionPercent.ToString();
mQualityTextBox.Text = mDefaultQuality.ToString();
mParallelOptions = new ParallelOptions();
mParallelOptions.MaxDegreeOfParallelism = Environment.ProcessorCount;
this.txt_sourceFilePath.Enabled = false;
this.button2.Enabled = false;
//
InitComBox();
//load once of quantity
int onceOfQuantity= AppConfig.GetOnceOfQuantity();
this.pud_OnceOfQuantity.Value= onceOfQuantity;
//load fileLimitSize
int fileLimitSize = AppConfig.GetFileLimitSize();
this.mud_fileLimitSize.Value = fileLimitSize;
this.CenterToParent();
}
private void InitComBox()
{
this.numericUpDown1.Value =0;
var mylist = new ArrayList();
for (var i = 0; i < 24; i++)
{
if (i >= 10)
mylist.Add(new DictionaryEntry(string.Format("{0}:00", i), string.Format("{0}:00", i)));
else
mylist.Add(new DictionaryEntry(string.Format("0{0}:00", i), string.Format("0{0}:00", i)));
}
if (mylist.Count > 0)
{
comboBox1.DataSource = mylist;
comboBox1.DisplayMember = "Value";
comboBox1.ValueMember = "Key";
comboBox1.SelectedIndex = 0;
}
}
private void BICompressorForm_Closing(object sender, FormClosingEventArgs e)
{
if (mBackgroundWorker.IsBusy && !PromptCancel())
{
e.Cancel = true;
}
}
private void InputBrowseButton_Click(object sender, EventArgs e)
{
if (Directory.Exists(mInputTextBox.Text))
{
mInputBrowseDialog.SelectedPath = mInputTextBox.Text;
}
if (mInputBrowseDialog.ShowDialog() == DialogResult.OK)
{
mInputTextBox.Text = mInputBrowseDialog.SelectedPath;
}
}
private void OutputBrowseButton_Click(object sender, EventArgs e)
{
if (Directory.Exists(mOutputTextBox.Text))
{
mOutputBrowseDialog.SelectedPath = mOutputTextBox.Text;
}
if (mOutputBrowseDialog.ShowDialog() == DialogResult.OK)
{
mOutputTextBox.Text = mOutputBrowseDialog.SelectedPath;
}
}
private void mProblematicBrowseButton_Click(object sender, EventArgs e)
{
if (Directory.Exists(mProblematicTextBox.Text))
{
mProblematicBrowseDialog.SelectedPath = mProblematicTextBox.Text;
}
if (mProblematicBrowseDialog.ShowDialog() == DialogResult.OK)
{
mProblematicTextBox.Text = mProblematicBrowseDialog.SelectedPath;
}
}
private void ResolutionDimensionRadioButton_CheckedChanged(object sender, EventArgs e)
{
mResolutionDimensionTextBox.Enabled = true;
mResolutionPercentTextBox.Enabled = false;
}
private void ResolutionPercentRadioButton_CheckedChanged(object sender, EventArgs e)
{
mResolutionDimensionTextBox.Enabled = false;
mResolutionPercentTextBox.Enabled = true;
}
private void CompressButton_Click(object sender, EventArgs e)
{
string validationResult = ValidateUserInput();
if (!string.IsNullOrEmpty(validationResult))
{
MessageBox.Show(
this,
validationResult,
msTitleBarText,
MessageBoxButtons.OK,
MessageBoxIcon.Error
);
return;
}
var jobs = JobManager.AllSchedules;
if (!this.rb_autoCompress.Checked && jobs.Count() == 0)
{
ProcessCompressor();
}
else
{
if (jobs.Count() == 0)
RunAutoMode();
else
{
LogText(DateTime.Now.ToString() + " 自动任务取消\n");
JobManager.RemoveAllJobs();
JobManager.Stop();
if (mBackgroundWorker.IsBusy)
{
PromptCancel();
}
else
{
mCompressButton.Text = "开始";
}
}
}
}
private void RunAutoMode()
{
if (comboBox1.SelectedValue != null)
{
Timer = comboBox1.SelectedValue.ToString();
}
this.TimeInterval = Convert.ToInt32(this.numericUpDown1.Value);
for (int i = 0; i < groupBox1.Controls.Count; i++)
{
if (groupBox1.Controls[i] is RadioButton)
{
var temp = (RadioButton)groupBox1.Controls[i];
if (temp.Checked)
{
switch (temp.Text)
{
case "星期一":
Weekday = 1;
break;
case "星期二":
Weekday = 2;
break;
case "星期三":
Weekday = 3;
break;
case "星期四":
Weekday = 4;
break;
case "星期五":
Weekday = 5;
break;
case "星期六":
Weekday = 6;
break;
case "星期天":
Weekday = 7;
break;
}
}
}
}
//开启自动任务
StartTask();
}
private void ProcessCompressor()
{
if (mBackgroundWorker.IsBusy)
{
PromptCancel();
}
else
{
mBackgroundWorker.RunWorkerAsync();
mCompressButton.Text = "取消";
}
}
/// <summary>
/// 开始任务
/// </summary>