-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathunHelpForms.pas
195 lines (163 loc) · 4.51 KB
/
unHelpForms.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
unit unHelpForms;
interface
uses Vcl.Forms,Vcl.ExtCtrls,Vcl.StdCtrls,Vcl.Buttons,System.SysUtils, Vcl.TabNotBk,
Vcl.dialogs,Vcl.Samples.Spin,unDevices;
Type
TDefDevForm = class(TForm)
private
class constructor Create;
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
function getmainpath: string;
protected
Param1SE:TSpinEdit;
Param2SE:TSpinEdit;
Param3SE:TSpinEdit;
Param4SE:TSpinEdit;
Param5SE:TSpinEdit;
Param6SE:TSpinEdit;
Param7SE:TSpinEdit;
procedure DoCreate; Override;
procedure DoShow; Override;
public
{ Public declarations }
ActiveDeviceId:Integer;
procedure RefreshBlockControls;
Function GetDeviceTypeId:Integer;
Function LblC:TLabel;
Function btnC:TBitBtn;
Procedure KillDevice;
procedure SetSEfromParam(Pno: integer; SE: TSpinedit);
Procedure SetParam(Pno:integer;SE:TSpinedit);
Function ActDev:TActiveDevice;
procedure NewMaxPins;
property AppPath:string read getmainpath;
end;
implementation
uses unCtrlPlatMain,Messages;
{ TDefDevForm }
procedure TDefDevForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
KillDevice;
end;
function TDefDevForm.ActDev: TActiveDevice;
begin
Result:=ActDevs[ActiveDeviceId];
end;
function TDefDevForm.btnC: TBitBtn;
begin
Result:= TBitBtn(frmRoboLang.getPanelAddButton(ArduinoDevices[GetDeviceTypeId].DevicePanel));
end;
class constructor TDefDevForm.Create;
begin
inherited;
end;
procedure TDefDevForm.DoCreate;
begin
ActiveDeviceId:=ActDevsCount;
inherited;
OnCloseQuery:=FormCloseQuery;
Param1SE:=nil;
Param2SE:=nil;
Param3SE:=nil;
Param4SE:=nil;
Param5SE:=nil;
Param6SE:=nil;
Param7SE:=nil;
end;
procedure TDefDevForm.DoShow;
begin
inherited;
SetSEfromParam(1,Param1SE);
SetSEfromParam(2,Param2SE);
SetSEfromParam(3,Param3SE);
SetSEfromParam(4,Param4SE);
SetSEfromParam(5,Param5SE);
SetSEfromParam(6,Param6SE);
SetSEfromParam(7,Param7SE);
RefreshBlockControls;
end;
function TDefDevForm.GetDeviceTypeId: Integer;
begin
Result:=ActDev.DeviceTypeID;
end;
function TDefDevForm.getmainpath: string;
begin
result:=mainpath;
end;
procedure TDefDevForm.KillDevice;
Var lbl:TLabel;
pi:Integer;
Begin
// lbl:=frmRoboLang.getPanelCountLabel(ArduinoDevices[GetDeviceTypeId].DevicePanel);
// Sender:=frmRoboLang.getPanelAddButton(ArduinoDevices[GetDeviceTypeId].DevicePanel);
btnC.Tag:= btnC.Tag-1;
btnC.Enabled:= btnC.tag<ArduinoDevices[GetDeviceTypeId].DeviceMax;
lblC.Caption:=inttostr( btnC.Tag);
if btnC.tag=0 then
frmRoboLang.CommandsByType(GetDeviceTypeId,False);
visible:=false;
try
Parent:=frmRoboLang;
except
end;
application.processmessages;
//tabpage must not be active or it crashes when you delete it BUG???
pi:=frmRoboLang.DevBook.PageIndex;
frmRoboLang.DevBook.PageIndex:=0;
application.processmessages;
frmRoboLang.DevBook.Pages.Delete(pi);
frmRoboLang.DevBook.PageIndex:=frmRoboLang.DevBook.Pages.Count-1;
DeleteActiveDevice(ActiveDeviceId);
RefreshBlockControls;
end;
Procedure TDefDevForm.RefreshBlockControls;
var
Msg: TMessage;
i:Integer;
begin
Msg.Msg := WM_REFRESH_MSG;
Msg.WParam := GetDeviceTypeId;
Msg.LParam := ActiveDeviceId;
Msg.Result := 0;
for i := 0 to frmRoboLang.ScrollBox1.ControlCount-1 do
try
frmRoboLang.ScrollBox1.Controls[i].Perform(msg.Msg,msg.WParam,msg.LParam)
Except
end;
// frmRoboLang.Broadcast(Msg);
End;
function TDefDevForm.LblC: TLabel;
begin
Result:=frmRoboLang.getPanelCountLabel(ArduinoDevices[GetDeviceTypeId].DevicePanel);
end;
procedure TDefDevForm.NewMaxPins;
begin
if assigned(param1SE) then
TSpinEdit(Param1Se).MaxValue:=Arduino.MaxPins;
if assigned(param2SE) then
TSpinEdit(Param2Se).MaxValue:=Arduino.MaxPins;
if assigned(param3SE) then
TSpinEdit(Param3Se).MaxValue:=Arduino.MaxPins;
if assigned(param4SE) then
TSpinEdit(Param4Se).MaxValue:=Arduino.MaxPins;
if assigned(param5SE) then
TSpinEdit(Param5Se).MaxValue:=Arduino.MaxPins;
if assigned(param6SE) then
TSpinEdit(Param6Se).MaxValue:=Arduino.MaxPins;
if assigned(param7SE) then
TSpinEdit(Param7Se).MaxValue:=Arduino.MaxPins;
end;
procedure TDefDevForm.SetParam(Pno: integer; SE: TSpinedit);
begin
ActDevs[ActiveDeviceId].ActDevParams[Pno-1]:=Se.Value;
RefreshBlockControls;
end;
procedure TDefDevForm.SetSEfromParam(Pno: integer; SE: TSpinedit);
Begin
if assigned(SE) then
Begin
Se.Value:=ActDevs[ActiveDeviceId].ActDevParams[Pno-1];
Se.EditorEnabled:=true;
End;
End;
end.