1
0
mirror of synced 2024-11-21 17:43:51 +00:00

Import / export GraphicContainer

This commit is contained in:
Mark van Renswoude 2013-12-30 09:33:09 +00:00
parent d3ca72b5ff
commit 231b2c42bf
2 changed files with 27 additions and 10 deletions

View File

@ -201,7 +201,7 @@ object GraphicsEditorForm: TGraphicsEditorForm
Left = 20 Left = 20
Top = 360 Top = 360
Bitmap = { Bitmap = {
494C010107000900040010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600 494C010107000900080010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
0000000000003600000028000000400000002000000001002000000000000020 0000000000003600000028000000400000002000000001002000000000000020
0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000

View File

@ -466,6 +466,7 @@ var
index: Integer; index: Integer;
graphic: TX2GraphicContainerItem; graphic: TX2GraphicContainerItem;
fileName: string; fileName: string;
startIndex: Integer;
begin begin
if dlgImport.Execute then if dlgImport.Execute then
@ -476,8 +477,21 @@ begin
exit; exit;
end; end;
{ Items inherited from the ancestor through visual inheritance can not
be deleted. Start at the first one introduced at this level. }
startIndex := 0;
while (startIndex < FComponent.GraphicCount) and (csAncestor in FComponent.Graphics[startIndex].ComponentState) do
Inc(startIndex);
lstGraphics.Clear; lstGraphics.Clear;
FComponent.Clear;
if startIndex = 0 then
FComponent.Clear
else
begin
for index := Pred(FComponent.GraphicCount) downto startIndex do
FComponent.Graphics[index].Free;
end;
importPath := ExtractFilePath(dlgImport.FileName); importPath := ExtractFilePath(dlgImport.FileName);
importFile := TIniFile.Create(dlgImport.FileName); importFile := TIniFile.Create(dlgImport.FileName);
@ -486,16 +500,19 @@ begin
while importFile.ValueExists('PictureName', IntToStr(index)) do while importFile.ValueExists('PictureName', IntToStr(index)) do
begin begin
graphic := TX2GraphicContainerItem(FComponentDesigner.CreateComponent(TX2GraphicContainerItem, nil, 0, 0, 0, 0)); if index >= startIndex then
if Assigned(graphic) then
begin begin
graphic.Container := FComponent; graphic := TX2GraphicContainerItem(FComponentDesigner.CreateComponent(TX2GraphicContainerItem, nil, 0, 0, 0, 0));
graphic.PictureName := importFile.ReadString('PictureName', IntToStr(index), IntToStr(index));
fileName := importFile.ReadString('FileName', IntToStr(index), ''); if Assigned(graphic) then
if (Length(fileName) > 0) and FileExists(importPath + fileName) then begin
graphic.Picture.LoadFromFile(importPath + fileName); graphic.Container := FComponent;
graphic.PictureName := importFile.ReadString('PictureName', IntToStr(index), IntToStr(index));
fileName := importFile.ReadString('FileName', IntToStr(index), '');
if (Length(fileName) > 0) and FileExists(importPath + fileName) then
graphic.Picture.LoadFromFile(importPath + fileName);
end;
end; end;
Inc(index); Inc(index);