-
Notifications
You must be signed in to change notification settings - Fork 180
/
Interface_op.pas
352 lines (290 loc) · 13.7 KB
/
Interface_op.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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
unit Interface_op;
interface
uses
System.SysUtils, System.Variants, Vcl.Forms, Vcl.Graphics, System.TypInfo,
Class_ClientNode;
function GetPublicVarFromXML(ParaXMLPathName: string): Integer;
procedure Enable_DisableAllCheckbox(State: Boolean);
procedure Enable_DisableBasePara(State: Boolean);
procedure Enable_DisableSelectPara(State: Boolean);
procedure Enable_DisableModePara(State: Boolean);
procedure Enable_DisableHiddenPara(State: Boolean);
procedure DisableAllInterfaceExceptJSON;
procedure DisableAllInterface;
procedure ShowClientInfoToInterface(ClientNode: TClientNode);
procedure WriteHint_ModeDefault;
implementation
uses
PublicVar, Main;
function GetPublicVarFromXML(ParaXMLPathName: string): Integer;
begin
Result:= 0;
PublicVar.CanModifyXML:= False;
try
PublicVar.XMLDocument_Para.LoadFromFile(ParaXMLPathName);
PublicVar.XMLDocument_Para.Active:= True;
PublicVar.MainNode:= XMLDocument_Para.DocumentElement;
PublicVar.ProgramNode:= MainNode.ChildNodes.FindNode('programpara');
PublicVar.ClientNodes:= MainNode.ChildNodes.FindNode('clientnodes');
PublicVar.AutoStart:= StrToInt(ProgramNode.ChildNodes.FindNode('autostart').NodeValue);
FMain.CheckBox_AutoStart.Checked:= Boolean(PublicVar.AutoStart);
PublicVar.Minimize:= StrToInt(ProgramNode.ChildNodes.FindNode('minimize').NodeValue);
FMain.CheckBox_Minimize.Checked:= Boolean(PublicVar.Minimize);
PublicVar.ClientEXEDir:= VarToStr(ProgramNode.ChildNodes.FindNode('clientexedir').NodeValue);
FMain.Edit_ClientEXEDir.Text:= PublicVar.ClientEXEDir;
PublicVar.AutoConn:= StrToInt(ProgramNode.ChildNodes.FindNode('autoconn').Attributes['enable']);
PublicVar.AutoConnTime:= StrToInt(ProgramNode.ChildNodes.FindNode('autoconn').NodeValue);
FMain.SpinEdit_AutoConnTime.Value:= PublicVar.AutoConnTime;
FMain.CheckBox_AutoConn.Checked:= Boolean(PublicVar.AutoConn);
FMain.CheckBox_AutoConnClick(FMain);
except
Result:= 1;
end;
PublicVar.CanModifyXML:= True;
end;
procedure Enable_DisableAllCheckbox(State: Boolean);
begin
with FMain do
begin
CheckBox_Key.Enabled:= State;
CheckBox_Crypt.Enabled:= State;
CheckBox_NoComp.Enabled:= State;
CheckBox_DataShard.Enabled:= State;
CheckBox_ParityShard.Enabled:= State;
CheckBox_Conn.Enabled:= State;
CheckBox_MTU.Enabled:= State;
CheckBox_SndWnd.Enabled:= State;
CheckBox_RcvWnd.Enabled:= State;
CheckBox_DSCP.Enabled:= State;
CheckBox_AutoExpire.Enabled:= State;
CheckBox_ScavengeTTL.Enabled:= State;
CheckBox_Quiet.Enabled:= State;
CheckBox_Mode.Enabled:= State;
CheckBox_NoDelay.Enabled:= State;
CheckBox_Interval.Enabled:= State;
CheckBox_Resend.Enabled:= State;
CheckBox_NC.Enabled:= State;
CheckBox_ACKNoDelay.Enabled:= State;
CheckBox_KeepAlive.Enabled:= State;
CheckBox_SockBuf.Enabled:= State;
end;
end;
//界面上禁用或启用基础参数
procedure Enable_DisableBasePara(State: Boolean);
begin
with FMain do
begin
if State then
begin
Edit_LocalPort.Color:= clWindow;
Edit_KCPServerIP.Color:= clWindow;
Edit_KCPServerPort.Color:= clWindow;
end
else
begin
Edit_LocalPort.Color:= clBtnFace;
Edit_KCPServerIP.Color:= clBtnFace;
Edit_KCPServerPort.Color:= clBtnFace;
end;
Label_LocalPort.Enabled:= State; Edit_LocalPort.Enabled:= State; CheckBox_AllowOnlyLocal.Enabled:= State;
Label_KCPServerIP.Enabled:= State; Edit_KCPServerIP.Enabled:= State;
Label_KCPServerPort.Enabled:= State; Edit_KCPServerPort.Enabled:= State;
end;
end;
//界面上禁用或启用可选参数
procedure Enable_DisableSelectPara(State: Boolean);
begin
with FMain do
begin
CheckBox_Key.Enabled:= State; CheckBox_KeyClick(FMain);
CheckBox_Crypt.Enabled:= State; CheckBox_CryptClick(FMain);
CheckBox_NoComp.Enabled:= State; CheckBox_NoCompClick(FMain);
CheckBox_DataShard.Enabled:= State; CheckBox_DataShardClick(FMain);
CheckBox_ParityShard.Enabled:= State; CheckBox_ParityShardClick(FMain);
CheckBox_Conn.Enabled:= State; CheckBox_ConnClick(FMain);
CheckBox_MTU.Enabled:= State; CheckBox_MTUClick(FMain);
CheckBox_SndWnd.Enabled:= State; CheckBox_SndWndClick(FMain);
CheckBox_RcvWnd.Enabled:= State; CheckBox_RcvWndClick(FMain);
CheckBox_DSCP.Enabled:= State; CheckBox_DSCPClick(FMain);
CheckBox_AutoExpire.Enabled:= State; CheckBox_AutoExpireClick(FMain);
CheckBox_ScavengeTTL.Enabled:= State; CheckBox_ScavengeTTLClick(FMain);
CheckBox_Quiet.Enabled:= State; CheckBox_QuietClick(FMain);
end;
end;
//界面上禁用或启用模式参数
procedure Enable_DisableModePara(State: Boolean);
begin
with FMain do
begin
CheckBox_NoDelay.Enabled:= State; CheckBox_NoDelayClick(FMain);
CheckBox_Interval.Enabled:= State; CheckBox_IntervalClick(FMain);
CheckBox_Resend.Enabled:= State; CheckBox_ResendClick(FMain);
CheckBox_NC.Enabled:= State; CheckBox_NCClick(FMain);
end;
end;
//界面上禁用或启用隐藏参数
procedure Enable_DisableHiddenPara(State: Boolean);
begin
with FMain do
begin
CheckBox_ACKNoDelay.Enabled:= State; CheckBox_ACKNoDelayClick(FMain);
CheckBox_KeepAlive.Enabled:= State; CheckBox_KeepAliveClick(FMain);
CheckBox_SockBuf.Enabled:= State; CheckBox_SockBufClick(FMain);
end;
end;
procedure DisableAllInterfaceExceptJSON;
begin
with FMain do
begin
Label_Key.Enabled:= False; Edit_Key.Enabled:= False; Edit_Key.Color:= clBtnFace;
Label_Crypt.Enabled:= False; ComboBox_Crypt.Enabled:= False;
Label_NoComp.Enabled:= False;
Label_DataShard.Enabled:= False; Edit_DataShard.Enabled:= False; Edit_DataShard.Color:= clBtnFace;
Label_ParityShard.Enabled:= False; Edit_ParityShard.Enabled:= False; Edit_ParityShard.Color:= clBtnFace;
Label_Conn.Enabled:= False; Edit_Conn.Enabled:= False; Edit_Conn.Color:= clBtnFace;
Label_MTU.Enabled:= False; Edit_MTU.Enabled:= False; Edit_MTU.Color:= clBtnFace;
Label_SndWnd.Enabled:= False; Edit_SndWnd.Enabled:= False; Edit_SndWnd.Color:= clBtnFace;
Label_RcvWnd.Enabled:= False; Edit_RcvWnd.Enabled:= False; Edit_RcvWnd.Color:= clBtnFace;
Label_DSCP.Enabled:= False; Edit_DSCP.Enabled:= False; Edit_DSCP.Color:= clBtnFace;
Label_AutoExpire.Enabled:= False; Edit_AutoExpire.Enabled:= False; Edit_AutoExpire.Color:= clBtnFace;
Label_ScavengeTTL.Enabled:= False; Edit_ScavengeTTL.Enabled:= False; Edit_ScavengeTTL.Color:= clBtnFace;
Label_Quiet.Enabled:= False;
Label_Mode.Enabled:= False; ComboBox_Mode.Enabled:= False;
Label_NoDelay.Enabled:= False;
Label_Interval.Enabled:= False; Edit_Interval.Enabled:= False; Edit_Interval.Color:= clBtnFace;
Label_Resend.Enabled:= False; Edit_Resend.Enabled:= False; Edit_Resend.Color:= clBtnFace;
Label_NC.Enabled:= False;
Label_ACKNoDelay.Enabled:= False;
Label_KeepAlive.Enabled:= False; Edit_KeepAlive.Enabled:= False; Edit_KeepAlive.Color:= clBtnFace;
Label_SockBuf.Enabled:= False; Edit_SockBuf.Enabled:= False; Edit_SockBuf.Color:= clBtnFace;
end;
end;
procedure DisableAllInterface;
begin
with FMain do
begin
Btn_DeleteNode.Enabled:= False;
CheckBox_ConfigFileDir.Enabled:= False;
Label_ConfigFileDir.Enabled:= False;
Edit_ConfigFileDir.Enabled:= False;
Btn_FindConfigFileDir.Enabled:= False;
Label_Remark.Enabled:= False;
Edit_Remark.Enabled:= False;
Edit_Remark.Color:= clBtnFace;
SpeedBtn_CMDLine.Enabled:= False;
SpeedBtn_ClearLog.Enabled:= False;
Btn_Start.Enabled:= False;
Btn_Stop.Enabled:= False;
Interface_op.Enable_DisableAllCheckbox(False);
Interface_op.Enable_DisableBasePara(False);
DisableAllInterfaceExceptJSON;
// Interface_op.Enable_DisableSelectPara(False);
// Interface_op.Enable_DisableModePara(False);
// Interface_op.Enable_DisableHiddenPara(False);
end;
end;
procedure ShowClientInfoToInterface(ClientNode: TClientNode);
begin
with FMain do
begin
Edit_LocalPort.Text:= ClientNode.LocalPort;
CheckBox_AllowOnlyLocal.Checked:= Boolean(ClientNode.AllowOnlyLocal);
Edit_KCPServerIP.Text:= ClientNode.KCPServerIP;
Edit_KCPServerPort.Text:= ClientNode.KCPServerPort;
CheckBox_Key.Checked:= Boolean(ClientNode.isKey);
Edit_Key.Text:= ClientNode.Key;
CheckBox_Key.OnClick(FMain);
CheckBox_Crypt.Checked:= Boolean(ClientNode.isCrypt);
ComboBox_Crypt.ItemIndex:= ComboBox_Crypt.Items.IndexOf(ClientNode.Crypt);
CheckBox_Crypt.OnClick(FMain);
CheckBox_NoComp.Checked:= Boolean(ClientNode.isNoComp);
CheckBox_NoComp.OnClick(FMain);
CheckBox_DataShard.Checked:= Boolean(ClientNode.isDataShard);
Edit_DataShard.Text:= ClientNode.DataShard;
CheckBox_DataShard.OnClick(FMain);
CheckBox_ParityShard.Checked:= Boolean(ClientNode.isParityShard);
Edit_ParityShard.Text:= ClientNode.ParityShard;
CheckBox_ParityShard.OnClick(FMain);
CheckBox_Conn.Checked:= Boolean(ClientNode.isConn);
Edit_Conn.Text:= ClientNode.Conn;
CheckBox_Conn.OnClick(FMain);
CheckBox_MTU.Checked:= Boolean(ClientNode.isMTU);
Edit_MTU.Text:= ClientNode.MTU;
CheckBox_MTU.OnClick(FMain);
CheckBox_SndWnd.Checked:= Boolean(ClientNode.isSndWnd);
Edit_SndWnd.Text:= ClientNode.SndWnd;
CheckBox_SndWnd.OnClick(FMain);
CheckBox_RcvWnd.Checked:= Boolean(ClientNode.isRcvWnd);
Edit_RcvWnd.Text:= ClientNode.RcvWnd;
CheckBox_RcvWnd.OnClick(FMain);
CheckBox_DSCP.Checked:= Boolean(ClientNode.isDSCP);
Edit_DSCP.Text:= ClientNode.DSCP;
CheckBox_DSCP.OnClick(FMain);
CheckBox_AutoExpire.Checked:= Boolean(ClientNode.isAutoExpire);
Edit_AutoExpire.Text:= ClientNode.AutoExpire;
CheckBox_AutoExpire.OnClick(FMain);
CheckBox_ScavengeTTL.Checked:= Boolean(ClientNode.isScavengeTTL);
Edit_ScavengeTTL.Text:= ClientNode.ScavengeTTL;
CheckBox_ScavengeTTL.OnClick(FMain);
CheckBox_Quiet.Checked:= Boolean(ClientNode.isQuiet);
CheckBox_Quiet.OnClick(FMain);
//-------------------------------------------------------------------------------------
ComboBox_Mode.ItemIndex:= ComboBox_Mode.Items.IndexOf(ClientNode.Mode);
CheckBox_NoDelay.Checked:= Boolean(ClientNode.isNoDelay);
CheckBox_NoDelay.OnClick(FMain);
CheckBox_Interval.Checked:= Boolean(ClientNode.isInterval);
Edit_Interval.Text:= ClientNode.Interval;
CheckBox_Interval.OnClick(FMain);
CheckBox_Resend.Checked:= Boolean(ClientNode.isResend);
Edit_Resend.Text:= ClientNode.Resend;
CheckBox_Resend.OnClick(FMain);
CheckBox_NC.Checked:= Boolean(ClientNode.isNC);
CheckBox_NC.OnClick(FMain);
CheckBox_Mode.Checked:= Boolean(ClientNode.isMode);
CheckBox_Mode.OnClick(FMain);
//-------------------------------------------------------------------------------------
CheckBox_ACKNoDelay.Checked:= Boolean(ClientNode.isACKNoDelay);
CheckBox_ACKNoDelay.OnClick(FMain);
CheckBox_KeepAlive.Checked:= Boolean(ClientNode.isKeepAlive);
Edit_KeepAlive.Text:= ClientNode.KeepAlive;
CheckBox_KeepAlive.OnClick(FMain);
CheckBox_SockBuf.Checked:= Boolean(ClientNode.isSockBuf);
Edit_SockBuf.Text:= ClientNode.SockBuf;
CheckBox_SockBuf.OnClick(FMain);
Edit_Remark.Text:= ClientNode.Remark;
Btn_Start.Enabled:= not Boolean(ClientNode.isRunCMD);
Btn_Stop.Enabled:= Boolean(ClientNode.isRunCMD);
CheckBox_ConfigFileDir.Checked:= Boolean(ClientNode.isJson);
Edit_ConfigFileDir.Text:= ClientNode.Json;
CheckBox_ConfigFileDir.OnClick(FMain);
end;
end;
procedure WriteHint_ModeDefault;
var
NoDelayStr, IntervalStr, ResendStr, NCStr: string;
begin
with FMain do
begin
// NoDelayStr:= '默认值:' + #13 + #10 + 'fast3:开启' + #13 + #10 + 'fast2:开启' + #13 + #10 +
// 'fast:不开启' + #13 + #10 + 'normal:不开启' + #13 + #10 + 'manual:不开启';
// IntervalStr:= '默认值:' + #13 + #10 + 'fast3:10' + #13 + #10 + 'fast2:20' + #13 + #10 +
// 'fast:20' + #13 + #10 + 'normal:30' + #13 + #10 + 'manual:40';
// ResendStr:= '默认值:' + #13 + #10 + 'fast3:2' + #13 + #10 + 'fast2:2' + #13 + #10 +
// 'fast:2' + #13 + #10 + 'normal:2' + #13 + #10 + 'manual:0';
// NCStr:= '默认值:' + #13 + #10 + 'fast3:开启' + #13 + #10 + 'fast2:开启' + #13 + #10 +
// 'fast:开启' + #13 + #10 + 'normal:开启' + #13 + #10 + 'manual:不开启';
NoDelayStr:= '默认值:' + #13 + #10 + 'fast3:开启' + #13 + #10 + 'fast2:开启' + #13 + #10 +
'fast:不开启' + #13 + #10 + 'normal:不开启';
IntervalStr:= '默认值:' + #13 + #10 + 'fast3:20' + #13 + #10 + 'fast2:30' + #13 + #10 +
'fast:40' + #13 + #10 + 'normal:50';
ResendStr:= '默认值:' + #13 + #10 + 'fast3:2' + #13 + #10 + 'fast2:2' + #13 + #10 +
'fast:2' + #13 + #10 + 'normal:2';
NCStr:= '默认值:' + #13 + #10 + 'fast3:开启' + #13 + #10 + 'fast2:开启' + #13 + #10 +
'fast:开启' + #13 + #10 + 'normal:开启';
CheckBox_NoDelay.Hint:= NoDelayStr; Label_NoDelay.Hint:= NoDelayStr;
CheckBox_Interval.Hint:= IntervalStr; Label_Interval.Hint:= IntervalStr; Edit_Interval.Hint:= IntervalStr;
CheckBox_Resend.Hint:= ResendStr; Label_Resend.Hint:= ResendStr; Edit_Resend.Hint:= ResendStr;
CheckBox_NC.Hint:= NCStr; Label_NC.Hint:= NCStr;
end;
end;
end.