1 | unit UFormMain;
|
---|
2 |
|
---|
3 | {$mode delphi}{$H+}
|
---|
4 |
|
---|
5 | interface
|
---|
6 |
|
---|
7 | uses
|
---|
8 | Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
|
---|
9 | Spin, JobProgressView;
|
---|
10 |
|
---|
11 | type
|
---|
12 |
|
---|
13 | { TFormMain }
|
---|
14 |
|
---|
15 | TFormMain = class(TForm)
|
---|
16 | ButtonTest: TButton;
|
---|
17 | CheckBoxAutoClose: TCheckBox;
|
---|
18 | CheckBoxTextProgress: TCheckBox;
|
---|
19 | CheckBoxErrors: TCheckBox;
|
---|
20 | JobProgressView1: TJobProgressView;
|
---|
21 | Label1: TLabel;
|
---|
22 | Label2: TLabel;
|
---|
23 | Label3: TLabel;
|
---|
24 | SpinEditJobCount: TSpinEdit;
|
---|
25 | SpinEditShowDelay: TSpinEdit;
|
---|
26 | procedure ButtonTestClick(Sender: TObject);
|
---|
27 | private
|
---|
28 | procedure JobMethod(Job: TJob);
|
---|
29 | public
|
---|
30 |
|
---|
31 | end;
|
---|
32 |
|
---|
33 | var
|
---|
34 | FormMain: TFormMain;
|
---|
35 |
|
---|
36 | implementation
|
---|
37 |
|
---|
38 | {$R *.lfm}
|
---|
39 |
|
---|
40 | { TFormMain }
|
---|
41 |
|
---|
42 | procedure TFormMain.ButtonTestClick(Sender: TObject);
|
---|
43 | var
|
---|
44 | I: Integer;
|
---|
45 | begin
|
---|
46 | ButtonTest.Enabled := False;
|
---|
47 | with JobProgressView1 do begin
|
---|
48 | AutoClose := CheckBoxAutoClose.Checked;
|
---|
49 | ShowDelay := SpinEditShowDelay.Value;
|
---|
50 |
|
---|
51 | for I := 0 to SpinEditJobCount.Value - 1 do
|
---|
52 | AddJob('Job ' + IntToStr(I + 1), JobMethod);
|
---|
53 | Start;
|
---|
54 | end;
|
---|
55 | ButtonTest.Enabled := True;
|
---|
56 | end;
|
---|
57 |
|
---|
58 | procedure TFormMain.JobMethod(Job: TJob);
|
---|
59 | var
|
---|
60 | Count: Integer;
|
---|
61 | I: Integer;
|
---|
62 | begin
|
---|
63 | Count := Random(100);
|
---|
64 | Job.Progress.Max := Count;
|
---|
65 | for I := 0 to Count - 1 do begin
|
---|
66 | Sleep(10);
|
---|
67 | Job.Progress.Value := I;
|
---|
68 | if CheckBoxErrors.Checked and (Random < 0.1) then
|
---|
69 | Job.AddLogItem('Error during execution');
|
---|
70 | if CheckBoxTextProgress.Checked then Job.Progress.Text := 'Processing item ' + IntToStr(I);
|
---|
71 | if Job.Terminate then Break;
|
---|
72 | end;
|
---|
73 | end;
|
---|
74 |
|
---|
75 | end.
|
---|
76 |
|
---|