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('Á¤Ã¥ À̸§À» ÀÔ·ÂÇØ ÁֽʽÿÀ.'), PChar('CA'), MB_ICONWARNING or MB_OK); exit; end; if GetCaNames = '' then begin MessageBox(Handle, PChar('»óȲ ÀÎÁö Á¶°ÇÀ» Ãß°¡ÇØ ÁֽʽÿÀ.'), PChar('CA'), MB_ICONWARNING or MB_OK); exit; end; if GetTaskNames = '' then begin MessageBox(Handle, PChar('º¸¾È Á¤Ã¥À» ¼³Á¤ÇØ ÁֽʽÿÀ.'), 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 := '³¯Â¥'; cakTime : CellText := '½Ã°£'; cakIpRange : CellText := 'IP ¹üÀ§ ÁøÀÔ'; cakWlan : CellText := '¹«¼± ³×Æ®¿öÅ©'; cakVNic : CellText := '°¡»ó NIC Ȱ¼º'; cakRdp : CellText := '¿ÜºÎ¿¡¼­ ¿ø°Ý µ¥½ºÅ©Åé ¿¬°á'; cakWebb : CellText := 'À¥ºê¶ó¿ìÀú'; cakUSB : CellText := 'USB'; cakBT : CellText := 'ºí·çÅõ½º'; cakMTP : CellText := 'MTP'; cakApp : CellText := '¼ÒÇÁÆ®¿þ¾î ½ÇÇà/Á¾·á'; cakAppInst : CellText := '¼ÒÇÁÆ®¿þ¾î ¼³Ä¡/»èÁ¦'; cakAppCap : CellText := 'ÇÁ·Î±×·¥ ĸ¼Ç'; cakFile : CellText := 'ÆÄÀÏ'; cakFolder : CellText := 'Æú´õ'; cakLogoff : CellText := '·Î±×¿ÀÇÁ'; cakScrSv : CellText := 'È­¸é º¸È£±â'; cakScrLck : CellText := 'Àá±ÝÈ­¸é'; cakSleep : CellText := '¼ö¸é¸ðµå'; cakSecu : CellText := 'º¸¾È¸ðµå'; cakVul : CellText := 'Ãë¾à¸ðµå'; 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('»èÁ¦ÇϽðڽÀ´Ï±î?'), 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 := 'Æ÷Æ® Á¤Ã¥'; ctkConnPO : CellText := '³×Æ®¿öÅ© Á¢¼Ó °ü¸® Á¤Ã¥'; ctkWebb : CellText := 'À¥ºê¶ó¿ìÀú URL Â÷´Ü'; ctkAppPO : CellText := 'ÇÁ·Î¼¼½º Â÷´Ü'; ctkAppInstPO : CellText := 'ÇÁ·Î±×·¥ ¼³Ä¡ Â÷´Ü'; ctkUsbPO : CellText := 'USB Á¦¾î'; ctkBtPO : CellText := 'ºí·çÅõ½º Â÷´Ü'; ctkMtpPO : CellText := 'MTP Â÷´Ü'; ctkFile : CellText := 'ÆÄÀÏ Á¤Ã¥'; ctkFolder : CellText := 'Æú´õ Á¤Ã¥'; // ctkCttSchFile, ctkCttSchDir, ctkBlcDownDirPO, ctkScrLogoPO : CellText := '»ó½Ã·Î°í Ç¥½Ã'; ctkBlcClipPO : CellText := 'Ŭ¸³º¸µå Â÷´Ü'; ctkScrLock : CellText := 'È­¸éÀá±Ý'; 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.