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

353 lines
9.6 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 FCaPolicyInfo;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.Buttons,
VirtualTrees, Define, Vcl.ExtCtrls, System.ImageList, Vcl.ImgList,
PngImageList, ManagerCaPolicy;
type
PCaEnt = ^TCaEnt;
TCaEnt = record
Kind: TCtxAwareKind;
end;
PTaskEnt = ^TTaskEnt;
TTaskEnt = record
Kind: TCaTaskKind;
end;
TFrmCaPolicyInfo = class(TFrame)
pnClient: TPanel;
Label1: TLabel;
Label2: TLabel;
vtCA: TVirtualStringTree;
vtTask: TVirtualStringTree;
btnAddCa: TSpeedButton;
btnAddTask: TSpeedButton;
btnOk: TButton;
btnCancel: TButton;
imgList: TPngImageList;
Label3: TLabel;
edName: TEdit;
procedure btnAddCaClick(Sender: TObject);
procedure btnCancelClick(Sender: TObject);
procedure vtCAGetNodeDataSize(Sender: TBaseVirtualTree;
var NodeDataSize: Integer);
procedure vtCAGetHint(Sender: TBaseVirtualTree; Node: PVirtualNode;
Column: TColumnIndex; var LineBreakStyle: TVTTooltipLineBreakStyle;
var HintText: string);
procedure vtCAGetText(Sender: TBaseVirtualTree; Node: PVirtualNode;
Column: TColumnIndex; TextType: TVSTTextType; var CellText: string);
procedure vtCANodeClick(Sender: TBaseVirtualTree; const HitInfo: THitInfo);
procedure vtCAGetImageIndex(Sender: TBaseVirtualTree; Node: PVirtualNode;
Kind: TVTImageKind; Column: TColumnIndex; var Ghosted: Boolean;
var ImageIndex: TImageIndex);
procedure btnAddTaskClick(Sender: TObject);
procedure vtTaskGetNodeDataSize(Sender: TBaseVirtualTree;
var NodeDataSize: Integer);
procedure vtTaskFreeNode(Sender: TBaseVirtualTree; Node: PVirtualNode);
procedure vtCAFreeNode(Sender: TBaseVirtualTree; Node: PVirtualNode);
procedure vtTaskGetText(Sender: TBaseVirtualTree; Node: PVirtualNode;
Column: TColumnIndex; TextType: TVSTTextType; var CellText: string);
procedure btnOkClick(Sender: TObject);
private
{ Private declarations }
FrmChild_: TFrame;
public
{ Public declarations }
Constructor Create(aOwner: TComponent); override;
function GetCaNames: String;
function GetTaskNames: String;
procedure process_WM_CAPOLICY_DLG_OK(var msg: TMessage); Message WM_CAPOLICY_DLG_OK;
procedure process_WM_CAPOLICY_DLG_CANCEL(var msg: TMessage); Message WM_CAPOLICY_DLG_CANCEL;
end;
implementation
uses
FCaPolicyCate, Tocsg.VirtualTreeViewUtil, FCaPolicyTaskCate, Tocsg.Strings;
{$R *.dfm}
Constructor TFrmCaPolicyInfo.Create(aOwner: TComponent);
begin
Inherited Create(aOwner);
FrmChild_ := nil;
end;
function TFrmCaPolicyInfo.GetCaNames: String;
var
pNode: PVirtualNode;
begin
Result := '';
vtCA.BeginUpdate;
try
pNode := vtCA.GetFirst;
while pNode <> nil do
begin
SumString(Result, vtCA.Text[pNode, 0]);
pNode := vtCA.GetNext(pNode);
end;
finally
vtCA.EndUpdate;
end;
end;
function TFrmCaPolicyInfo.GetTaskNames: String;
var
pNode: PVirtualNode;
begin
Result := '';
vtTask.BeginUpdate;
try
pNode := vtTask.GetFirst;
while pNode <> nil do
begin
SumString(Result, vtTask.Text[pNode, 0]);
pNode := vtTask.GetNext(pNode);
end;
finally
vtTask.EndUpdate;
end;
end;
procedure TFrmCaPolicyInfo.btnAddCaClick(Sender: TObject);
begin
if FrmChild_ = nil then
begin
FrmChild_ := TFrmCaPolicyCate.Create(Self);
FrmChild_.Parent := Self;
FrmChild_.Align := alClient;
FrmChild_.Visible := true;
pnClient.Visible := false;
end;
end;
procedure TFrmCaPolicyInfo.btnAddTaskClick(Sender: TObject);
begin
if FrmChild_ = nil then
begin
FrmChild_ := TFrmCaPolicyTaskCate.Create(Self);
FrmChild_.Parent := Self;
FrmChild_.Align := alClient;
FrmChild_.Visible := true;
pnClient.Visible := false;
end;
end;
procedure TFrmCaPolicyInfo.btnCancelClick(Sender: TObject);
begin
if (Owner <> nil) and (Owner is TWinControl) then
PostMessage(TWinControl(Owner).Handle, WM_CAPOLICY_DLG_CANCEL, 0, 0);
end;
procedure TFrmCaPolicyInfo.btnOkClick(Sender: TObject);
begin
if (Owner <> nil) and (Owner is TWinControl) then
begin
edName.Text := Trim(edName.Text);
if edName.Text = '' then
begin
MessageBox(Handle, PChar('<27><>å <20≯<EFBFBD><CCB8><EFBFBD> <20>Է<EFBFBD><D4B7><EFBFBD> <20>ֽʽÿ<CABD>.'), PChar('CA'), MB_ICONWARNING or MB_OK);
exit;
end;
if GetCaNames = '' then
begin
MessageBox(Handle, PChar('<27><>Ȳ <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>߰<EFBFBD><DFB0><EFBFBD> <20>ֽʽÿ<CABD>.'), PChar('CA'), MB_ICONWARNING or MB_OK);
exit;
end;
if GetTaskNames = '' then
begin
MessageBox(Handle, PChar('<27><><EFBFBD><EFBFBD> <20><>å<EFBFBD><C3A5> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ֽʽÿ<CABD>.'), PChar('CA'), MB_ICONWARNING or MB_OK);
exit;
end;
PostMessage(TWinControl(Owner).Handle, WM_CAPOLICY_DLG_OK, 0, 0);
end;
end;
procedure TFrmCaPolicyInfo.process_WM_CAPOLICY_DLG_OK(var msg: TMessage);
var
pDataCA: PCaEnt;
pDataTsk: PTaskEnt;
begin
if FrmChild_ <> nil then
begin
if FrmChild_ is TFrmCaPolicyCate then
begin
vtCA.BeginUpdate;
try
pDataCA := VT_AddChildData(vtCA);
pDataCA.Kind := TFrmCaPolicyCate(FrmChild_).SelectedCaKind;
ASSERT(pDataCA.Kind <> cakUnknown);
finally
vtCA.EndUpdate;
end;
end else
if FrmChild_ is TFrmCaPolicyTaskCate then
begin
vtTask.BeginUpdate;
try
pDataTsk := VT_AddChildData(vtTask);
pDataTsk.Kind := TFrmCaPolicyTaskCate(FrmChild_).SelectedCaKind;
ASSERT(pDataTsk.Kind <> ctkUnknown);
finally
vtTask.EndUpdate;
end;
end;
pnClient.Visible := true;
FreeAndNil(FrmChild_);
end;
end;
procedure TFrmCaPolicyInfo.vtCAFreeNode(Sender: TBaseVirtualTree;
Node: PVirtualNode);
var
pData: PCaEnt;
begin
pData := Sender.GetNodeData(Node);
Finalize(pData^);
end;
procedure TFrmCaPolicyInfo.vtCAGetHint(Sender: TBaseVirtualTree;
Node: PVirtualNode; Column: TColumnIndex;
var LineBreakStyle: TVTTooltipLineBreakStyle; var HintText: string);
begin
HintText := TVirtualStringTree(Sender).Text[Node, Column];
end;
procedure TFrmCaPolicyInfo.vtCAGetImageIndex(Sender: TBaseVirtualTree;
Node: PVirtualNode; Kind: TVTImageKind; Column: TColumnIndex;
var Ghosted: Boolean; var ImageIndex: TImageIndex);
begin
if Column = 1 then
begin
case Kind of
ikNormal,
ikSelected: ImageIndex := 0;
end;
end;
end;
procedure TFrmCaPolicyInfo.vtCAGetNodeDataSize(Sender: TBaseVirtualTree;
var NodeDataSize: Integer);
begin
NodeDataSize := SizeOf(TCaEnt);
end;
procedure TFrmCaPolicyInfo.vtCAGetText(Sender: TBaseVirtualTree;
Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType;
var CellText: string);
var
pData: PCaEnt;
begin
if Column = 0 then
begin
pData := Sender.GetNodeData(Node);
case pData.Kind of
cakDate : CellText := '<27><>¥';
cakTime : CellText := '<27>ð<EFBFBD>';
cakIpRange : CellText := 'IP <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>';
cakWlan : CellText := '<27><><EFBFBD><EFBFBD> <20><>Ʈ<EFBFBD><C6AE>ũ';
cakVNic : CellText := '<27><><EFBFBD><EFBFBD> NIC Ȱ<><C8B0>';
cakRdp : CellText := '<27>ܺο<DCBA><CEBF><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>ũ<EFBFBD><C5A9> <20><><EFBFBD><EFBFBD>';
cakWebb : CellText := '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
cakUSB : CellText := 'USB';
cakBT : CellText := '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
cakMTP : CellText := 'MTP';
cakApp : CellText := '<27><><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD>';
cakAppInst : CellText := '<27><><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE><EFBFBD><EFBFBD> <20><>ġ/<2F><><EFBFBD><EFBFBD>';
cakAppCap : CellText := '<27><><EFBFBD>α׷<CEB1> ĸ<><C4B8>';
cakFile : CellText := '<27><><EFBFBD><EFBFBD>';
cakFolder : CellText := '<27><><EFBFBD><EFBFBD>';
cakLogoff : CellText := '<27>α׿<CEB1><D7BF><EFBFBD>';
cakScrSv : CellText := 'ȭ<><C8AD> <20><>ȣ<EFBFBD><C8A3>';
cakScrLck : CellText := '<27><><EFBFBD><EFBFBD>ȭ<EFBFBD><C8AD>';
cakSleep : CellText := '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
cakSecu : CellText := '<27><><EFBFBD>ȸ<EFBFBD><C8B8><EFBFBD>';
cakVul : CellText := '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
else CellText := Format('Unknown (%d)', [Integer(pData.Kind)]);
end;
end;
end;
procedure TFrmCaPolicyInfo.vtCANodeClick(Sender: TBaseVirtualTree;
const HitInfo: THitInfo);
begin
if hiOnNormalIcon in HitInfo.HitPositions then
begin
if HitInfo.HitNode = nil then
exit;
if MessageBox(Handle, PChar('<27><><EFBFBD><EFBFBD><EFBFBD>Ͻðڽ<C3B0><DABD>ϱ<EFBFBD>?'),
PChar('CA'), MB_ICONQUESTION or MB_YESNO) = IDNO then exit;
Sender.DeleteNode(HitInfo.HitNode);
end;
end;
procedure TFrmCaPolicyInfo.vtTaskFreeNode(Sender: TBaseVirtualTree;
Node: PVirtualNode);
var
pData: PTaskEnt;
begin
pData := Sender.GetNodeData(Node);
Finalize(pData^);
end;
procedure TFrmCaPolicyInfo.vtTaskGetNodeDataSize(Sender: TBaseVirtualTree;
var NodeDataSize: Integer);
begin
NodeDataSize := SizeOf(TTaskEnt);
end;
procedure TFrmCaPolicyInfo.vtTaskGetText(Sender: TBaseVirtualTree;
Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType;
var CellText: string);
var
pData: PTaskEnt;
begin
if Column = 0 then
begin
pData := Sender.GetNodeData(Node);
case pData.Kind of
ctkPortPO : CellText := '<27><>Ʈ <20><>å';
ctkConnPO : CellText := '<27><>Ʈ<EFBFBD><C6AE>ũ <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><>å';
ctkWebb : CellText := '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> URL <20><><EFBFBD><EFBFBD>';
ctkAppPO : CellText := '<27><><EFBFBD>μ<EFBFBD><CEBC><EFBFBD> <20><><EFBFBD><EFBFBD>';
ctkAppInstPO : CellText := '<27><><EFBFBD>α׷<CEB1> <20><>ġ <20><><EFBFBD><EFBFBD>';
ctkUsbPO : CellText := 'USB <20><><EFBFBD><EFBFBD>';
ctkBtPO : CellText := '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>';
ctkMtpPO : CellText := 'MTP <20><><EFBFBD><EFBFBD>';
ctkFile : CellText := '<27><><EFBFBD><EFBFBD> <20><>å';
ctkFolder : CellText := '<27><><EFBFBD><EFBFBD> <20><>å';
// ctkCttSchFile, ctkCttSchDir, ctkBlcDownDirPO,
ctkScrLogoPO : CellText := '<27><><EFBFBD>÷ΰ<C3B7> ǥ<><C7A5>';
ctkBlcClipPO : CellText := 'Ŭ<><C5AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>';
ctkScrLock : CellText := 'ȭ<><C8AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
end;
end;
end;
procedure TFrmCaPolicyInfo.process_WM_CAPOLICY_DLG_CANCEL(var msg: TMessage);
begin
if FrmChild_ <> nil then
begin
pnClient.Visible := true;
FreeAndNil(FrmChild_);
end;
end;
end.