📄 vismain.pas
字号:
Result:=(p<>nil);
FreeLibrary(DLLHandle);
end;
procedure TMainForm.TestVisParent(Node : TTreeNode;index : integer);
var
i,cnt : integer;
begin
cnt:=0;
for i:=0 to Node.Count-1 do begin
if FVisPlugInList[index].Enables[i] then begin
Node[i].ImageIndex:=1;
Node[i].SelectedIndex:=1;
inc(cnt);
end
else begin
Node[i].ImageIndex:=3;
Node[i].SelectedIndex:=3;
end;
end;
if cnt>=FVisPlugInList[index].Count then begin
Node.ImageIndex:=0;
Node.SelectedIndex:=0;
end
else if cnt=0 then begin
Node.ImageIndex:=3;
Node.SelectedIndex:=3;
end
else begin
Node.ImageIndex:=2;
Node.SelectedIndex:=2;
end;
end;
procedure TMainForm.SearchPlugIn;
var
done : integer;
Rec : TSearchRec;
s : string;
i,n : integer;
Node,Nd : TTreeNode;
function IndexOfNode(Str : string) : TTreeNode;
var
j : integer;
begin
Result:=nil;
for j:=0 to TreeView1.Items.Count-1 do begin
if (TreeView1.Items[j].Parent=nil) and (TreeView1.Items[j].Text=Str) then begin
Result:=TreeView1.Items[j];
exit;
end;
end;
end;
begin
TreeView1.Items.BeginUpdate;
try
for i:=TreeView1.Items.Count-1 downto 0 do begin
if TreeView1.Items[i].Count<=0 then TreeView1.Items[i].Delete;
end;
s:=DirectoryEdit1.LongName;
if s<>'' then begin
if s[Length(s)]<>'\' then s:=s+'\';
done:=FindFirst(s+'vis_*.dll',faAnyFile,Rec);
while done=0 do begin
if IsPlugInFile(s+Rec.Name) then begin
if IndexOfNode(s+Rec.Name)=nil then begin
Node:=TreeView1.Items.AddChild(nil,s+Rec.Name);
Node.ImageIndex:=3;
Node.SelectedIndex:=3;
Node.Data:=Pointer(-1);
end;
end;
done:=FindNext(Rec);
end;
end;
FindClose(Rec);
for i:=0 to Length(FVisPlugInList)-1 do begin
Node:=IndexOfNode(FVisPlugInList[i].DLLName);
if Node=nil then Node:=TreeView1.Items.AddChild(nil,FVisPlugInList[i].DLLName);
Node.Data:=Pointer(i);
if Node.Count<=0 then begin
for n:=0 to FVisPlugInList[i].Count-1 do begin
Nd:=TreeView1.Items.AddChild(Node,StrPas(FVisPlugInList[i].Modules[n].description));
Nd.Data:=Pointer(n);
Nd.ImageIndex:=1;
end;
end;
TestVisParent(Node,i);
end;
finally
TreeView1.Items.EndUpdate;
end;
end;
procedure TMainForm.ShowPlugInError;
begin
ShowMessage('敲矾弊牢俊辑 坷幅啊 惯积沁嚼聪促.');
end;
procedure TMainForm.EnabledVisPlugIn(DLLName: string;Index : integer;Flag: Boolean);
var
ii : integer;
begin
try
ii:=AddVisPlugInList(DLLName);
if (Index<=Length(FVisPlugInList[ii].Enables)-1) and
(FVisPlugInList[ii].Enables[Index]<>Flag) then begin
FVisPlugInList[ii].Enables[Index]:=Flag;
if Flag then begin
try
if Assigned(FVisPlugInList[ii].Modules[Index]^.Init) then
FVisPlugInList[ii].Modules[Index]^.Init(FVisPlugInList[ii].Modules[Index]);
except
ShowPlugInError;
end;
end
else begin
try
if Assigned(FVisPlugInList[ii].Modules[Index]^.Quit) then
FVisPlugInList[ii].Modules[Index]^.Quit(FVisPlugInList[ii].Modules[Index]);
except
ShowPlugInError;
end;
end;
end;
except
ShowPlugInError;
end;
end;
procedure TMainForm.TreeView1MouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
Node : TTreeNode;
ht : THitTests;
i,ii : integer;
Nd : TTreeNode;
begin
ht:=TTreeView(Sender).GetHitTestInfoAt(X,Y);
Node:=TTreeView(Sender).GetNodeAt(X,Y);
if (Node<>nil) then begin
if (Node.Parent=nil) and (Node.Count<=0) then begin
ii:=AddVisPlugInList(Node.Text);
Node.Data:=Pointer(ii);
if ii>=0 then begin
for i:=0 to FVisPlugInList[ii].Count-1 do begin
Nd:=TTreeView(Sender).Items.AddChild(Node,StrPas(FVisPlugInList[ii].Modules[i].description));
Nd.ImageIndex:=3;
Nd.SelectedIndex:=3;
Nd.Data:=Pointer(i);
end;
end;
end;
if (htOnIcon in ht) then begin
if Node.Parent=nil then begin
if Node.ImageIndex<>3 then begin
Node.ImageIndex:=3;
Node.SelectedIndex:=3;
ii:=IndexofVisPlugInList(Node.Text);
for i:=0 to FVisPlugInList[ii].Count-1 do begin
EnabledVisPlugIn(Node.Text,i,False);
if Node.Count>i then begin
Node.Item[i].ImageIndex:=3;
Node.Item[i].SelectedIndex:=3;
end;
end;
end;
end
else begin
if Node.ImageIndex=3 then begin
Node.ImageIndex:=1;
Node.SelectedIndex:=1;
EnabledVisPlugIn(Node.Parent.Text,Integer(Node.Data),True);
end
else begin
Node.ImageIndex:=3;
Node.SelectedIndex:=3;
EnabledVisPlugIn(Node.Parent.Text,Integer(Node.Data),False);
end;
ii:=AddVisPlugInList(Node.Parent.Text);
TestVisParent(Node.Parent,ii);
end;
end;
end;
end;
procedure TMainForm.TreeView1AdvancedCustomDrawItem(
Sender: TCustomTreeView; Node: TTreeNode; State: TCustomDrawState;
Stage: TCustomDrawStage; var PaintImages, DefaultDraw: Boolean);
var
r : TRect;
s : string;
ii : integer;
begin
if (Node.Parent=nil) and (Node.Count>0) and (Stage=cdPostPaint) then begin
ii:=integer(Node.Data);
if ii>=0 then begin
s:=StrPas(FVisPlugInList[ii].Header.description);
s:=' '+s+'['+ExtractFileName(Node.Text)+']';
r:=Node.DisplayRect(True);
inc(r.Right,300);
Sender.Canvas.FillRect(r);
if not(cdsSelected in State) then Sender.Canvas.Font.Color:=clRed;
DrawText(Sender.Canvas.Handle,pchar(s),Length(s),r,DT_VCENTER or DT_SINGLELINE);
DefaultDraw:=False;
end;
end;
end;
procedure TMainForm.TreeView1CustomDrawItem(Sender: TCustomTreeView;
Node: TTreeNode; State: TCustomDrawState; var DefaultDraw: Boolean);
begin
if not(cdsSelected in State) then begin
if Node.Parent=nil then Sender.Canvas.Font.Color:=clBlue
else Sender.Canvas.Font.Color:=clBlack;
end;
end;
procedure TMainForm.SetupVisPlugIn(DLLName: string;Index : integer);
var
ii : integer;
begin
try
ii:=AddVisPlugInList(DLLName);
if (Index<=FVisPlugInList[ii].Count-1) then begin
if Assigned(FVisPlugInList[ii].Modules[Index]^.Config) then
FVisPlugInList[ii].Modules[Index]^.Config(FVisPlugInList[ii].Modules[Index]);
end;
except
ShowPlugInError;
end;
end;
procedure TMainForm.TreeView1DblClick(Sender: TObject);
var
name : string;
ii : integer;
begin
if (TTreeView(Sender).Selected<>nil) and (TTreeView(Sender).Selected.Parent<>nil) then begin
ii:=integer(TTreeView(Sender).Selected.Data);
name:=TTreeView(Sender).Selected.Parent.Text;
SetupVisPlugIn(name,ii);
end;
end;
procedure TMainForm.FreeVisPlugIn;
var
i,j : integer;
PlugIn : TVisPlugInList;
begin
PlugIn:=FVisPlugInList;
FVisPlugInList:=nil;
for i:=0 to Length(PlugIn)-1 do begin
for j:=0 to Length(PlugIn[i].Enables)-1 do begin
if (PlugIn[i].Enables[j]) then begin
try
if Assigned(PlugIn[i].Modules[j]^.Quit) then
PlugIn[i].Modules[j]^.Quit(PlugIn[i].Modules[j]);
except
end;
end;
end;
FreeLibrary(PlugIn[i].DLLHandle);
PlugIn[i].Modules:=nil;
PlugIn[i].Enables:=nil;
end;
end;
procedure TMainForm.SaveVisPlugIn(sName: string);
var
i,j : integer;
bb : Boolean;
begin
FReg.DeleteKey(sRegistryKey+sVisPlugKey+'\'+sName);
if FReg.OpenKey(sRegistryKey+sVisPlugKey+'\'+sName,True) then begin
for i:=0 to Length(FVisPlugInList)-1 do begin
FReg.CloseKey;
bb:=False;
if FReg.OpenKey(sRegistryKey+sVisPlugKey+'\'+sName+'\'+IntToStr(i),True) then begin
FReg.WriteString('',FVisPlugInList[i].DLLName);
for j:=0 to Length(FVisPlugInList[i].Enables)-1 do begin
FReg.WriteBool(IntToStr(j),FVisPlugInList[i].Enables[j]);
if FVisPlugInList[i].Enables[j] then bb:=True;
end;
FReg.CloseKey;
end;
if bb=False then FReg.DeleteKey(sRegistryKey+sVisPlugKey+'\'+sName+'\'+IntToStr(i));
end;
FReg.CloseKey;
end;
end;
procedure TMainForm.LoadVisPlugIn(sName: string);
var
i,j : integer;
List : TStringList;
ss : string;
begin
FreeVisPlugIn;
List:=TStringList.Create;
try
FReg.RootKey:=HKEY_CURRENT_USER;
if FReg.KeyExists(sRegistryKey+sVisPlugKey+'\'+sName) then begin
if FReg.OpenKey(sRegistryKey+sVisPlugKey+'\'+sName,False) then begin
FReg.GetKeyNames(List);
for i:=0 to List.Count-1 do begin
FReg.CloseKey;
if FReg.OpenKey(sRegistryKey+sVisPlugKey+'\'+sName+'\'+List[i],False) then begin
ss:=FReg.ReadString('');
AddVisPlugInList(ss);
j:=0;
while True do begin
if FReg.ValueExists(IntToStr(j)) then EnabledVisPlugIn(ss,j,FReg.ReadBool(IntToStr(j)))
else break;
inc(j);
end;
FReg.CloseKey;
end;
end;
FReg.CloseKey;
end;
end;
finally
List.Free;
end;
end;
procedure TMainForm.DirectoryEdit1Change(Sender: TObject);
begin
SearchPlugIn;
end;
procedure TMainForm.Button1Click(Sender: TObject);
begin
FreeVisPlugIn;
SearchPlugIn;
end;
procedure TMainForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
RxTrayIcon1.Active:=True;
end;
procedure TMainForm.RxTrayIcon1Click(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
RxTrayIcon1.Active:=False;
Show;
end;
procedure TMainForm.SpinEdit1Change(Sender: TObject);
begin
FFrameRate:=SpinEdit1.Value;
end;
procedure TMainForm.CheckBox1Click(Sender: TObject);
begin
FUsePlugIn:=TCheckBox(Sender).Checked;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -