-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfigFrameBase.pas
More file actions
83 lines (68 loc) · 1.84 KB
/
ConfigFrameBase.pas
File metadata and controls
83 lines (68 loc) · 1.84 KB
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
unit ConfigFrameBase;
interface
uses
System.SysUtils, System.Classes, System.JSON, JSONHelpers, Vcl.Controls, Vcl.Forms,
Vcl.StdCtrls, Vcl.ExtCtrls, Vcl.ComCtrls, Vcl.Graphics, Vcl.Dialogs,
UtilsTypes;
type
// 基础配置框架类
TBaseConfigFrame = class(TFrame)
private
FJSONObject: TJSONObject;
FOnModified: TNotifyEvent;
FModified: Boolean;
procedure SetModified(const Value: Boolean);
protected
procedure CreateControls; virtual;
procedure EditModified(Sender: TObject); virtual;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure SaveToJSON; virtual;
procedure LoadFromJSON; virtual;
procedure SetJSONObject(const Value: TJSONObject);
property JSONObject: TJSONObject read FJSONObject write SetJSONObject;
property OnModified: TNotifyEvent read FOnModified write FOnModified;
property Modified: Boolean read FModified write SetModified;
end;
implementation
{ TBaseConfigFrame }
constructor TBaseConfigFrame.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FJSONObject := nil;
FModified := False;
end;
destructor TBaseConfigFrame.Destroy;
begin
inherited;
end;
procedure TBaseConfigFrame.SetJSONObject(const Value: TJSONObject);
begin
FJSONObject := Value;
LoadFromJSON;
end;
procedure TBaseConfigFrame.SetModified(const Value: Boolean);
begin
FModified := Value;
if Assigned(FOnModified) then
FOnModified(Self);
end;
procedure TBaseConfigFrame.LoadFromJSON;
begin
// 基类中不实现具体逻辑
end;
procedure TBaseConfigFrame.SaveToJSON;
begin
// 基类中不实现具体逻辑
end;
procedure TBaseConfigFrame.CreateControls;
begin
// 基类中不实现具体逻辑
end;
procedure TBaseConfigFrame.EditModified(Sender: TObject);
begin
// 设置修改标记
Modified := True;
end;
end.