-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathMain.pas
1426 lines (1303 loc) · 43 KB
/
Main.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
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
unit Main;
interface
//** Converted with Mida BASIC 275 http://www.midaconverter.com
uses
System.SysUtils,
System.Types,
System.UITypes,
System.Classes,
System.Variants,
System.IniFiles,
Data.DB,
FMX.Types,
FMX.Controls,
FMX.Forms,
FMX.Dialogs,
FMX.Objects,
FMX.Menus,
FMX.Grid,
FMX.ExtCtrls,
FMX.ListBox,
FMX.TreeView,
FMX.Memo,
FMX.TabControl,
FMX.Layouts,
FMX.Edit,
FMX.Platform,
FMX.Bind.DBEngExt,
FMX.Bind.Editors,
FMX.Bind.DBLinks,
FMX.Bind.Navigator,
Data.Bind.EngExt,
Data.Bind.Components,
Data.Bind.DBScope,
Data.Bind.DBLinks,
Datasnap.DBClient,
Fmx.Bind.Grid,
System.Rtti,
System.Bindings.Outputs,
Data.Bind.Grid,
Fmx.StdCtrls,
FMX.Header,
FMX.Graphics,
FMX.DialogService,
Posix.Stdlib, Class_TrayItem,
Macapi.Foundation, Macapi.AppKit, Macapi.Helpers,
PublicVar, FMX.ListView.Types, FMX.ListView, Xml.XMLIntf, Xml.XMLDoc,
FMX.ScrollBox, FMX.Controls.Presentation;
//** Original VCL Uses section :
//** Winapi.Windows, Winapi.ShellAPI, Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
//** Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ComCtrls, Vcl.ExtCtrls,
//** Xml.XMLIntf, Xml.XMLDoc, Vcl.Menus, Vcl.Buttons, Vcl.ImgList, PublicVar;
type
TFMain = class(TForm)
Btn_AddNode: TButton;
Btn_DeleteNode: TButton;
Btn_StartAll: TButton;
Btn_StopAll: TButton;
StatusBar_Status: TStatusBar;
Panel_ClientNodeInfo: TPanel;
GroupBox_BascPara: TGroupBox;
Label_LocalPort: TLabel;
Label_KCPServerIP: TLabel;
Edit_LocalPort: TEdit;
Edit_KCPServerIP: TEdit;
Edit_KCPServerPort: TEdit;
Label_KCPServerPort: TLabel;
GroupBox_SelectPara: TGroupBox;
CheckBox_Key: TCheckBox;
Label_Key: TLabel;
Edit_Key: TEdit;
CheckBox_Crypt: TCheckBox;
Label_Crypt: TLabel;
ComboBox_Crypt: TComboBox;
CheckBox_Conn: TCheckBox;
Label_Conn: TLabel;
Edit_Conn: TEdit;
CheckBox_MTU: TCheckBox;
Label_MTU: TLabel;
Edit_MTU: TEdit;
CheckBox_SndWnd: TCheckBox;
Label_SndWnd: TLabel;
Edit_SndWnd: TEdit;
CheckBox_RcvWnd: TCheckBox;
Label_RcvWnd: TLabel;
Edit_RcvWnd: TEdit;
CheckBox_NoComp: TCheckBox;
CheckBox_DSCP: TCheckBox;
Label_DSCP: TLabel;
Edit_DSCP: TEdit;
CheckBox_DataShard: TCheckBox;
Label_DataShard: TLabel;
Edit_DataShard: TEdit;
CheckBox_ParityShard: TCheckBox;
Label_ParityShard: TLabel;
Edit_ParityShard: TEdit;
GroupBox_Mode: TGroupBox;
Memo_Log: TMemo;
CheckBox_NoDelay: TCheckBox;
CheckBox_Interval: TCheckBox;
Label_Interval: TLabel;
Edit_Interval: TEdit;
CheckBox_Resend: TCheckBox;
Label_Resend: TLabel;
Edit_Resend: TEdit;
CheckBox_NC: TCheckBox;
Label_NC: TLabel;
Edit_Remark: TEdit;
Label_Remark: TLabel;
Btn_Start: TButton;
Btn_Stop: TButton;
CheckBox_AutoStart: TCheckBox;
Label_ClientEXEDir: TLabel;
Edit_ClientEXEDir: TEdit;
Btn_FindClientEXE: TButton;
Memo_CMDLine: TMemo;
OpenDialog_ClientEXE: TOpenDialog;
CheckBox_Mode: TCheckBox;
Label_Mode: TLabel;
ComboBox_Mode: TComboBox;
Label_NoComp: TLabel;
Label_NoDelay: TLabel;
GroupBox_HiddenPara: TGroupBox;
CheckBox_ACKNoDelay: TCheckBox;
Label_ACKNoDelay: TLabel;
Label_SockBuf: TLabel;
CheckBox_SockBuf: TCheckBox;
Edit_SockBuf: TEdit;
CheckBox_KeepAlive: TCheckBox;
Label_KeepAlive: TLabel;
Edit_KeepAlive: TEdit;
CheckBox_Minimize: TCheckBox;
CheckBox_AutoExpire: TCheckBox;
Label_AutoExpire: TLabel;
Edit_AutoExpire: TEdit;
SpeedBtn_ClearLog: TSpeedButton;
SpeedBtn_CMDLine: TSpeedButton;
CheckBox_ConfigFileDir: TCheckBox;
PopupMenu_ClientNode: TPopupMenu;
Menu_Start: TMenuItem;
Menu_Stop: TMenuItem;
N4: TMenuItem;
Menu_Copy: TMenuItem;
N7: TMenuItem;
Menu_Delete: TMenuItem;
Edit_ConfigFileDir: TEdit;
Label_ConfigFileDir: TLabel;
Btn_FindConfigFileDir: TButton;
OpenDialog_JSON: TOpenDialog;
Menu_JSON: TMenuItem;
SaveDialog_JSON: TSaveDialog;
ListBox_Node: TListBox;
ListBoxGroupHeader1: TListBoxGroupHeader;
Label_KcpTun: TLabel;
Image_CMDLine: TImage;
Image_ClearLog: TImage;
Popup_Hint: TPopup;
CalloutPanel_Hint: TCalloutPanel;
Label_Hint: TLabel;
CheckBox_AllowOnlyLocal: TCheckBox;
Label_PID: TLabel;
procedure Btn_AddNodeClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Btn_FindClientEXEClick(Sender: TObject);
procedure ComboBox_CryptChange(Sender: TObject);
procedure ComboBox_ModeChange(Sender: TObject);
procedure Btn_StartClick(Sender: TObject);
procedure Btn_StopClick(Sender: TObject);
procedure Btn_DeleteNodeClick(Sender: TObject);
procedure TrayIcon_SysClick(Sender: TObject);
procedure Memo_CMDLineDblClick(Sender: TObject);
procedure Edit_LocalPortKeyPress(Sender: TObject; var Key: Char);
procedure Btn_StartAllClick(Sender: TObject);
procedure Btn_StopAllClick(Sender: TObject);
procedure SpeedBtn_CMDLineClick(Sender: TObject);
procedure SpeedBtn_ClearLogClick(Sender: TObject);
procedure Btn_FindConfigFileDirClick(Sender: TObject);
procedure Menu_StartClick(Sender: TObject);
procedure Menu_StopClick(Sender: TObject);
procedure Menu_DeleteClick(Sender: TObject);
procedure Menu_JSONClick(Sender: TObject);
procedure Menu_CopyClick(Sender: TObject);
procedure ListBox_NodeClick(Sender: TObject);
procedure Label_KcpTunClick(Sender: TObject);
procedure ListBox_NodeDblClick(Sender: TObject);
procedure Edit_RemarkChangeTracking(Sender: TObject);
procedure Edit_ClientEXEDirChangeTracking(Sender: TObject);
procedure Edit_ConfigFileDirChangeTracking(Sender: TObject);
procedure Edit_LocalPortChangeTracking(Sender: TObject);
procedure Edit_KCPServerIPChangeTracking(Sender: TObject);
procedure Edit_KCPServerPortChangeTracking(Sender: TObject);
procedure Edit_KeyChangeTracking(Sender: TObject);
procedure Edit_DataShardChangeTracking(Sender: TObject);
procedure Edit_ParityShardChangeTracking(Sender: TObject);
procedure Edit_ConnChangeTracking(Sender: TObject);
procedure Edit_MTUChangeTracking(Sender: TObject);
procedure Edit_SndWndChangeTracking(Sender: TObject);
procedure Edit_RcvWndChangeTracking(Sender: TObject);
procedure Edit_DSCPChangeTracking(Sender: TObject);
procedure Edit_AutoExpireChangeTracking(Sender: TObject);
procedure Edit_IntervalChangeTracking(Sender: TObject);
procedure Edit_ResendChangeTracking(Sender: TObject);
procedure Edit_KeepAliveChangeTracking(Sender: TObject);
procedure Edit_SockBufChangeTracking(Sender: TObject);
procedure CheckBox_KeyChange(Sender: TObject);
procedure CheckBox_CryptChange(Sender: TObject);
procedure CheckBox_NoCompChange(Sender: TObject);
procedure CheckBox_DataShardChange(Sender: TObject);
procedure CheckBox_ParityShardChange(Sender: TObject);
procedure CheckBox_ConnChange(Sender: TObject);
procedure CheckBox_MTUChange(Sender: TObject);
procedure CheckBox_SndWndChange(Sender: TObject);
procedure CheckBox_RcvWndChange(Sender: TObject);
procedure CheckBox_DSCPChange(Sender: TObject);
procedure CheckBox_AutoExpireChange(Sender: TObject);
procedure CheckBox_ModeChange(Sender: TObject);
procedure CheckBox_NoDelayChange(Sender: TObject);
procedure CheckBox_IntervalChange(Sender: TObject);
procedure CheckBox_ResendChange(Sender: TObject);
procedure CheckBox_NCChange(Sender: TObject);
procedure CheckBox_ACKNoDelayChange(Sender: TObject);
procedure CheckBox_KeepAliveChange(Sender: TObject);
procedure CheckBox_SockBufChange(Sender: TObject);
procedure CheckBox_ConfigFileDirChange(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure CheckBox_MinimizeChange(Sender: TObject);
procedure CheckBox_AutoStartChange(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Edit_KCPServerPortMouseEnter(Sender: TObject);
procedure Edit_KCPServerPortMouseLeave(Sender: TObject);
procedure CheckBox_AllowOnlyLocalChange(Sender: TObject);
private
{ Private declarations }
// procedure WMSYSCommand(var Msg: TWMSysCommand); message WM_SYSCOMMAND;
protected
// procedure WMDropFiles(var Msg: TMessage); message WM_DROPFILES;
// procedure WMDOSCommandStop(var Msg: TMessage); message WM_DOSCOMMANDSTOP;
public
{ Public declarations }
end;
var
FMain: TFMain;
TrayItem: TFMXTrayItem;
implementation
uses
Interface_op, Class_ClientNode, OneCopy, PublicFun, Photo;
{$R *.FMX}
{$R *.Macintosh.fmx MACOS}
{$R photo.RES}
//procedure TFMain.WMSYSCommand;
//begin
// if (Msg.CmdType = SC_MINIMIZE) or (Msg.CmdType = SC_CLOSE) then
// begin
// FMain.Visible:= False;
// end
// else
// DefaultHandler(Msg);
//
// if (Msg.CmdType = WM_PHOTO) then
// FPhoto.ShowModal;
//end;
//procedure TFMain.WMDropFiles(var Msg:TMessage);
//var
// i: Integer;
// Buffer: array[0..8190] of Char;
// FileFullName, LowerCaseFileName: string;
// FindFiles: Boolean;
//begin
// FindFiles:= False;
// i:= DragQueryFile(Msg.wParam, $FFFFFFFF, Buffer, 8190);
// for i:= 0 to (i - 1) do
// begin //处理选择多个文件
// DragQueryFile(Msg.wParam, i, Buffer, 8190);
// FileFullName:= Buffer;
// LowerCaseFileName:= LowerCase(ExtractFileName(FileFullName));
// if (LowerCaseFileName = 'client_windows_amd64.exe') or (LowerCaseFileName = 'client_windows_386.exe') then
// begin
// FindFiles:= True;
// Break;
// end;//if
// end;//for
// DragFinish(Msg.wParam);
// if FindFiles then
// begin
// PublicVar.ClientEXEDir:= FileFullName;
// Edit_ClientEXEDir.Text:= FileFullName;
// end;
//end;
//procedure TFMain.WMDOSCommandStop(var Msg: TMessage);
//var
// ClientNode: TClientNode;
//begin
// ClientNode:= TClientNode(Msg.LParam);
// ClientNode.StopCommand;
// if (ListView_Node.Selected <> nil) and (ListView_Node.Selected.Data = ClientNode) then
// begin
// Btn_Start.Enabled:= True;
// Btn_Stop.Enabled:= False;
// end;
// ListView_Node.Repaint;
//end;
procedure TFMain.Btn_AddNodeClick(Sender: TObject);
var
NewClientNode: TClientNode;
NodeItem: TListBoxItem;
NewXMLNode: IXMLNode;
begin
Btn_AddNode.Enabled:= False;
try
NewClientNode:= TClientNode.Create;
NewClientNode.XMLDocument_Para:= PublicVar.XMLDocument_Para;
NodeItem:= TListBoxItem.Create(ListBox_Node);
NodeItem.Parent:= ListBox_Node;
NodeItem.Text:= NewClientNode.KCPServerIP + ':' + NewClientNode.KCPServerPort + '——' + NewClientNode.LocalPort;
NodeItem.Data:= NewClientNode;
NewXMLNode:= PublicVar.ClientNodes.AddChild('node');
NewClientNode.XMLNode:= NewXMLNode;
NewClientNode.WriteToXMLNode(NewXMLNode);
PublicVar.XMLDocument_Para.SaveToFile();
finally
Btn_AddNode.Enabled:= True;
end;
end;
procedure TFMain.Btn_DeleteNodeClick(Sender: TObject);
var
ClientNode: TClientNode;
begin
TDialogService.MessageDialog('确定要删除所选中的节点吗?删除后无法恢复!', TMsgDlgType.mtInformation, [TMsgDlgBtn.mbYes, TMsgDlgBtn.mbNo], TMsgDlgBtn.mbNo, 0,
procedure(const aResult: TModalResult)
begin
if aResult = mrNo then
Exit
else
begin
ClientNode:= TClientNode(ListBox_Node.Selected.Data);
ClientNode.XMLNode.ParentNode.ChildNodes.Remove(ClientNode.XMLNode);
PublicVar.XMLDocument_Para.SaveToFile;
if ClientNode.isRunCMD <> 0 then
begin
ClientNode.CorrectQuit:= True;
ClientNode.StopCommand;
end;
ClientNode.Free;
ListBox_Node.Items.Delete(ListBox_Node.Selected.Index);
ListBox_NodeClick(Self);
end;
end
);
end;
procedure TFMain.Btn_FindClientEXEClick(Sender: TObject);
var
RelativePath: string;
begin
if not OpenDialog_ClientEXE.Execute then
Exit;
RelativePath:= ExtractRelativePath(ExtractFilePath(string(TNSBundle.Wrap(TNSBundle.OCClass.mainBundle).bundlePath.cString)), ExtractFilePath(OpenDialog_ClientEXE.FileName));
if (RelativePath = '') then
begin
PublicVar.ClientEXEDir:= './' + ExtractFileName(OpenDialog_ClientEXE.FileName);
Edit_ClientEXEDir.Text:= './' + ExtractFileName(OpenDialog_ClientEXE.FileName);
end
else
begin
PublicVar.ClientEXEDir:= OpenDialog_ClientEXE.FileName;
Edit_ClientEXEDir.Text:= OpenDialog_ClientEXE.FileName;
end;
end;
procedure TFMain.Btn_FindConfigFileDirClick(Sender: TObject);
var
RelativePath: string;
begin
if not OpenDialog_JSON.Execute then
Exit;
RelativePath:= ExtractRelativePath(ExtractFilePath(string(TNSBundle.Wrap(TNSBundle.OCClass.mainBundle).bundlePath.cString)), ExtractFilePath(OpenDialog_ClientEXE.FileName));
if (RelativePath = '') then
begin
Edit_ConfigFileDir.Text:= './' + ExtractFileName(OpenDialog_JSON.FileName);
end
else
begin
Edit_ConfigFileDir.Text:= OpenDialog_JSON.FileName;
end;
end;
procedure TFMain.Btn_StartAllClick(Sender: TObject);
var
i: Integer;
ClientNode: TClientNode;
CMDLineStr: string;
begin
for i := 0 to (ListBox_Node.Count - 1) do
begin
if (ListBox_Node.ListItems[i] is TListBoxGroupHeader) then
Continue;
ClientNode:= TClientNode(ListBox_Node.ListItems[i].Data);
if (ClientNode.isRunCMD = 0) then
begin
CMDLineStr:= ClientNode.CreateCMDLine(Edit_ClientEXEDir.Text);
ClientNode.RunCommand(CMDLineStr);
ClientNode.RunState:= '1';
end;
end;
ListBox_Node.Repaint;
ListBox_NodeClick(Self);
end;
procedure TFMain.Btn_StartClick(Sender: TObject);
var
CMDLineStr: string;
begin
CMDLineStr:= TClientNode(ListBox_Node.Selected.Data).CreateCMDLine(Edit_ClientEXEDir.Text);
Memo_CMDLine.Lines.Text:= CMDLineStr;
TClientNode(ListBox_Node.Selected.Data).RunCommand(CMDLineStr);
TClientNode(ListBox_Node.Selected.Data).RunState:= '1';
ListBox_Node.Repaint;
Btn_Start.Enabled:= False;
Btn_Stop.Enabled:= True;
end;
procedure TFMain.Btn_StopAllClick(Sender: TObject);
var
i: Integer;
ClientNode: TClientNode;
begin
for i := 0 to (ListBox_Node.Count - 1) do
begin
if (ListBox_Node.ListItems[i] is TListBoxGroupHeader) then
Continue;
ClientNode:= TClientNode(ListBox_Node.ListItems[i].Data);
if (ClientNode.isRunCMD = 1) then
begin
ClientNode.CorrectQuit:= True;
ClientNode.StopCommand;
ClientNode.RunState:= '0';
end;
end;
ListBox_Node.Repaint;
ListBox_NodeClick(Self);
end;
procedure TFMain.Btn_StopClick(Sender: TObject);
begin
TClientNode(ListBox_Node.Selected.Data).CorrectQuit:= True;
TClientNode(ListBox_Node.Selected.Data).StopCommand;
TClientNode(ListBox_Node.Selected.Data).RunState:= '0';
ListBox_Node.Repaint;
Btn_Start.Enabled:= True;
Btn_Stop.Enabled:= False;
end;
procedure TFMain.CheckBox_ACKNoDelayChange(Sender: TObject);
begin
Label_ACKNoDelay.Enabled:= CheckBox_ACKNoDelay.isChecked;
if ListBox_Node.Selected = nil then
Exit;
TClientNode(ListBox_Node.Selected.Data).isACKNoDelay:= Integer(CheckBox_ACKNoDelay.isChecked);
end;
procedure TFMain.CheckBox_AllowOnlyLocalChange(Sender: TObject);
begin
if ListBox_Node.Selected = nil then
Exit;
TClientNode(ListBox_Node.Selected.Data).AllowOnlyLocal:= Integer(CheckBox_AllowOnlyLocal.isChecked);
end;
procedure TFMain.CheckBox_AutoExpireChange(Sender: TObject);
begin
Label_AutoExpire.Enabled:= CheckBox_AutoExpire.isChecked;
Edit_AutoExpire.Enabled:= CheckBox_AutoExpire.isChecked;
if CheckBox_AutoExpire.isChecked then
begin
// Edit_AutoExpire.Color:= clWindow;
if PublicVar.CanFoucs then
Edit_AutoExpire.SetFocus;
end
else
begin
// Edit_AutoExpire.Color:= clBtnFace;
end;
if ListBox_Node.Selected = nil then
Exit;
TClientNode(ListBox_Node.Selected.Data).isAutoExpire:= Integer(CheckBox_AutoExpire.isChecked);
end;
procedure TFMain.CheckBox_AutoStartChange(Sender: TObject);
begin
// PublicVar.AutoStart:= Integer(CheckBox_AutoStart.isChecked);
// if not PublicVar.CanModifyXML then
// Exit;
// try
// WriteREGAutoRun(PublicVar.AutoStart, Application.ExeName);
// PublicVar.ProgramNode.ChildNodes['autostart'].NodeValue:= PublicVar.AutoStart;
// PublicVar.XMLDocument_Para.SaveToFile;
// except
// Application.MessageBox('试图操作注册表时出现错误,请以系统管理员身份运行后再次重试!', '提示', MB_OK);
// Exit;
// end;
end;
procedure TFMain.CheckBox_ConfigFileDirChange(Sender: TObject);
begin
Label_ConfigFileDir.Enabled:= CheckBox_ConfigFileDir.isChecked;
Edit_ConfigFileDir.Enabled:= CheckBox_ConfigFileDir.isChecked;
Btn_FindConfigFileDir.Enabled:= CheckBox_ConfigFileDir.isChecked;
if CheckBox_ConfigFileDir.isChecked then
begin
if PublicVar.CanFoucs then
Btn_FindConfigFileDir.SetFocus;
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
else
begin
Interface_op.Enable_DisableAllCheckbox(True);
Interface_op.Enable_DisableBasePara(True);
Interface_op.Enable_DisableSelectPara(True);
Interface_op.Enable_DisableModePara(True);
Interface_op.Enable_DisableHiddenPara(True);
end;
if ListBox_Node.Selected = nil then
Exit;
TClientNode(ListBox_Node.Selected.Data).isJson:= Integer(CheckBox_ConfigFileDir.isChecked);
end;
procedure TFMain.CheckBox_ConnChange(Sender: TObject);
begin
Label_Conn.Enabled:= CheckBox_Conn.isChecked;
Edit_Conn.Enabled:= CheckBox_Conn.isChecked;
if CheckBox_Conn.isChecked then
begin
// Edit_Conn.Color:= clWindow;
if PublicVar.CanFoucs then
Edit_Conn.SetFocus;
end
else
begin
// Edit_Conn.Color:= clBtnFace;
end;
if ListBox_Node.Selected = nil then
Exit;
TClientNode(ListBox_Node.Selected.Data).isConn:= Integer(CheckBox_Conn.isChecked);
end;
procedure TFMain.CheckBox_CryptChange(Sender: TObject);
begin
Label_Crypt.Enabled:= CheckBox_Crypt.isChecked;
ComboBox_Crypt.Enabled:= CheckBox_Crypt.isChecked;
if CheckBox_Crypt.isChecked then
begin
if PublicVar.CanFoucs then
ComboBox_Crypt.SetFocus;
end;
if ListBox_Node.Selected = nil then
Exit;
TClientNode(ListBox_Node.Selected.Data).isCrypt:= Integer(CheckBox_Crypt.isChecked);
end;
procedure TFMain.CheckBox_DataShardChange(Sender: TObject);
begin
Label_DataShard.Enabled:= CheckBox_DataShard.isChecked;
Edit_DataShard.Enabled:= CheckBox_DataShard.isChecked;
if CheckBox_DataShard.isChecked then
begin
// Edit_DataShard.Color:= clWindow;
if PublicVar.CanFoucs then
Edit_DataShard.SetFocus;
end
else
begin
// Edit_DataShard.Color:= clBtnFace;
end;
if ListBox_Node.Selected = nil then
Exit;
TClientNode(ListBox_Node.Selected.Data).isDataShard:= Integer(CheckBox_DataShard.isChecked);
end;
procedure TFMain.CheckBox_DSCPChange(Sender: TObject);
begin
Label_DSCP.Enabled:= CheckBox_DSCP.isChecked;
Edit_DSCP.Enabled:= CheckBox_DSCP.isChecked;
if CheckBox_DSCP.isChecked then
begin
// Edit_DSCP.Color:= clWindow;
if PublicVar.CanFoucs then
Edit_DSCP.SetFocus;
end
else
begin
// Edit_DSCP.Color:= clBtnFace;
end;
if ListBox_Node.Selected = nil then
Exit;
TClientNode(ListBox_Node.Selected.Data).isDSCP:= Integer(CheckBox_DSCP.isChecked);
end;
procedure TFMain.CheckBox_IntervalChange(Sender: TObject);
begin
if (CheckBox_Mode.isChecked) and (ComboBox_Mode.Selected <> nil) and (ComboBox_Mode.Selected.Text = 'manual') and (CheckBox_Interval.isChecked) then
begin
Label_Interval.Enabled:= True;
// Edit_Interval.Color:= clWindow;
Edit_Interval.Enabled:= True;
if PublicVar.CanFoucs and PublicVar.ModeCanFouse then
Edit_Interval.SetFocus;
end
else
begin
Label_Interval.Enabled:= False;
// Edit_Interval.Color:= clBtnFace;
Edit_Interval.Enabled:= False;
end;
if ListBox_Node.Selected = nil then
Exit;
TClientNode(ListBox_Node.Selected.Data).isInterval:= Integer(CheckBox_Interval.isChecked);
end;
procedure TFMain.CheckBox_KeepAliveChange(Sender: TObject);
begin
Label_KeepAlive.Enabled:= CheckBox_KeepAlive.isChecked;
Edit_KeepAlive.Enabled:= CheckBox_KeepAlive.isChecked;
if CheckBox_KeepAlive.isChecked then
begin
// Edit_KeepAlive.Color:= clWindow;
if PublicVar.CanFoucs then
Edit_KeepAlive.SetFocus;
end
else
begin
// Edit_KeepAlive.Color:= clBtnFace;
end;
if ListBox_Node.Selected = nil then
Exit;
TClientNode(ListBox_Node.Selected.Data).isKeepAlive:= Integer(CheckBox_KeepAlive.isChecked);
end;
procedure TFMain.CheckBox_KeyChange(Sender: TObject);
begin
Label_Key.Enabled:= CheckBox_Key.isChecked;
Edit_Key.Enabled:= CheckBox_Key.isChecked;
if CheckBox_Key.isChecked then
begin
// Edit_Key.Color:= clWindow;
if PublicVar.CanFoucs then
Edit_Key.SetFocus;
end
else
begin
// Edit_Key.Color:= clBtnFace;
end;
if ListBox_Node.Selected = nil then
Exit;
TClientNode(ListBox_Node.Selected.Data).isKey:= Integer(CheckBox_Key.isChecked);
end;
procedure TFMain.CheckBox_MinimizeChange(Sender: TObject);
begin
PublicVar.Minimize:= Integer(CheckBox_Minimize.isChecked);
if not PublicVar.CanModifyXML then
Exit;
PublicVar.ProgramNode.ChildNodes['minimize'].NodeValue:= PublicVar.Minimize;
PublicVar.XMLDocument_Para.SaveToFile;
end;
procedure TFMain.CheckBox_ModeChange(Sender: TObject);
begin
Label_Mode.Enabled:= CheckBox_Mode.isChecked;
ComboBox_Mode.Enabled:= CheckBox_Mode.isChecked;
if CheckBox_Mode.isChecked then
begin
if PublicVar.CanFoucs then
ComboBox_Mode.SetFocus;
end;
PublicVar.ModeCanFouse:= False;
if (ComboBox_Mode.Selected <> nil) and (ComboBox_Mode.Selected.Text = 'manual') and (CheckBox_Mode.isChecked) then
begin
Interface_op.Enable_DisableModePara(True);
end
else
begin
Interface_op.Enable_DisableModePara(False);
end;
PublicVar.ModeCanFouse:= True;
if ListBox_Node.Selected = nil then
Exit;
TClientNode(ListBox_Node.Selected.Data).isMode:= Integer(CheckBox_Mode.isChecked);
end;
procedure TFMain.CheckBox_MTUChange(Sender: TObject);
begin
Label_MTU.Enabled:= CheckBox_MTU.isChecked;
Edit_MTU.Enabled:= CheckBox_MTU.isChecked;
if CheckBox_MTU.isChecked then
begin
// Edit_MTU.Color:= clWindow;
if PublicVar.CanFoucs then
Edit_MTU.SetFocus;
end
else
begin
// Edit_MTU.Color:= clBtnFace;
end;
if ListBox_Node.Selected = nil then
Exit;
TClientNode(ListBox_Node.Selected.Data).isMTU:= Integer(CheckBox_MTU.isChecked);
end;
procedure TFMain.CheckBox_NCChange(Sender: TObject);
begin
if (CheckBox_Mode.isChecked) and (ComboBox_Mode.Selected <> nil) and (ComboBox_Mode.Selected.Text = 'manual') and (CheckBox_NC.isChecked) then
begin
Label_NC.Enabled:= True;
end
else
begin
Label_NC.Enabled:= False;
end;
if ListBox_Node.Selected = nil then
Exit;
TClientNode(ListBox_Node.Selected.Data).isNC:= Integer(CheckBox_NC.isChecked);
end;
procedure TFMain.CheckBox_NoCompChange(Sender: TObject);
begin
Label_NoComp.Enabled:= CheckBox_NoComp.isChecked;
if ListBox_Node.Selected = nil then
Exit;
TClientNode(ListBox_Node.Selected.Data).isNoComp:= Integer(CheckBox_NoComp.isChecked);
end;
procedure TFMain.CheckBox_NoDelayChange(Sender: TObject);
begin
if (CheckBox_Mode.isChecked) and (ComboBox_Mode.Selected <> nil) and (ComboBox_Mode.Selected.Text = 'manual') and (CheckBox_NoDelay.isChecked) then
begin
Label_NoDelay.Enabled:= True;
end
else
begin
Label_NoDelay.Enabled:= False;
end;
if ListBox_Node.Selected = nil then
Exit;
TClientNode(ListBox_Node.Selected.Data).isNoDelay:= Integer(CheckBox_NoDelay.isChecked);
end;
procedure TFMain.CheckBox_ParityShardChange(Sender: TObject);
begin
Label_ParityShard.Enabled:= CheckBox_ParityShard.isChecked;
Edit_ParityShard.Enabled:= CheckBox_ParityShard.isChecked;
if CheckBox_ParityShard.isChecked then
begin
// Edit_ParityShard.Color:= clWindow;
if PublicVar.CanFoucs then
Edit_ParityShard.SetFocus;
end
else
begin
// Edit_ParityShard.Color:= clBtnFace;
end;
if ListBox_Node.Selected = nil then
Exit;
TClientNode(ListBox_Node.Selected.Data).isParityShard:= Integer(CheckBox_ParityShard.isChecked);
end;
procedure TFMain.CheckBox_RcvWndChange(Sender: TObject);
begin
Label_RcvWnd.Enabled:= CheckBox_RcvWnd.isChecked;
Edit_RcvWnd.Enabled:= CheckBox_RcvWnd.isChecked;
if CheckBox_RcvWnd.isChecked then
begin
// Edit_RcvWnd.Color:= clWindow;
if PublicVar.CanFoucs then
Edit_RcvWnd.SetFocus;
end
else
begin
// Edit_RcvWnd.Color:= clBtnFace;
end;
if ListBox_Node.Selected = nil then
Exit;
TClientNode(ListBox_Node.Selected.Data).isRcvWnd:= Integer(CheckBox_RcvWnd.isChecked);
end;
procedure TFMain.CheckBox_ResendChange(Sender: TObject);
begin
if (CheckBox_Mode.isChecked) and (ComboBox_Mode.Selected <> nil) and (ComboBox_Mode.Selected.Text = 'manual') and (CheckBox_Resend.isChecked) then
begin
Label_Resend.Enabled:= True;
// Edit_Resend.Color:= clWindow;
Edit_Resend.Enabled:= True;
if PublicVar.CanFoucs and PublicVar.ModeCanFouse then
Edit_Resend.SetFocus;
end
else
begin
Label_Resend.Enabled:= False;
// Edit_Resend.Color:= clBtnFace;
Edit_Resend.Enabled:= False;
end;
if ListBox_Node.Selected = nil then
Exit;
TClientNode(ListBox_Node.Selected.Data).isResend:= Integer(CheckBox_Resend.isChecked);
end;
procedure TFMain.CheckBox_SndWndChange(Sender: TObject);
begin
Label_SndWnd.Enabled:= CheckBox_SndWnd.isChecked;
Edit_SndWnd.Enabled:= CheckBox_SndWnd.isChecked;
if CheckBox_SndWnd.isChecked then
begin
// Edit_SndWnd.Color:= clWindow;
if PublicVar.CanFoucs then
Edit_SndWnd.SetFocus;
end
else
begin
// Edit_SndWnd.Color:= clBtnFace;
end;
if ListBox_Node.Selected = nil then
Exit;
TClientNode(ListBox_Node.Selected.Data).isSndWnd:= Integer(CheckBox_SndWnd.isChecked);
end;
procedure TFMain.CheckBox_SockBufChange(Sender: TObject);
begin
Label_SockBuf.Enabled:= CheckBox_SockBuf.isChecked;
Edit_SockBuf.Enabled:= CheckBox_SockBuf.isChecked;
if CheckBox_SockBuf.isChecked then
begin
// Edit_SockBuf.Color:= clWindow;
if PublicVar.CanFoucs then
Edit_SockBuf.SetFocus;
end
else
begin
// Edit_SockBuf.Color:= clBtnFace;
end;
if ListBox_Node.Selected = nil then
Exit;
TClientNode(ListBox_Node.Selected.Data).isSockBuf:= Integer(CheckBox_SockBuf.isChecked);
end;
procedure TFMain.ComboBox_CryptChange(Sender: TObject);
begin
if ListBox_Node.Selected = nil then
Exit;
if ComboBox_Crypt.Selected = nil then
TClientNode(ListBox_Node.Selected.Data).Crypt:= ''
else
TClientNode(ListBox_Node.Selected.Data).Crypt:= ComboBox_Crypt.Selected.Text;
end;
procedure TFMain.ComboBox_ModeChange(Sender: TObject);
begin
if ListBox_Node.Selected = nil then
Exit;
if ComboBox_Mode.Selected = nil then
begin
TClientNode(ListBox_Node.Selected.Data).Mode:= '';
end
else
begin
TClientNode(ListBox_Node.Selected.Data).Mode:= ComboBox_Mode.Selected.Text;
if (ComboBox_Mode.Selected.Text = 'manual') then
begin
Enable_DisableModePara(True);
end
else
begin
Enable_DisableModePara(False);
end;
end;
end;
procedure TFMain.Edit_AutoExpireChangeTracking(Sender: TObject);
begin
if ListBox_Node.Selected = nil then
Exit;
TClientNode(ListBox_Node.Selected.Data).AutoExpire:= Edit_AutoExpire.Text;
end;
procedure TFMain.Edit_ClientEXEDirChangeTracking(Sender: TObject);
begin
if not PublicVar.CanModifyXML then
Exit;
PublicVar.ProgramNode.ChildNodes['clientexedir'].NodeValue:= Edit_ClientEXEDir.Text;
PublicVar.XMLDocument_Para.SaveToFile;
end;
procedure TFMain.Edit_ConfigFileDirChangeTracking(Sender: TObject);
begin
if ListBox_Node.Selected = nil then
Exit;
TClientNode(ListBox_Node.Selected.Data).Json:= Edit_ConfigFileDir.Text;
end;
procedure TFMain.Edit_ConnChangeTracking(Sender: TObject);
begin
if ListBox_Node.Selected = nil then
Exit;
TClientNode(ListBox_Node.Selected.Data).Conn:= Edit_Conn.Text;
end;
procedure TFMain.Edit_DataShardChangeTracking(Sender: TObject);
begin
if ListBox_Node.Selected = nil then
Exit;
TClientNode(ListBox_Node.Selected.Data).DataShard:= Edit_DataShard.Text;
end;
procedure TFMain.Edit_DSCPChangeTracking(Sender: TObject);
begin
if ListBox_Node.Selected = nil then
Exit;
TClientNode(ListBox_Node.Selected.Data).DSCP:= Edit_DSCP.Text;
end;
procedure TFMain.Edit_IntervalChangeTracking(Sender: TObject);
begin
if ListBox_Node.Selected = nil then
Exit;
TClientNode(ListBox_Node.Selected.Data).Interval:= Edit_Interval.Text;
end;
procedure TFMain.Edit_KCPServerIPChangeTracking(Sender: TObject);
var
ClientNode: TClientNode;
ShowCaption: string;
begin
if ListBox_Node.Selected = nil then
Exit;
ClientNode:= TClientNode(ListBox_Node.Selected.Data);
ClientNode.KCPServerIP:= Edit_KCPServerIP.Text;
ShowCaption:= ClientNode.KCPServerIP + ':' + ClientNode.KCPServerPort + '——' + ClientNode.LocalPort;
if (ClientNode.Remark.Trim <> '') then
ShowCaption:= ClientNode.Remark.Trim + '(' + ShowCaption + ')';
ListBox_Node.Selected.Text:= ShowCaption;
end;
procedure TFMain.Edit_KCPServerPortChangeTracking(Sender: TObject);
var
ClientNode: TClientNode;
ShowCaption: string;
begin
if ListBox_Node.Selected = nil then
Exit;
ClientNode:= TClientNode(ListBox_Node.Selected.Data);
ClientNode.KCPServerPort:= Edit_KCPServerPort.Text;
ShowCaption:= ClientNode.KCPServerIP + ':' + ClientNode.KCPServerPort + '——' + ClientNode.LocalPort;
if (ClientNode.Remark.Trim <> '') then
ShowCaption:= ClientNode.Remark.Trim + '(' + ShowCaption + ')';
ListBox_Node.Selected.Text:= ShowCaption;
end;
procedure TFMain.Edit_KCPServerPortMouseEnter(Sender: TObject);
begin
Popup_Hint.IsOpen:= True;
end;
procedure TFMain.Edit_KCPServerPortMouseLeave(Sender: TObject);
begin
Popup_Hint.IsOpen:= False;
end;
procedure TFMain.Edit_KeepAliveChangeTracking(Sender: TObject);
begin
if ListBox_Node.Selected = nil then