📄 open.pas
字号:
unit Open;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComCtrls, StdCtrls, Global, Buttons;
type
TOpenForm = class(TForm)
pcOpen: TPageControl;
tsAdapter: TTabSheet;
tsRemote: TTabSheet;
tsFile: TTabSheet;
cbxAdapter: TComboBox;
lblFilter: TLabel;
lblReadTimeOut: TLabel;
lblSnapLen: TLabel;
edReadTimeOut: TEdit;
edSnapLen: TEdit;
chkThreadSafe: TCheckBox;
lblHost: TLabel;
lblUserName: TLabel;
lblPassword: TLabel;
edHost: TEdit;
edUserName: TEdit;
edPassword: TEdit;
edFileName: TEdit;
sbtFileName: TSpeedButton;
btnOK: TButton;
btnCancel: TButton;
odFile: TOpenDialog;
cbxFilter: TComboBox;
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure sbtFileNameClick(Sender: TObject);
procedure btnOKClick(Sender: TObject);
procedure pcOpenChange(Sender: TObject);
private
{ Private declarations }
procedure SetControl;
public
{ Public declarations }
end;
var
OpenForm: TOpenForm;
implementation
uses Option, Main;
{$R *.DFM}
procedure TOpenForm.SetControl;
var
Index: Integer;
begin
Index := pcOpen.ActivePageIndex;
// if file load, ReadTimeOut, SnapLen, ThreadSafe do not need.
edReadTimeOut.Enabled := Index <> 2;
edSnapLen.Enabled := Index <> 2;
chkThreadSafe.Enabled := Index <> 2;
end;
procedure TOpenForm.FormCreate(Sender: TObject);
begin
//
end;
procedure TOpenForm.FormShow(Sender: TObject);
begin
_Global.Load;
// Open Type
pcOpen.ActivePageIndex := _Global.OpenType;
// Adapter
cbxAdapter.Items := MainForm.Snoop1.AdapterDescriptions;
cbxAdapter.ItemIndex := _Global.AdapterIndex;
if cbxAdapter.ItemIndex = -1 then
cbxAdapter.ItemIndex := 0;
// Remote
edHost.Text := _Global.Host;
edUserName.Text := _Global.UserName;
edPassword.Text := _Global.Password;
// File
edFileName.Text := _Global.FileName;
// Snoop Property
cbxFilter.Text := _Global.Filter;
cbxFilter.Items := _Global.FilterList;
edReadTimeOut.Text := IntToStr(_Global.ReadTimeOut);
edSnapLen.Text := IntToStr(_Global.SnapLen);
chkThreadSafe.Checked := _Global.ThreadSafe;
SetControl;
end;
procedure TOpenForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
//
end;
procedure TOpenForm.sbtFileNameClick(Sender: TObject);
begin
if odFile.Execute then
edFileName.Text := odFile.FileName;
end;
procedure TOpenForm.btnOKClick(Sender: TObject);
var
i: Integer;
begin
// Open Type
_Global.OpenType := pcOpen.ActivePageIndex;
// Adapter Capture
_Global.AdapterIndex := cbxAdapter.ItemIndex;
// Remote Capture
_Global.Host := edHost.Text;
_Global.UserName := edUserName.Text;
_Global.Password := edPassword.Text;
// File Capture
_Global.FileName := edFileName.Text;
// Snoop Property
_Global.Filter := cbxFilter.Text;
i := _Global.FilterList.IndexOf(cbxFilter.Text);
if i <> -1 then
_Global.FilterList.Delete(i);
_Global.FilterList.Insert(0, cbxFilter.Text);
cbxFilter.Items := _Global.FilterList;
_Global.ReadTimeOut := StrToInt(edReadTimeOut.Text);
_Global.SnapLen := StrToInt(edSnapLen.Text);
_Global.ThreadSafe := chkThreadSafe.Checked;
_Global.Save;
end;
procedure TOpenForm.pcOpenChange(Sender: TObject);
begin
SetControl;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -