-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAssistantDeveloperControl.pas
More file actions
112 lines (94 loc) · 2.97 KB
/
AssistantDeveloperControl.pas
File metadata and controls
112 lines (94 loc) · 2.97 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
{**
@Abstract Контрол для создания и редактирования фреймов, модулей, агентов и т.д.
@Author Prof1983 <prof1983@ya.ru>
@Created 06.04.2007
@LastMod 23.11.2012
}
unit AssistantDeveloperControl;
interface
uses
ComCtrls, Controls, SysUtils,
ABase, ACodeControl, AControlImpl, AProgramImpl, ASystemData, ASystemUtils, ATypes,
AiConsts;
function AssistantDeveloperControl_Init(ts: TWinControl; OnSendMessage: TProcMessageStr): AError;
implementation
type //** Контрол для создания и редактирования фреймов, модулей, агентов и т.д.
TDeveloperControl = class(TAControl)
private
FCodeControls: array of TArCodeControl;
pcElements: TPageControl;
protected
function DoInitialize(): AError; override; safecall;
public
// Добавить вкладку редактирования кода
function NewCodeControl(const AName: WideString): TArCodeControl;
end;
var
{** Контрол для создания и редактирования фреймов, модулей, агентов и т.д. }
FDeveloperControl: TDeveloperControl;
// --- Public ---
function AssistantDeveloperControl_Init(ts: TWinControl; OnSendMessage: TProcMessageStr): AError;
begin
try
FDeveloperControl := TDeveloperControl.Create();
FDeveloperControl.Control := ts;
FDeveloperControl.OnSendMessage := OnSendMessage;
FDeveloperControl.Initialize();
except
FDeveloperControl := nil;
end;
end;
{ TDeveloperControl }
function TDeveloperControl.DoInitialize(): AError;
var
cc: TArCodeControl;
S: string;
DirectoryPath: string;
begin
Result := inherited DoInitialize();
pcElements := TPageControl.Create(FControl);
pcElements.Parent := FControl;
pcElements.Align := alClient;
DirectoryPath := FExePath;
// Создаем вкладку с кодом Example1
cc := NewCodeControl('Example1');
S := NormalizePath2(DirectoryPath + AiDataDir) + 'Example1.ar';
S := ExpandFileName(S);
if FileExists(S) then
cc.LoadFromFile(S)
else
begin
S := DirectoryPath + 'KnowlegeBase\Example1.ar';
if FileExists(S) then
cc.LoadFromFile(S);
end;
// Создаем вкладку с кодом Reason
cc := NewCodeControl('Reason');
S := DirectoryPath + '..\Data\Reason.ar';
S := ExpandFileName(S);
if FileExists(S) then
cc.LoadFromFile(S)
else
begin
S := DirectoryPath + 'KnowlegeBase\Reason.ar';
if FileExists(S) then
cc.LoadFromFile(S);
end;
end;
function TDeveloperControl.NewCodeControl(const AName: WideString): TArCodeControl;
var
ts: TTabSheet;
i: Integer;
begin
//ts := TTabSheet(DoTabMainAdd(tmMemo, AName));
ts := TTabSheet.Create(FControl);
ts.PageControl := pcElements;
ts.Caption := AName;
Result := TArCodeControl.Create();
Result.Control := ts;
Result.Initialize();
i := Length(FCodeControls);
SetLength(FCodeControls, i + 1);
FCodeControls[i] := Result;
end;
end.