BSOne.SFC/Tocsg.Module/ContextAwarePolicy/FCaPolicySel.pas

353 lines
9.0 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

unit FCaPolicySel;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls,
VirtualTrees, Vcl.ComCtrls, ManagerCaPolicy;
type
PCateEnt = ^TCateEnt;
TCateEnt = record
sCaption: String;
Kind: TCtxAwareKind;
end;
TFrmCaPolicySel = class(TFrame)
pnBottom: TPanel;
btnOk: TButton;
btnCancel: TButton;
vtList: TVirtualStringTree;
Splitter1: TSplitter;
pcMain: TPageControl;
tabDate: TTabSheet;
tabTime: TTabSheet;
Label1: TLabel;
Label2: TLabel;
dpDateBegin: TDateTimePicker;
dpDateEnd: TDateTimePicker;
Label3: TLabel;
Label4: TLabel;
dpTimeBegin: TDateTimePicker;
dpTimeEnd: TDateTimePicker;
tabIpRange: TTabSheet;
Label5: TLabel;
mmIR_IpRange: TMemo;
tabVNic: TTabSheet;
Label6: TLabel;
Memo1: TMemo;
tabRDP: TTabSheet;
tabWebb: TTabSheet;
CheckBox2: TCheckBox;
CheckBox3: TCheckBox;
CheckBox4: TCheckBox;
CheckBox5: TCheckBox;
CheckBox6: TCheckBox;
Label7: TLabel;
Label8: TLabel;
Memo2: TMemo;
tabWlan: TTabSheet;
tabUsb: TTabSheet;
tabBT: TTabSheet;
tabMTP: TTabSheet;
tabApp: TTabSheet;
tabAInst: TTabSheet;
tabACap: TTabSheet;
tabFile: TTabSheet;
tabFolder: TTabSheet;
tabLogoff: TTabSheet;
tabScrSv: TTabSheet;
tabScrLck: TTabSheet;
tabSleep: TTabSheet;
tabSecu: TTabSheet;
tabVul: TTabSheet;
Label9: TLabel;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
RadioButton3: TRadioButton;
Memo3: TMemo;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
Label14: TLabel;
Label15: TLabel;
RadioButton4: TRadioButton;
RadioButton5: TRadioButton;
RadioButton6: TRadioButton;
Memo4: TMemo;
Label16: TLabel;
RadioButton7: TRadioButton;
RadioButton8: TRadioButton;
RadioButton9: TRadioButton;
Memo5: TMemo;
Label17: TLabel;
RadioButton10: TRadioButton;
RadioButton11: TRadioButton;
RadioButton12: TRadioButton;
Memo6: TMemo;
Label18: TLabel;
RadioButton13: TRadioButton;
RadioButton14: TRadioButton;
Memo7: TMemo;
Label19: TLabel;
RadioButton15: TRadioButton;
RadioButton16: TRadioButton;
Memo8: TMemo;
Label20: TLabel;
Memo9: TMemo;
Label21: TLabel;
Label23: TLabel;
RadioButton17: TRadioButton;
RadioButton18: TRadioButton;
RadioButton19: TRadioButton;
Memo10: TMemo;
CheckBox1: TCheckBox;
CheckBox7: TCheckBox;
CheckBox8: TCheckBox;
CheckBox9: TCheckBox;
Label24: TLabel;
Label25: TLabel;
Label26: TLabel;
Label27: TLabel;
Label28: TLabel;
Label29: TLabel;
Label30: TLabel;
CheckBox10: TCheckBox;
Edit1: TEdit;
<20><>: TLabel;
CheckBox11: TCheckBox;
Edit2: TEdit;
Label31: TLabel;
CheckBox12: TCheckBox;
Edit3: TEdit;
Label32: TLabel;
CheckBox13: TCheckBox;
Edit4: TEdit;
Label33: TLabel;
CheckBox14: TCheckBox;
Edit5: TEdit;
Label34: TLabel;
CheckBox15: TCheckBox;
Edit6: TEdit;
Label35: TLabel;
procedure btnCancelClick(Sender: TObject);
procedure vtListGetHint(Sender: TBaseVirtualTree; Node: PVirtualNode;
Column: TColumnIndex; var LineBreakStyle: TVTTooltipLineBreakStyle;
var HintText: string);
procedure vtListGetNodeDataSize(Sender: TBaseVirtualTree;
var NodeDataSize: Integer);
procedure vtListGetText(Sender: TBaseVirtualTree; Node: PVirtualNode;
Column: TColumnIndex; TextType: TVSTTextType; var CellText: string);
procedure vtListFocusChanged(Sender: TBaseVirtualTree; Node: PVirtualNode;
Column: TColumnIndex);
procedure vtListFreeNode(Sender: TBaseVirtualTree; Node: PVirtualNode);
procedure btnOkClick(Sender: TObject);
private
{ Private declarations }
SelCaKind_: TCtxAwareKind;
public
{ Public declarations }
Constructor Create(aOwner: TComponent); override;
procedure RefreshPolicy(nCate: Integer);
property SelectedCaKind: TCtxAwareKind read SelCaKind_;
end;
implementation
uses
Define, Tocsg.VirtualTreeViewUtil, System.DateUtils;
{$R *.dfm}
Constructor TFrmCaPolicySel.Create(aOwner: TComponent);
procedure InitCtrls;
var
i: Integer;
begin
for i := 0 to pcMain.PageCount - 1 do
pcMain.Pages[i].TabVisible := false;
dpDateBegin.Date := Now;
dpDateEnd.Date := IncDay(dpDateBegin.Date, 30);
dpTimeBegin.Time := EncodeDateTime(1981, 11, 8, 9, 0, 0, 0);
dpTimeEnd.Time := EncodeDateTime(1981, 11, 8, 18, 0, 0, 0);
end;
begin
Inherited Create(aOwner);
SelCaKind_ := cakUnknown;
InitCtrls;
end;
procedure TFrmCaPolicySel.RefreshPolicy(nCate: Integer);
procedure AddCateEnt(sCaption: String; aKind: TCtxAwareKind);
var
pData: PCateEnt;
begin
pData := VT_AddChildData(vtList);
pData.sCaption := sCaption;
pData.Kind := aKind;
end;
var
pNode: PVirtualNode;
begin
vtList.BeginUpdate;
try
case nCate of
1 :
begin
AddCateEnt('<27><>¥', cakDate);
AddCateEnt('<27>ð<EFBFBD>', cakTime);
end;
2 :
begin
AddCateEnt('IP <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>', cakIpRange);
AddCateEnt('<27><><EFBFBD><EFBFBD> <20><>Ʈ<EFBFBD><C6AE>ũ', cakWlan);
AddCateEnt('<27><><EFBFBD><EFBFBD> NIC Ȱ<><C8B0>', cakVNic);
AddCateEnt('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', cakWebb);
AddCateEnt('<27><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>ũ<EFBFBD><C5A9> <20><><EFBFBD><EFBFBD>', cakRdp);
end;
3 :
begin
AddCateEnt('USB', cakUSB);
AddCateEnt('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', cakBT);
AddCateEnt('MTP', cakMTP);
end;
4 :
begin
AddCateEnt('<27><><EFBFBD>μ<EFBFBD><CEBC><EFBFBD>', cakApp);
AddCateEnt('<27><><EFBFBD>α׷<CEB1> ĸ<><C4B8>', cakAppCap);
AddCateEnt('<27><><EFBFBD>α׷<CEB1> <20><>ġ', CakAppInst);
end;
5 :
begin
AddCateEnt('<27><><EFBFBD><EFBFBD>', cakFile);
AddCateEnt('<27><><EFBFBD><EFBFBD>', cakFolder);
end;
6 :
begin
AddCateEnt('<27>α׿<CEB1><D7BF><EFBFBD>', cakLogoff);
AddCateEnt('ȭ<><C8AD> <20><>ȣ<EFBFBD><C8A3> On', cakScrSv);
AddCateEnt('<27><><EFBFBD><EFBFBD>ȭ<EFBFBD><C8AD> On', cakScrLck);
AddCateEnt('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', cakSleep);
AddCateEnt('<27><><EFBFBD>ȸ<EFBFBD><C8B8><EFBFBD>', cakSecu);
AddCateEnt('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', cakVul);
end;
end;
pNode := vtList.GetFirst;
if pNode <> nil then
begin
vtList.Selected[pNode] := true;
vtList.FocusedNode := pNode;
end;
finally
vtList.EndUpdate;
end;
end;
procedure TFrmCaPolicySel.btnCancelClick(Sender: TObject);
begin
if (Owner <> nil) and (Owner is TWinControl) then
PostMessage(TWinControl(Owner).Handle, WM_CAPOLICY_DLG_CANCEL, 0, 0);
end;
procedure TFrmCaPolicySel.vtListFocusChanged(Sender: TBaseVirtualTree;
Node: PVirtualNode; Column: TColumnIndex);
var
pData: PCateEnt;
begin
if Node = nil then
exit;
pData := Sender.GetNodeData(Node);
case pData.Kind of
cakDate : pcMain.ActivePage := tabDate;
cakTime : pcMain.ActivePage := tabTime;
cakIpRange : pcMain.ActivePage := tabIpRange;
cakWlan : pcMain.ActivePage := tabWlan;
cakVNic : pcMain.ActivePage := tabVNic;
cakRdp : pcMain.ActivePage := tabRDP;
cakWebb : pcMain.ActivePage := tabWebb;
cakUSB : pcMain.ActivePage := tabUsb;
cakBT : pcMain.ActivePage := tabBT;
cakMTP : pcMain.ActivePage := tabMTP;
cakApp : pcMain.ActivePage := tabApp;
cakAppInst : pcMain.ActivePage := tabAInst;
cakAppCap : pcMain.ActivePage := tabACap;
cakFile : pcMain.ActivePage := tabFile;
cakFolder : pcMain.ActivePage := tabFolder;
cakLogoff : pcMain.ActivePage := tabLogoff;
cakScrSv : pcMain.ActivePage := tabScrSv;
cakScrLck : pcMain.ActivePage := tabScrLck;
cakSleep : pcMain.ActivePage := tabSleep;
cakSecu : pcMain.ActivePage := tabSecu;
cakVul : pcMain.ActivePage := tabVul;
end;
end;
procedure TFrmCaPolicySel.vtListFreeNode(Sender: TBaseVirtualTree;
Node: PVirtualNode);
var
pData: PCateEnt;
begin
pData := Sender.GetNodeData(Node);
Finalize(pData^);
end;
procedure TFrmCaPolicySel.vtListGetHint(Sender: TBaseVirtualTree;
Node: PVirtualNode; Column: TColumnIndex;
var LineBreakStyle: TVTTooltipLineBreakStyle; var HintText: string);
begin
HintText := vtList.Text[Node, Column];
end;
procedure TFrmCaPolicySel.vtListGetNodeDataSize(Sender: TBaseVirtualTree;
var NodeDataSize: Integer);
begin
NodeDataSize := SizeOf(TCateEnt);
end;
procedure TFrmCaPolicySel.vtListGetText(Sender: TBaseVirtualTree;
Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType;
var CellText: string);
var
pData: PCateEnt;
begin
if Column = 0 then
begin
pData := Sender.GetNodeData(Node);
CellText := pData.sCaption;
end;
end;
procedure TFrmCaPolicySel.btnOkClick(Sender: TObject);
var
pNode: PVirtualNode;
pData: PCateEnt;
begin
if (Owner <> nil) and (Owner is TWinControl) then
begin
pNode := vtList.GetFirstSelected;
if pNode = nil then
begin
MessageBox(Handle, PChar('<27><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ֽʽÿ<CABD>.'), PChar(Caption), MB_ICONWARNING or MB_OK);
exit;
end;
pData := vtList.GetNodeData(pNode);
SelCaKind_ := pData.Kind;
PostMessage(TWinControl(Owner).Handle, WM_CAPOLICY_DLG_OK, 0, 0);
end;
end;
end.