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

292 lines
7.3 KiB
Plaintext
Raw Permalink 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 FCaPolicyTaskSel;
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
PTaskEnt = ^TTaskEnt;
TTaskEnt = record
sCaption: String;
Kind: TCaTaskKind;
end;
TFrmCaPolicyTaskSel = class(TFrame)
pnBottom: TPanel;
btnOk: TButton;
btnCancel: TButton;
vtList: TVirtualStringTree;
Splitter1: TSplitter;
pcMain: TPageControl;
tabPort: TTabSheet;
Label1: TLabel;
CheckBox1: TCheckBox;
CheckBox2: TCheckBox;
Memo1: TMemo;
tabConn: TTabSheet;
Label2: TLabel;
ComboBox1: TComboBox;
Memo2: TMemo;
CheckBox3: TCheckBox;
Memo3: TMemo;
tabWebb: TTabSheet;
Label3: TLabel;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
Memo4: TMemo;
tabWlan: TTabSheet;
Label4: TLabel;
RadioButton3: TRadioButton;
RadioButton4: TRadioButton;
tabApp: TTabSheet;
Label5: TLabel;
RadioButton5: TRadioButton;
RadioButton6: TRadioButton;
Memo5: TMemo;
tabAppInst: TTabSheet;
Label6: TLabel;
RadioButton7: TRadioButton;
RadioButton8: TRadioButton;
Memo6: TMemo;
tabUSB: TTabSheet;
tabBT: TTabSheet;
tabMTP: TTabSheet;
Label7: TLabel;
RadioButton9: TRadioButton;
RadioButton10: TRadioButton;
CheckBox4: TCheckBox;
Memo7: TMemo;
Label8: TLabel;
CheckBox5: TCheckBox;
Memo8: TMemo;
Label9: TLabel;
CheckBox6: TCheckBox;
Memo9: TMemo;
tabFile: TTabSheet;
Label10: TLabel;
CheckBox7: TCheckBox;
CheckBox8: TCheckBox;
CheckBox9: TCheckBox;
Memo10: TMemo;
Memo11: TMemo;
Memo12: TMemo;
CheckBox10: TCheckBox;
tabFolder: TTabSheet;
Label11: TLabel;
CheckBox11: TCheckBox;
tabCB: TTabSheet;
Label12: TLabel;
Label13: TLabel;
Memo13: TMemo;
tabLogo: TTabSheet;
lbLogo: TLabel;
tabScrLock: TTabSheet;
Label14: TLabel;
Label15: TLabel;
Label16: TLabel;
edPass1: TEdit;
edPass2: TEdit;
CheckBox12: TCheckBox;
Label17: TLabel;
Edit1: TEdit;
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 }
SelTaskKind_: TCaTaskKind;
public
{ Public declarations }
Constructor Create(aOwner: TComponent); override;
procedure RefreshPolicy(nCate: Integer);
property SelectedCaKind: TCaTaskKind read SelTaskKind_;
end;
implementation
uses
Define, Tocsg.VirtualTreeViewUtil, System.DateUtils;
{$R *.dfm}
Constructor TFrmCaPolicyTaskSel.Create(aOwner: TComponent);
procedure InitCtrls;
var
i: Integer;
begin
for i := 0 to pcMain.PageCount - 1 do
pcMain.Pages[i].TabVisible := false;
end;
begin
Inherited Create(aOwner);
SelTaskKind_ := ctkUnknown;
InitCtrls;
end;
procedure TFrmCaPolicyTaskSel.RefreshPolicy(nCate: Integer);
procedure AddCateEnt(sCaption: String; aKind: TCaTaskKind);
var
pData: PTaskEnt;
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><>Ʈ <20><><EFBFBD><EFBFBD>', ctkPortPO);
AddCateEnt('<27><>Ʈ<EFBFBD><C6AE>ũ <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>', ctkConnPO);
end;
2 :
begin
AddCateEnt('<27><><EFBFBD>μ<EFBFBD><CEBC><EFBFBD> <20><><EFBFBD><EFBFBD>', ctkAppPO);
AddCateEnt('<27><><EFBFBD>α׷<CEB1> <20><>ġ <20><><EFBFBD><EFBFBD>', ctkAppInstPO);
end;
3 :
begin
AddCateEnt('USB', ctkUsbPO);
AddCateEnt('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', ctkBtPO);
AddCateEnt('MTP', ctkMtpPO);
end;
4 :
begin
AddCateEnt('<27><><EFBFBD><EFBFBD>', ctkFile);
AddCateEnt('<27><><EFBFBD><EFBFBD>', ctkFolder);
end;
5 :
begin
AddCateEnt('Ŭ<><C5AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', ctkBlcClipPO);
AddCateEnt('<27><><EFBFBD>÷ΰ<C3B7>', ctkScrLogoPO);
AddCateEnt('ȭ<><C8AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', ctkScrLock);
end;
6 : ;
end;
pNode := vtList.GetFirst;
if pNode <> nil then
begin
vtList.Selected[pNode] := true;
vtList.FocusedNode := pNode;
end;
finally
vtList.EndUpdate;
end;
end;
procedure TFrmCaPolicyTaskSel.btnCancelClick(Sender: TObject);
begin
if (Owner <> nil) and (Owner is TWinControl) then
PostMessage(TWinControl(Owner).Handle, WM_CAPOLICY_DLG_CANCEL, 0, 0);
end;
procedure TFrmCaPolicyTaskSel.vtListFocusChanged(Sender: TBaseVirtualTree;
Node: PVirtualNode; Column: TColumnIndex);
var
pData: PTaskEnt;
begin
if Node = nil then
exit;
pData := Sender.GetNodeData(Node);
case pData.Kind of
ctkPortPO : pcMain.ActivePage := tabPort;
ctkConnPO : pcMain.ActivePage := tabConn;
ctkWebb : pcMain.ActivePage := tabWebb;
ctkAppPO : pcMain.ActivePage := tabApp;
ctkAppInstPO : pcMain.ActivePage := tabAppInst;
ctkUsbPO : pcMain.ActivePage := tabUSB;
ctkBtPO : pcMain.ActivePage := tabBT;
ctkMtpPO : pcMain.ActivePage := tabMTP;
ctkFile : pcMain.ActivePage := tabFile;
ctkFolder : pcMain.ActivePage := tabFolder;
ctkCttSchFile : ;
ctkCttSchDir : ;
ctkBlcDownDirPO : ;
ctkScrLogoPO : pcMain.ActivePage := tabLogo;
ctkBlcClipPO : pcMain.ActivePage := tabCB;
ctkScrLock : pcMain.ActivePage := tabScrLock;
end;
end;
procedure TFrmCaPolicyTaskSel.vtListFreeNode(Sender: TBaseVirtualTree;
Node: PVirtualNode);
var
pData: PTaskEnt;
begin
pData := Sender.GetNodeData(Node);
Finalize(pData^);
end;
procedure TFrmCaPolicyTaskSel.vtListGetHint(Sender: TBaseVirtualTree;
Node: PVirtualNode; Column: TColumnIndex;
var LineBreakStyle: TVTTooltipLineBreakStyle; var HintText: string);
begin
HintText := vtList.Text[Node, Column];
end;
procedure TFrmCaPolicyTaskSel.vtListGetNodeDataSize(Sender: TBaseVirtualTree;
var NodeDataSize: Integer);
begin
NodeDataSize := SizeOf(TTaskEnt);
end;
procedure TFrmCaPolicyTaskSel.vtListGetText(Sender: TBaseVirtualTree;
Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType;
var CellText: string);
var
pData: PTaskEnt;
begin
if Column = 0 then
begin
pData := Sender.GetNodeData(Node);
CellText := pData.sCaption;
end;
end;
procedure TFrmCaPolicyTaskSel.btnOkClick(Sender: TObject);
var
pNode: PVirtualNode;
pData: PTaskEnt;
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);
SelTaskKind_ := pData.Kind;
PostMessage(TWinControl(Owner).Handle, WM_CAPOLICY_DLG_OK, 0, 0);
end;
end;
end.