source: Common/Demo/JobProgressView/UFormMain.pas

Last change on this file was 563, checked in by chronos, 18 months ago
  • Modified: Removed U prefix from all Common package units.
File size: 1.6 KB
Line 
1unit UFormMain;
2
3{$mode delphi}{$H+}
4
5interface
6
7uses
8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
9 Spin, JobProgressView;
10
11type
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
33var
34 FormMain: TFormMain;
35
36implementation
37
38{$R *.lfm}
39
40{ TFormMain }
41
42procedure TFormMain.ButtonTestClick(Sender: TObject);
43var
44 I: Integer;
45begin
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;
56end;
57
58procedure TFormMain.JobMethod(Job: TJob);
59var
60 Count: Integer;
61 I: Integer;
62begin
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;
73end;
74
75end.
76
Note: See TracBrowser for help on using the repository browser.