Skip to main navigation Skip to main content Skip to page footer
pascal
 1unit StatusForm;
 2
 3interface
 4
 5uses
 6  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, System.Types, Vcl.Graphics,
 7  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.DBCtrls, Vcl.ExtCtrls, Vcl.ComCtrls,
 8  Util, StrUtils, TL.Components;
 9
10type
11  TfrmStatus = class(TLForm)
12    Panel1: TPanel;
13    ProgressBar1: TProgressBar;
14    ProgressBar2: TProgressBar;
15    Label6: TLabel;
16    lblState: TLabel;
17    Label7: TLabel;
18    Panel2: TPanel;
19    btnOk: TButton;
20    btnCancel: TButton;
21    Panel3: TPanel;
22    lblFilesDetected: TLabel;
23    lblFilesProcessed: TLabel;
24    lblFilesMoved: TLabel;
25    lblDuplicateFiles: TLabel;
26    lblProcessingFile: TLabel;
27    Label1: TLabel;
28    Label2: TLabel;
29    Label3: TLabel;
30    Label4: TLabel;
31    Label5: TLabel;
32    Label8: TLabel;
33    Label9: TLabel;
34    procedure FormCreate(Sender: TObject);
35    procedure btnCancelClick(Sender: TObject);
36  private
37    FTotalFilesDetected: integer;
38    FState: Tstate;
39    FProcessingFile: string;
40    FFileAction: TFileAction;
41    function GetFilesDetected: integer;
42    procedure SetFilesDetected(const Value: integer);
43    function GetFilesProcessed: integer;
44    procedure SetFilesProcessed(const Value: integer);
45    function GetFilesMoved: integer;
46    procedure SetFilesMoved(const Value: integer);
47    function GetDuplicateFiles: integer;
48    procedure SetDuplicateFiles(const Value: integer);
49    function GetProcessingFile: string;
50    procedure SetProcessingFile(const Value: string);
51    function GetProgress: integer;
52    procedure SetProgress(const Value: integer);
53    procedure SetState(const Value: TState);
54    procedure SetFileAction(Action: TFileAction);
55    { Private declarations }
56  public
57    { Public declarations }
58    Cancel: bool;
59    property FilesDetected: integer read GetFilesDetected write SetFilesDetected;
60    property FilesProcessed: integer read GetFilesProcessed write SetFilesProcessed;
61    property FilesMoved: integer read GetFilesMoved write SetFilesMoved;
62    property DuplicateFiles: integer read GetDuplicateFiles write SetDuplicateFiles;
63    property ProcessingFile: string read GetProcessingFile write SetProcessingFile;
64    property Progress: integer read GetProgress write SetProgress;
65    property TotalFilesDetected: integer read FTotalFilesDetected write FTotalFilesDetected;
66    property State: TState read FState write SetState;
67    property FileAction: TFileAction read FFileAction write SetFileAction;
68  end;
69
70implementation
71
72{$R *.dfm}
73
74{ TForm2 }
75
76procedure TfrmStatus.SetFileAction(Action: TFileAction);
77begin
78  FFileAction:= Action;
79  Label3.Caption:= FileActionStr[Action];
80end;
81
82procedure TfrmStatus.btnCancelClick(Sender: TObject);
83begin
84  Cancel:= TRUE;
85end;
86
87procedure TfrmStatus.FormCreate(Sender: TObject);
88begin
89  lblFilesDetected.Caption:= '0';
90  lblFilesProcessed.Caption:= '0';
91  lblFilesMoved.Caption:= '0';
92  lblDuplicateFiles.Caption:= '0';
93  lblProcessingFile.Caption:= '';
94  btnOk.Enabled:= FALSE;
95  Cancel:= FALSE;
96end;
97
98function TfrmStatus.GetProgress: integer;
99begin
100  Result:= ProgressBar1.Position;
101end;
102
103procedure TfrmStatus.SetProgress(const Value: integer);
104begin
105  ProgressBar1.Position:= Round(Value  / FTotalFilesDetected * 100);
106  case FState of
107     stNone: ;
108     stScan:  ProgressBar2.Position:= Round(Value  / FTotalFilesDetected * 20);
109     stGetExif: ProgressBar2.Position:= 20 + Round(Value  / FTotalFilesDetected * 80);
110     stRestructure: ProgressBar2.Position:= Round(Value  / FTotalFilesDetected * 100);
111     stCompleted: begin
112       ProgressBar1.Position:= 100;
113       ProgressBar2.Position:= 100;
114     end;
115  end;
116  Label8.Caption:= ProgressBar1.Position.ToString + '%';
117  Label9.Caption:= ProgressBar2.Position.ToString + '%';
118
119end;
120
121function TfrmStatus.GetDuplicateFiles: integer;
122begin
123  Result:= StrToInt(lblDuplicateFiles.Caption);
124end;
125
126function TfrmStatus.GetFilesDetected: integer;
127begin
128  Result:= StrToInt(lblFilesDetected.Caption);
129end;
130
131function TfrmStatus.GetFilesMoved: integer;
132begin
133  Result:= StrToInt(lblFilesMoved.Caption);
134end;
135
136function TfrmStatus.GetFilesProcessed: integer;
137begin
138  Result:= StrToInt(lblFilesProcessed.Caption);
139end;
140
141function TfrmStatus.GetProcessingFile: String;
142begin
143  Result:= FProcessingFile;
144end;
145
146procedure TfrmStatus.SetDuplicateFiles(const Value: integer);
147begin
148  lblDuplicateFiles.Caption:= Value.ToString;
149end;
150
151procedure TfrmStatus.SetFilesDetected(const Value: integer);
152begin
153  lblFilesDetected.Caption:= Value.ToString;
154end;
155
156procedure TfrmStatus.SetFilesMoved(const Value: integer);
157begin
158  lblFilesMoved.Caption:= Value.ToString;
159end;
160
161procedure TfrmStatus.SetFilesProcessed(const Value: integer);
162begin
163  SetProgress(Value);
164  lblFilesProcessed.Caption:= Value.ToString;
165end;
166
167procedure TfrmStatus.SetProcessingFile(const Value: string);
168begin
169  lblProcessingFile.Caption:= TruncateFileName(Value, 100);
170  FProcessingFile:= Value;
171end;
172
173procedure TfrmStatus.SetState(const Value: TState);
174begin
175  FState:= Value;
176  lblState.Caption:= StateStr[FState];
177end;
178
179
180end.
181