TRVStyleTemplateCollection : SaveToStreamRVST, LoadFromStreamRVST
Posted: Tue May 12, 2020 10:53 pm
Hi Sergey,
can you add something like that in TRVStyleTemplateCollection?
function TRVStyleTemplateCollection.SaveToStreamRVST(Stream: TStream; Units: TRVStyleUnits): Boolean;
var
ini: TMemIniFile;
begin
Result := False;
try
ini := TMemIniFile.Create(Stream, TEncoding.UTF8);
try
ini.EraseSection(STYLETEMPLATEINISECTION);
SaveToINI(ini, STYLETEMPLATEINISECTION);
ini.WriteInteger(STYLETEMPLATEINISECTION, RVINI_UNITS, Ord(Units));
ini.UpdateFile;
finally
ini.Free;
end;
Result := True;
except
end;
end;
function TRVStyleTemplateCollection.LoadFromStreamRVST(Stream: TStream; Units: TRVStyleUnits; ARVStyle: TRVStyle = nil): Boolean;
var
ini: TMemIniFile;
FileUnits: TRVStyleUnits;
begin
Result := False;
try
ini := TMemIniFile.Create(Stream, TEncoding.UTF8);
try
LoadFromINI(ini, STYLETEMPLATEINISECTION);
FileUnits := TRVStyleUnits(ini.ReadInteger(STYLETEMPLATEINISECTION,
RVINI_UNITS, Ord(rvstuPixels)));
UpdateReferences;
finally
ini.Free;
end;
if FileUnits <> Units then
begin
if ARVStyle = nil then
ARVStyle := FOwner as TRVStyle;
ConvertToDifferentUnits(ARVStyle, FileUnits, Units);
end;
Result := True;
except
end;
end;
For now I add this code manually in every engine update. It would be great to see this methods in next release of TRichView
can you add something like that in TRVStyleTemplateCollection?
function TRVStyleTemplateCollection.SaveToStreamRVST(Stream: TStream; Units: TRVStyleUnits): Boolean;
var
ini: TMemIniFile;
begin
Result := False;
try
ini := TMemIniFile.Create(Stream, TEncoding.UTF8);
try
ini.EraseSection(STYLETEMPLATEINISECTION);
SaveToINI(ini, STYLETEMPLATEINISECTION);
ini.WriteInteger(STYLETEMPLATEINISECTION, RVINI_UNITS, Ord(Units));
ini.UpdateFile;
finally
ini.Free;
end;
Result := True;
except
end;
end;
function TRVStyleTemplateCollection.LoadFromStreamRVST(Stream: TStream; Units: TRVStyleUnits; ARVStyle: TRVStyle = nil): Boolean;
var
ini: TMemIniFile;
FileUnits: TRVStyleUnits;
begin
Result := False;
try
ini := TMemIniFile.Create(Stream, TEncoding.UTF8);
try
LoadFromINI(ini, STYLETEMPLATEINISECTION);
FileUnits := TRVStyleUnits(ini.ReadInteger(STYLETEMPLATEINISECTION,
RVINI_UNITS, Ord(rvstuPixels)));
UpdateReferences;
finally
ini.Free;
end;
if FileUnits <> Units then
begin
if ARVStyle = nil then
ARVStyle := FOwner as TRVStyle;
ConvertToDifferentUnits(ARVStyle, FileUnits, Units);
end;
Result := True;
except
end;
end;
For now I add this code manually in every engine update. It would be great to see this methods in next release of TRichView