-
Notifications
You must be signed in to change notification settings - Fork 27
/
Pkg.Json.OutputFormat.pas
89 lines (71 loc) · 1.89 KB
/
Pkg.Json.OutputFormat.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
unit Pkg.Json.OutputFormat;
interface
uses
System.Classes, System.Generics.Collections,
FMX.Types,
FMX.Memo, FMX.TabControl;
type
TOutputFormat = class
strict private
FOwner: TTabControl;
FTabCaption: string;
FOutput: string;
FFileExtention: string;
public
constructor Create(aOwner: TTabControl; aTabCaption: string; aOutput: string; aFileExtention: string); reintroduce;
procedure Execute;
property Output: string read FOutput;
property FileExtention: string read FFileExtention;
end;
TOutputFormatDict = class(TObjectDictionary<TTabItem, TOutputFormat>)
private
class var Instance: TOutputFormatDict;
public
constructor Create; reintroduce;
end;
function OutputFormatDict: TOutputFormatDict;
implementation
{ TOutputFormat }
function OutputFormatDict: TOutputFormatDict;
begin
if TOutputFormatDict.Instance = nil then
TOutputFormatDict.Instance := TOutputFormatDict.Create;
Result := TOutputFormatDict.Instance;
end;
constructor TOutputFormat.Create(aOwner: TTabControl; aTabCaption: string; aOutput: string; aFileExtention: string);
begin
inherited Create;
FOwner := aOwner;
FTabCaption := aTabCaption;
FOutput := aOutput;
FFileExtention := aFileExtention;
end;
procedure TOutputFormat.Execute;
var
TabItem: TTabItem;
begin
TabItem := FOwner.Add as TTabItem;
TabItem.Text := FTabCaption;
with TMemo.Create(TabItem) do
begin
Parent := TabItem;
Align := TAlignLayout.Client;
Text := FOutput;
WordWrap := True;
ReadOnly := True;
TextSettings.Font.Family := 'Consolas';
TextSettings.Font.Size := 14;
StyledSettings := StyledSettings - [TStyledSetting.Size];
Margins.Bottom := 4;
end;
OutputFormatDict.Add(TabItem, Self);
end;
{ TOutputFormatDict }
constructor TOutputFormatDict.Create;
begin
inherited Create([doOwnsValues]);
end;
initialization
finalization
OutputFormatDict.Free;
end.