设计器

优化保存加载
This commit is contained in:
JianjunLiu 2022-10-19 11:19:00 +08:00
parent e2cc54dcbc
commit 85d5aea39e
4 changed files with 74 additions and 35 deletions

View File

@ -861,6 +861,10 @@ type TVclDesigner = class(tvcform)
end
end
end
function isloadednode(wndnode);
begin
return fwindowinfos.getdata(wndnode);
end
function UnLoadTreeNode(wndnode); //卸载控件树
begin
{**

View File

@ -818,11 +818,21 @@ type TProjectView = class(TVCForm) //
//打开界面
FDesigner.caption := "TVCL界面设计器 "+FprojName+"->"+FCurrentOpend["name"];
FTmfParser.fssourdirs := FCurrentOpend.gettmfdirs();
FTmfParser.ScriptPath := FCurrentOpend.gettmfname();
FTfmComponets := array();
FTmfParser.GetAllSubObjects(nil,FTfmComponets);
tfm := FCurrentOpend.gettmfname();
it := FTslEditer.OpenAndGoLineByName(tfm);
if it then
begin
//FTmfParser.ScriptPath := FCurrentOpend.gettmfname();
sc := it.FEditer.text;
FTmfParser.Script := sc;
FCurrentOpend.ftfmscript := sc;
FTslEditer.CloseScriptByFileName(tfm);
//FTfmComponets := array();
//FTmfParser.GetAllSubObjects(nil,FTfmComponets);
FDesigner.LoadTreeNode(FTmfParser,inh,FCurrentOpend);
FDesigner.EditerCodeChanged();
end
end else
begin
FDesigner.ExecuteCommand("hiddrennode",nil);
@ -1070,13 +1080,16 @@ end
if ph then ph += fio;
else ph := "";
ph := cprojpath+ph+n+".tsf";
tfm := FCProjectPath+"resource.tfm"+fio+n+".tfm";
if not(FileExists("",ph))then
begin
r := CreateAForm(n);
ReWriteString(ph,r);
r := CreateAtfm(n,n);
ReWriteString((FCProjectPath+"resource.tfm"+fio+n+".tfm"),r);
ReWriteString(tfm,r);
end else //已经存在
begin
if FileExists("",tfm) then
begin
inh := getwindowinherited2(ph);
if inh = array("tdcreateform") then
@ -1090,6 +1103,7 @@ end
begin
fn["type"]:= "tsf";
end
end else fn["type"]:= "tsf";
end
FTree.SetFileToNode(fn);
SaveProjInfo();
@ -1105,13 +1119,16 @@ end
if ph then ph += fio;
else ph := "";
ph := cprojpath+ph+n+".tsf";
tfm := (FCProjectPath+"resource.tfm"+fio+n+".tfm");
if not FileExists("",ph)then
begin
r := CreateAPanel(n);
ReWriteString(ph,r);
r := CreateAtfm(n,n);
ReWriteString((FCProjectPath+"resource.tfm"+fio+n+".tfm"),r);
ReWriteString(tfm,r);
end else
begin
if FileExists("",tfm) then
begin
inh := getwindowinherited2(ph);
if inh = array("tdcreateform") then
@ -1125,6 +1142,8 @@ end
begin
fn["type"]:= "tsf";
end
end else fn["type"]:= "tsf";
end
FTree.SetFileToNode(fn);
SaveProjInfo();
@ -1341,6 +1360,10 @@ end
if not nd then nd := FCurrentOpend;
if nd then
begin
if not(FDesigner.isloadednode(nd)) then //判断是否保存
begin
return ;
end
case nd["type"]of
"form","panel":
begin
@ -1349,7 +1372,17 @@ end
if fn then
begin
tfm := FDesigner.TreeNode2tfm(lib,items,nd);
ReWriteString(fn,tfm);
if nd.ftfmscript<>tfm then //发生了改变
begin
nd.ftfmscript := tfm ;
it := FTslEditer.OpenAndGoLineByName(fn);
if it then
begin
it.FEditer.text := tfm;
FTslEditer.SaveFileByName(fn);
end
end
//ReWriteString(fn,tfm);
end
end
end;
@ -1901,6 +1934,7 @@ type TFileTree = class(TTreeCtl)
//function SetType()
FName; // a
FFType; //dir
ftfmscript;
private
function setfileinfo(v);
begin

View File

@ -589,6 +589,7 @@ type TDComponent = class()
r := array();
r["name"] := n;
r["event"] := n;
r["virtual"] := true;
r["param"] := array("o","e");
r["body"] :=
format("

View File

@ -552,7 +552,7 @@ public //
for i,vi in ps do
begin
n := vi["name"];
if ifarray(FChangedPropertiesflg) and FChangedPropertiesflg[n] then continue;
if (f<>2) and ifarray(FChangedPropertiesflg) and FChangedPropertiesflg[n] then continue;
vv := FChangedProperties[n];
if ifnil(vv)then continue;
vit := vi["type"];