-
Notifications
You must be signed in to change notification settings - Fork 60
/
Copy pathProgressFrame.pas
101 lines (88 loc) · 4.14 KB
/
ProgressFrame.pas
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
(**************************************************************************)
(* *)
(* Module: Unit 'ProgressFrame' Copyright (c) 2021 *)
(* *)
(* Lucas Moura Belo - lmbelo *)
(* lucas.belo@live.com *)
(* Brazil *)
(* *)
(* PyScripter *)
(* e-mail: pyscripter@gmail.com *)
(* *)
(* Project pages: https://github.com/Embarcadero/python4delphi *)
(* https://github.com/pyscripter/python4delphi *)
(**************************************************************************)
(* Functionality: Environment loading progress report *)
(* *)
(* *)
(**************************************************************************)
(* This source code is distributed with no WARRANTY, for no reason or use.*)
(* Everyone is allowed to use and change this code free for his own tasks *)
(* and projects, as long as this header and its copyright text is intact. *)
(* For changed versions of this code, which are public distributed the *)
(* following additional conditions have to be fullfilled: *)
(* 1) The header has to contain a comment on the change and the author of *)
(* it. *)
(* 2) A copy of the changed source has to be sent to the above E-Mail *)
(* address or my then valid address, if this is possible to the *)
(* author. *)
(* The second condition has the target to maintain an up to date central *)
(* version of the component. If this condition is not acceptable for *)
(* confidential or legal reasons, everyone is free to derive a component *)
(* or to generate a diff file to my or other original sources. *)
(**************************************************************************)
unit ProgressFrame;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Graphics, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls,
FMX.Controls.Presentation, FMX.Layouts, AppEnvironment;
type
TProgressViewFrame = class(TFrame, IProgressNotifier)
pnlContent: TPanel;
lbDescription: TLabel;
lblCurrentAction: TLabel;
pbProgress: TProgressBar;
pnlBackground: TPanel;
private
{ Private declarations }
public
constructor Create(AOwner: TComponent; const AForm: TCustomForm); reintroduce;
procedure Start(const ADescription, AFirstAction: string; const ATotal: Int64);
procedure Update(const ACurrentAction: string; const AProgress: Int64);
procedure Stop();
end;
implementation
uses
Math;
{$R *.fmx}
{ TProgressViewFrame }
constructor TProgressViewFrame.Create(AOwner: TComponent;
const AForm: TCustomForm);
begin
inherited Create(AOwner);
lblCurrentAction.Text := String.Empty;
Parent := AForm;
Align := TAlignLayout.Contents;
pnlContent.Width := Math.Min(AForm.Width - 40, 410);
end;
procedure TProgressViewFrame.Start(const ADescription, AFirstAction: string;
const ATotal: Int64);
begin
lbDescription.Text := ADescription;
lblCurrentAction.Text := AFirstAction;
pbProgress.Min := 0;
pbProgress.Max := ATotal;
pbProgress.Value := 0;
pnlContent.Visible := not ADescription.IsEmpty();
end;
procedure TProgressViewFrame.Stop;
begin
Self.Visible := false;
end;
procedure TProgressViewFrame.Update(const ACurrentAction: string; const AProgress: Int64);
begin
lblCurrentAction.Text := ACurrentAction;
pbProgress.Value := AProgress;
end;
end.