forked from dfdragon/kcptun_gclient
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.pas
1737 lines (1563 loc) · 51.8 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
uses
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, System.JSON, System.IOUtils, PublicVar,
Vcl.Samples.Spin, System.ImageList, Class_ClientNode;
type
TFMain = class(TForm)
ListView_Node: TListView;
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;
PopupMenu_Tray: TPopupMenu;
Menu_Show: TMenuItem;
N2: TMenuItem;
Menu_StartAll: TMenuItem;
Menu_StopAll: TMenuItem;
N5: TMenuItem;
Menu_Exit: TMenuItem;
TrayIcon_Sys: TTrayIcon;
CheckBox_Minimize: TCheckBox;
CheckBox_AutoExpire: TCheckBox;
Label_AutoExpire: TLabel;
Edit_AutoExpire: TEdit;
SpeedBtn_ClearLog: TSpeedButton;
SpeedBtn_CMDLine: TSpeedButton;
ImageList_Menu: TImageList;
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_ExportToJSON: TMenuItem;
SaveDialog_JSON: TSaveDialog;
Menu_ImportFromJSON: TMenuItem;
CheckBox_AutoConn: TCheckBox;
Label_AutoConnUnit: TLabel;
SpinEdit_AutoConnTime: TSpinEdit;
CheckBox_AllowOnlyLocal: TCheckBox;
Panel_QRCode: TPanel;
Image_QRCode: TImage;
CheckBox_ScavengeTTL: TCheckBox;
Label_ScavengeTTL: TLabel;
Edit_ScavengeTTL: TEdit;
CheckBox_Quiet: TCheckBox;
Label_Quiet: TLabel;
procedure Btn_AddNodeClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Btn_FindClientEXEClick(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure ListView_NodeClick(Sender: TObject);
procedure CheckBox_KeyClick(Sender: TObject);
procedure CheckBox_CryptClick(Sender: TObject);
procedure CheckBox_ModeClick(Sender: TObject);
procedure Edit_LocalPortChange(Sender: TObject);
procedure Edit_KeyChange(Sender: TObject);
procedure ListView_NodeKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure Edit_RemarkChange(Sender: TObject);
procedure Edit_KCPServerIPChange(Sender: TObject);
procedure Edit_KCPServerPortChange(Sender: TObject);
procedure CheckBox_AutoStartClick(Sender: TObject);
procedure ComboBox_CryptChange(Sender: TObject);
procedure CheckBox_NoCompClick(Sender: TObject);
procedure CheckBox_DataShardClick(Sender: TObject);
procedure Edit_DataShardChange(Sender: TObject);
procedure CheckBox_ParityShardClick(Sender: TObject);
procedure Edit_ParityShardChange(Sender: TObject);
procedure CheckBox_ConnClick(Sender: TObject);
procedure Edit_ConnChange(Sender: TObject);
procedure CheckBox_MTUClick(Sender: TObject);
procedure Edit_MTUChange(Sender: TObject);
procedure CheckBox_SndWndClick(Sender: TObject);
procedure Edit_SndWndChange(Sender: TObject);
procedure CheckBox_RcvWndClick(Sender: TObject);
procedure Edit_RcvWndChange(Sender: TObject);
procedure CheckBox_DSCPClick(Sender: TObject);
procedure Edit_DSCPChange(Sender: TObject);
procedure ComboBox_ModeChange(Sender: TObject);
procedure CheckBox_NoDelayClick(Sender: TObject);
procedure CheckBox_IntervalClick(Sender: TObject);
procedure Edit_IntervalChange(Sender: TObject);
procedure CheckBox_ResendClick(Sender: TObject);
procedure Edit_ResendChange(Sender: TObject);
procedure CheckBox_ACKNoDelayClick(Sender: TObject);
procedure CheckBox_KeepAliveClick(Sender: TObject);
procedure Edit_KeepAliveChange(Sender: TObject);
procedure CheckBox_SockBufClick(Sender: TObject);
procedure Edit_SockBufChange(Sender: TObject);
procedure CheckBox_NCClick(Sender: TObject);
procedure Btn_StartClick(Sender: TObject);
procedure Btn_StopClick(Sender: TObject);
procedure Btn_DeleteNodeClick(Sender: TObject);
procedure Menu_ShowClick(Sender: TObject);
procedure Menu_ExitClick(Sender: TObject);
procedure TrayIcon_SysClick(Sender: TObject);
procedure Edit_ClientEXEDirChange(Sender: TObject);
procedure Memo_CMDLineDblClick(Sender: TObject);
procedure CheckBox_MinimizeClick(Sender: TObject);
procedure CheckBox_AutoExpireClick(Sender: TObject);
procedure Edit_AutoExpireChange(Sender: TObject);
procedure Edit_LocalPortKeyPress(Sender: TObject; var Key: Char);
procedure ListView_NodeCustomDrawItem(Sender: TCustomListView;
Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
procedure Btn_StartAllClick(Sender: TObject);
procedure Btn_StopAllClick(Sender: TObject);
procedure Menu_StartAllClick(Sender: TObject);
procedure Menu_StopAllClick(Sender: TObject);
procedure SpeedBtn_CMDLineClick(Sender: TObject);
procedure SpeedBtn_ClearLogClick(Sender: TObject);
procedure CheckBox_ConfigFileDirClick(Sender: TObject);
procedure Edit_ConfigFileDirChange(Sender: TObject);
procedure StatusBar_StatusMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure Btn_FindConfigFileDirClick(Sender: TObject);
procedure ListView_NodeMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure Menu_StartClick(Sender: TObject);
procedure Menu_StopClick(Sender: TObject);
procedure Menu_DeleteClick(Sender: TObject);
procedure Menu_ExportToJSONClick(Sender: TObject);
procedure Menu_CopyClick(Sender: TObject);
procedure Menu_ImportFromJSONClick(Sender: TObject);
procedure CheckBox_AutoConnClick(Sender: TObject);
procedure SpinEdit_AutoConnTimeChange(Sender: TObject);
procedure CheckBox_AllowOnlyLocalClick(Sender: TObject);
procedure Edit_ScavengeTTLKeyPress(Sender: TObject; var Key: Char);
procedure CheckBox_ScavengeTTLClick(Sender: TObject);
procedure Edit_ScavengeTTLChange(Sender: TObject);
procedure StatusBar_StatusMouseLeave(Sender: TObject);
procedure StatusBar_StatusMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure CheckBox_QuietClick(Sender: TObject);
private
{ Private declarations }
function CreateQRCodeBitmap(QRData: string): TMemoryStream;
procedure LoadQRCodeImage(ClientNode: TClientNode);
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;
implementation
uses
Interface_op, OneCopy, PublicFun, Photo, DelphiZXIngQRCode;
{$R *.dfm}
{$R res\photo.RES}
function TFMain.CreateQRCodeBitmap(QRData: string): TMemoryStream;
var
QRCode: TDelphiZXingQRCode;
QRCodeBitmap: TBitmap;
Row, Column: Integer;
begin
if (QRData = '') then
begin
Result:= nil;
Exit;
end;
Result:= TMemoryStream.Create;
QRCode:= TDelphiZXingQRCode.Create;
try
QRCode.Data:= QRData;
QRCode.Encoding:= qrISO88591;
QRCode.QuietZone:= 2;
QRCodeBitmap:= TBitmap.Create;
try
QRCodeBitmap.SetSize(QRCode.Rows, QRCode.Columns);
for Row := 0 to QRCode.Rows - 1 do
begin
for Column := 0 to QRCode.Columns - 1 do
begin
if (QRCode.IsBlack[Row, Column]) then
begin
QRCodeBitmap.Canvas.Pixels[Column, Row]:= clBlack;
end
else
begin
QRCodeBitmap.Canvas.Pixels[Column, Row]:= clWhite;
end;
end;
end;
QRCodeBitmap.SaveToStream(Result);
Result.Position:= 0;
finally
QRCodeBitmap.Free;
end;
finally
QRCode.Free;
end;
end;
procedure TFMain.LoadQRCodeImage(ClientNode: TClientNode);
var
QRCodeStream: TMemoryStream;
begin
QRCodeStream:= CreateQRCodeBitmap(ClientNode.CreateQRCodeData);
try
if QRCodeStream = nil then
Image_QRCode.Picture:= nil
else
Image_QRCode.Picture.Bitmap.LoadFromStream(QRCodeStream);
finally
QRCodeStream.Free;
end;
end;
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
DragFileNum, i: Integer;
Buffer: array[0..8190] of Char;
FileFullName, LowerCaseFileName, RelativePath: string;
FindFiles: Boolean;
begin
FindFiles:= False;
DragFileNum:= DragQueryFile(Msg.wParam, $FFFFFFFF, Buffer, 8190);
for i:= 0 to (DragFileNum - 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
RelativePath:= ExtractRelativePath(ExtractFilePath(Application.ExeName), ExtractFilePath(FileFullName));
if (RelativePath = '') then
begin
PublicVar.ClientEXEDir:= ExtractFileName(FileFullName);
Edit_ClientEXEDir.Text:= ExtractFileName(FileFullName);
end
else
begin
PublicVar.ClientEXEDir:= FileFullName;
Edit_ClientEXEDir.Text:= FileFullName;
end;
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: TListItem;
NewXMLNode: IXMLNode;
begin
Btn_AddNode.Enabled:= False;
try
NewClientNode:= TClientNode.Create;
NewClientNode.XMLDocument_Para:= PublicVar.XMLDocument_Para;
NodeItem:= ListView_Node.Items.Add;
NodeItem.Caption:= 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
if Application.MessageBox('确定要删除所选中的节点吗?删除后无法恢复!', '提示', MB_YESNO) = MrNo then
Exit;
ClientNode:= TClientNode(ListView_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;
ListView_Node.Selected.Delete;
ListView_NodeClick(Self);
end;
procedure TFMain.Btn_FindClientEXEClick(Sender: TObject);
var
RelativePath: string;
begin
if not OpenDialog_ClientEXE.Execute then
Exit;
RelativePath:= ExtractRelativePath(ExtractFilePath(Application.ExeName), 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(Application.ExeName), ExtractFilePath(OpenDialog_JSON.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 (ListView_Node.Items.Count - 1) do
begin
ClientNode:= TClientNode(ListView_Node.Items[i].Data);
if (ClientNode.isRunCMD = 0) then
begin
CMDLineStr:= ClientNode.CreateCMDLine(Edit_ClientEXEDir.Text);
ClientNode.RunCommand(CMDLineStr);
ClientNode.RunState:= '1';
end;
end;
ListView_Node.Repaint;
ListView_NodeClick(Self);
end;
procedure TFMain.Btn_StartClick(Sender: TObject);
var
CMDLineStr: string;
begin
CMDLineStr:= TClientNode(ListView_Node.Selected.Data).CreateCMDLine(Edit_ClientEXEDir.Text);
Memo_CMDLine.Lines.Text:= CMDLineStr;
TClientNode(ListView_Node.Selected.Data).RunCommand(CMDLineStr);
TClientNode(ListView_Node.Selected.Data).RunState:= '1';
ListView_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 (ListView_Node.Items.Count - 1) do
begin
ClientNode:= TClientNode(ListView_Node.Items[i].Data);
if (ClientNode.isRunCMD = 1) then
begin
ClientNode.CorrectQuit:= True;
ClientNode.StopCommand;
ClientNode.RunState:= '0';
end;
end;
ListView_Node.Repaint;
ListView_NodeClick(Self);
end;
procedure TFMain.Btn_StopClick(Sender: TObject);
begin
TClientNode(ListView_Node.Selected.Data).CorrectQuit:= True;
TClientNode(ListView_Node.Selected.Data).StopCommand;
TClientNode(ListView_Node.Selected.Data).RunState:= '0';
ListView_Node.Repaint;
Btn_Start.Enabled:= True;
Btn_Stop.Enabled:= False;
end;
procedure TFMain.CheckBox_ACKNoDelayClick(Sender: TObject);
begin
Label_ACKNoDelay.Enabled:= CheckBox_ACKNoDelay.Checked;
if ListView_Node.Selected = nil then
Exit;
TClientNode(ListView_Node.Selected.Data).isACKNoDelay:= Integer(CheckBox_ACKNoDelay.Checked);
if PublicVar.CanModifyXML then
LoadQRCodeImage(TClientNode(ListView_Node.Selected.Data));
end;
procedure TFMain.CheckBox_AllowOnlyLocalClick(Sender: TObject);
var
ClientNode: TClientNode;
begin
if ListView_Node.Selected = nil then
Exit;
ClientNode:= TClientNode(ListView_Node.Selected.Data);
ClientNode.AllowOnlyLocal:= Integer(CheckBox_AllowOnlyLocal.Checked);
end;
procedure TFMain.CheckBox_AutoConnClick(Sender: TObject);
begin
PublicVar.AutoConn:= Integer(CheckBox_AutoConn.Checked);
SpinEdit_AutoConnTime.Enabled:= CheckBox_AutoConn.Checked;
Label_AutoConnUnit.Enabled:= CheckBox_AutoConn.Checked;
if CheckBox_AutoConn.Checked then
begin
SpinEdit_AutoConnTime.Color:= clWindow;
if PublicVar.CanFoucs then
SpinEdit_AutoConnTime.SetFocus;
end
else
begin
SpinEdit_AutoConnTime.Color:= clBtnFace;
end;
if not PublicVar.CanModifyXML then
Exit;
PublicVar.ProgramNode.ChildNodes['autoconn'].Attributes['enable']:= PublicVar.AutoConn;
PublicVar.XMLDocument_Para.SaveToFile;
end;
procedure TFMain.CheckBox_AutoExpireClick(Sender: TObject);
begin
Label_AutoExpire.Enabled:= CheckBox_AutoExpire.Checked;
Edit_AutoExpire.Enabled:= CheckBox_AutoExpire.Checked;
if CheckBox_AutoExpire.Checked then
begin
Edit_AutoExpire.Color:= clWindow;
if PublicVar.CanFoucs then
Edit_AutoExpire.SetFocus;
end
else
begin
Edit_AutoExpire.Color:= clBtnFace;
end;
if ListView_Node.Selected = nil then
Exit;
TClientNode(ListView_Node.Selected.Data).isAutoExpire:= Integer(CheckBox_AutoExpire.Checked);
if PublicVar.CanModifyXML then
LoadQRCodeImage(TClientNode(ListView_Node.Selected.Data));
end;
procedure TFMain.CheckBox_AutoStartClick(Sender: TObject);
var
AutoStart: Integer;
begin
PublicVar.AutoStart:= Integer(CheckBox_AutoStart.Checked);
if not PublicVar.CanModifyXML then
Exit;
try
AutoStart:= Integer(CheckBox_AutoStart.Checked);
WriteREGAutoRun(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_ConfigFileDirClick(Sender: TObject);
begin
Label_ConfigFileDir.Enabled:= CheckBox_ConfigFileDir.Checked;
Edit_ConfigFileDir.Enabled:= CheckBox_ConfigFileDir.Checked;
Btn_FindConfigFileDir.Enabled:= CheckBox_ConfigFileDir.Checked;
if CheckBox_ConfigFileDir.Checked 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 ListView_Node.Selected = nil then
Exit;
TClientNode(ListView_Node.Selected.Data).isJson:= Integer(CheckBox_ConfigFileDir.Checked);
if PublicVar.CanModifyXML then
LoadQRCodeImage(TClientNode(ListView_Node.Selected.Data));
end;
procedure TFMain.CheckBox_ConnClick(Sender: TObject);
begin
Label_Conn.Enabled:= CheckBox_Conn.Checked;
Edit_Conn.Enabled:= CheckBox_Conn.Checked;
if CheckBox_Conn.Checked then
begin
Edit_Conn.Color:= clWindow;
if PublicVar.CanFoucs then
Edit_Conn.SetFocus;
end
else
begin
Edit_Conn.Color:= clBtnFace;
end;
if ListView_Node.Selected = nil then
Exit;
TClientNode(ListView_Node.Selected.Data).isConn:= Integer(CheckBox_Conn.Checked);
if PublicVar.CanModifyXML then
LoadQRCodeImage(TClientNode(ListView_Node.Selected.Data));
end;
procedure TFMain.CheckBox_CryptClick(Sender: TObject);
begin
Label_Crypt.Enabled:= CheckBox_Crypt.Checked;
ComboBox_Crypt.Enabled:= CheckBox_Crypt.Checked;
if CheckBox_Crypt.Checked then
begin
if PublicVar.CanFoucs then
ComboBox_Crypt.SetFocus;
end;
if ListView_Node.Selected = nil then
Exit;
TClientNode(ListView_Node.Selected.Data).isCrypt:= Integer(CheckBox_Crypt.Checked);
if PublicVar.CanModifyXML then
LoadQRCodeImage(TClientNode(ListView_Node.Selected.Data));
end;
procedure TFMain.CheckBox_DataShardClick(Sender: TObject);
begin
Label_DataShard.Enabled:= CheckBox_DataShard.Checked;
Edit_DataShard.Enabled:= CheckBox_DataShard.Checked;
if CheckBox_DataShard.Checked then
begin
Edit_DataShard.Color:= clWindow;
if PublicVar.CanFoucs then
Edit_DataShard.SetFocus;
end
else
begin
Edit_DataShard.Color:= clBtnFace;
end;
if ListView_Node.Selected = nil then
Exit;
TClientNode(ListView_Node.Selected.Data).isDataShard:= Integer(CheckBox_DataShard.Checked);
if PublicVar.CanModifyXML then
LoadQRCodeImage(TClientNode(ListView_Node.Selected.Data));
end;
procedure TFMain.CheckBox_DSCPClick(Sender: TObject);
begin
Label_DSCP.Enabled:= CheckBox_DSCP.Checked;
Edit_DSCP.Enabled:= CheckBox_DSCP.Checked;
if CheckBox_DSCP.Checked then
begin
Edit_DSCP.Color:= clWindow;
if PublicVar.CanFoucs then
Edit_DSCP.SetFocus;
end
else
begin
Edit_DSCP.Color:= clBtnFace;
end;
if ListView_Node.Selected = nil then
Exit;
TClientNode(ListView_Node.Selected.Data).isDSCP:= Integer(CheckBox_DSCP.Checked);
if PublicVar.CanModifyXML then
LoadQRCodeImage(TClientNode(ListView_Node.Selected.Data));
end;
procedure TFMain.CheckBox_IntervalClick(Sender: TObject);
begin
if (CheckBox_Mode.Checked) and (ComboBox_Mode.Text = 'manual') and (CheckBox_Interval.Checked) 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 ListView_Node.Selected = nil then
Exit;
TClientNode(ListView_Node.Selected.Data).isInterval:= Integer(CheckBox_Interval.Checked);
if PublicVar.CanModifyXML then
LoadQRCodeImage(TClientNode(ListView_Node.Selected.Data));
end;
procedure TFMain.CheckBox_KeepAliveClick(Sender: TObject);
begin
Label_KeepAlive.Enabled:= CheckBox_KeepAlive.Checked;
Edit_KeepAlive.Enabled:= CheckBox_KeepAlive.Checked;
if CheckBox_KeepAlive.Checked then
begin
Edit_KeepAlive.Color:= clWindow;
if PublicVar.CanFoucs then
Edit_KeepAlive.SetFocus;
end
else
begin
Edit_KeepAlive.Color:= clBtnFace;
end;
if ListView_Node.Selected = nil then
Exit;
TClientNode(ListView_Node.Selected.Data).isKeepAlive:= Integer(CheckBox_KeepAlive.Checked);
if PublicVar.CanModifyXML then
LoadQRCodeImage(TClientNode(ListView_Node.Selected.Data));
end;
procedure TFMain.CheckBox_KeyClick(Sender: TObject);
begin
Label_Key.Enabled:= CheckBox_Key.Checked;
Edit_Key.Enabled:= CheckBox_Key.Checked;
if CheckBox_Key.Checked then
begin
Edit_Key.Color:= clWindow;
if PublicVar.CanFoucs then
Edit_Key.SetFocus;
end
else
begin
Edit_Key.Color:= clBtnFace;
end;
if ListView_Node.Selected = nil then
Exit;
TClientNode(ListView_Node.Selected.Data).isKey:= Integer(CheckBox_Key.Checked);
if PublicVar.CanModifyXML then
LoadQRCodeImage(TClientNode(ListView_Node.Selected.Data));
end;
procedure TFMain.CheckBox_MinimizeClick(Sender: TObject);
begin
PublicVar.Minimize:= Integer(CheckBox_Minimize.Checked);
if not PublicVar.CanModifyXML then
Exit;
PublicVar.ProgramNode.ChildNodes['minimize'].NodeValue:= PublicVar.Minimize;
PublicVar.XMLDocument_Para.SaveToFile;
end;
procedure TFMain.CheckBox_ModeClick(Sender: TObject);
begin
Label_Mode.Enabled:= CheckBox_Mode.Checked;
ComboBox_Mode.Enabled:= CheckBox_Mode.Checked;
if CheckBox_Mode.Checked then
begin
if PublicVar.CanFoucs then
ComboBox_Mode.SetFocus;
end;
PublicVar.ModeCanFouse:= False;
if (ComboBox_Mode.Text = 'manual') and (CheckBox_Mode.Checked) then
begin
Interface_op.Enable_DisableModePara(True);
end
else
begin
Interface_op.Enable_DisableModePara(False);
end;
PublicVar.ModeCanFouse:= True;
if ListView_Node.Selected = nil then
Exit;
TClientNode(ListView_Node.Selected.Data).isMode:= Integer(CheckBox_Mode.Checked);
if PublicVar.CanModifyXML then
LoadQRCodeImage(TClientNode(ListView_Node.Selected.Data));
end;
procedure TFMain.CheckBox_MTUClick(Sender: TObject);
begin
Label_MTU.Enabled:= CheckBox_MTU.Checked;
Edit_MTU.Enabled:= CheckBox_MTU.Checked;
if CheckBox_MTU.Checked then
begin
Edit_MTU.Color:= clWindow;
if PublicVar.CanFoucs then
Edit_MTU.SetFocus;
end
else
begin
Edit_MTU.Color:= clBtnFace;
end;
if ListView_Node.Selected = nil then
Exit;
TClientNode(ListView_Node.Selected.Data).isMTU:= Integer(CheckBox_MTU.Checked);
if PublicVar.CanModifyXML then
LoadQRCodeImage(TClientNode(ListView_Node.Selected.Data));
end;
procedure TFMain.CheckBox_NCClick(Sender: TObject);
begin
if (CheckBox_Mode.Checked) and (ComboBox_Mode.Text = 'manual') and (CheckBox_NC.Checked) then
begin
Label_NC.Enabled:= True;
end
else
begin
Label_NC.Enabled:= False;
end;
if ListView_Node.Selected = nil then
Exit;
TClientNode(ListView_Node.Selected.Data).isNC:= Integer(CheckBox_NC.Checked);
if PublicVar.CanModifyXML then
LoadQRCodeImage(TClientNode(ListView_Node.Selected.Data));
end;
procedure TFMain.CheckBox_NoCompClick(Sender: TObject);
begin
Label_NoComp.Enabled:= CheckBox_NoComp.Checked;
if ListView_Node.Selected = nil then
Exit;
TClientNode(ListView_Node.Selected.Data).isNoComp:= Integer(CheckBox_NoComp.Checked);
if PublicVar.CanModifyXML then
LoadQRCodeImage(TClientNode(ListView_Node.Selected.Data));
end;
procedure TFMain.CheckBox_NoDelayClick(Sender: TObject);
begin
if (CheckBox_Mode.Checked) and (ComboBox_Mode.Text = 'manual') and (CheckBox_NoDelay.Checked) then
begin
Label_NoDelay.Enabled:= True;
end
else
begin
Label_NoDelay.Enabled:= False;
end;
if ListView_Node.Selected = nil then
Exit;
TClientNode(ListView_Node.Selected.Data).isNoDelay:= Integer(CheckBox_NoDelay.Checked);
if PublicVar.CanModifyXML then
LoadQRCodeImage(TClientNode(ListView_Node.Selected.Data));
end;
procedure TFMain.CheckBox_ParityShardClick(Sender: TObject);
begin
Label_ParityShard.Enabled:= CheckBox_ParityShard.Checked;
Edit_ParityShard.Enabled:= CheckBox_ParityShard.Checked;
if CheckBox_ParityShard.Checked then
begin
Edit_ParityShard.Color:= clWindow;
if PublicVar.CanFoucs then
Edit_ParityShard.SetFocus;
end
else
begin
Edit_ParityShard.Color:= clBtnFace;
end;
if ListView_Node.Selected = nil then
Exit;
TClientNode(ListView_Node.Selected.Data).isParityShard:= Integer(CheckBox_ParityShard.Checked);
if PublicVar.CanModifyXML then
LoadQRCodeImage(TClientNode(ListView_Node.Selected.Data));
end;
procedure TFMain.CheckBox_QuietClick(Sender: TObject);
begin
Label_Quiet.Enabled:= CheckBox_Quiet.Checked;
if ListView_Node.Selected = nil then
Exit;
TClientNode(ListView_Node.Selected.Data).isQuiet:= Integer(CheckBox_Quiet.Checked);
if PublicVar.CanModifyXML then
LoadQRCodeImage(TClientNode(ListView_Node.Selected.Data));
end;
procedure TFMain.CheckBox_RcvWndClick(Sender: TObject);
begin
Label_RcvWnd.Enabled:= CheckBox_RcvWnd.Checked;
Edit_RcvWnd.Enabled:= CheckBox_RcvWnd.Checked;
if CheckBox_RcvWnd.Checked then
begin
Edit_RcvWnd.Color:= clWindow;
if PublicVar.CanFoucs then
Edit_RcvWnd.SetFocus;
end
else
begin
Edit_RcvWnd.Color:= clBtnFace;
end;
if ListView_Node.Selected = nil then
Exit;
TClientNode(ListView_Node.Selected.Data).isRcvWnd:= Integer(CheckBox_RcvWnd.Checked);
if PublicVar.CanModifyXML then
LoadQRCodeImage(TClientNode(ListView_Node.Selected.Data));
end;
procedure TFMain.CheckBox_ResendClick(Sender: TObject);
begin
if (CheckBox_Mode.Checked) and (ComboBox_Mode.Text = 'manual') and (CheckBox_Resend.Checked) 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 ListView_Node.Selected = nil then
Exit;
TClientNode(ListView_Node.Selected.Data).isResend:= Integer(CheckBox_Resend.Checked);
if PublicVar.CanModifyXML then
LoadQRCodeImage(TClientNode(ListView_Node.Selected.Data));
end;
procedure TFMain.CheckBox_ScavengeTTLClick(Sender: TObject);
begin
Label_ScavengeTTL.Enabled:= CheckBox_ScavengeTTL.Checked;
Edit_ScavengeTTL.Enabled:= CheckBox_ScavengeTTL.Checked;
if CheckBox_ScavengeTTL.Checked then
begin
Edit_ScavengeTTL.Color:= clWindow;
if PublicVar.CanFoucs then
Edit_ScavengeTTL.SetFocus;
end
else
begin
Edit_ScavengeTTL.Color:= clBtnFace;
end;
if ListView_Node.Selected = nil then
Exit;
TClientNode(ListView_Node.Selected.Data).isScavengeTTL:= Integer(CheckBox_ScavengeTTL.Checked);
if PublicVar.CanModifyXML then
LoadQRCodeImage(TClientNode(ListView_Node.Selected.Data));
end;
procedure TFMain.CheckBox_SndWndClick(Sender: TObject);
begin
Label_SndWnd.Enabled:= CheckBox_SndWnd.Checked;
Edit_SndWnd.Enabled:= CheckBox_SndWnd.Checked;
if CheckBox_SndWnd.Checked then
begin
Edit_SndWnd.Color:= clWindow;
if PublicVar.CanFoucs then
Edit_SndWnd.SetFocus;
end
else
begin
Edit_SndWnd.Color:= clBtnFace;
end;
if ListView_Node.Selected = nil then
Exit;
TClientNode(ListView_Node.Selected.Data).isSndWnd:= Integer(CheckBox_SndWnd.Checked);