Page 1 of 1

Add recto verso option to simplegraph

PostPosted: October 27th, 2005, 9:19 am
by Mirage
Hello!

Please give me solution to add the option of recto and verso to simplegraph.
:cry:

PostPosted: October 28th, 2005, 11:13 am
by Kambiz
Seems you should use two instances of SimpleGraph.

Could you please explain more about your purpose?

Add recto verso option to simplegraph

PostPosted: October 31st, 2005, 8:49 am
by Mirage
Kambiz Hello!
Thank you for your answer!

I wants to add two SimpleGraph one to draw in recto and the other to draw in back I have a problem when I make the save. Please give me a method for save 2 SimpleGraph in only one file.
Thank you in advance! :wink:

PostPosted: October 31st, 2005, 4:33 pm
by Kambiz
Hi,

You have to use a stream to save graphs in to the stream, then save stream in the file.

Cheers

Add recto verso option to simplegraph

PostPosted: November 1st, 2005, 7:33 am
by Mirage
Kambiz Hello!

Thank you for your answer!
Please given me a method of use of Stream.
I do not know how not used.

Thank you in advance Mr. Kambiz. :roll:

PostPosted: November 1st, 2005, 9:53 am
by Kambiz
Here are two procedures for saving/loading multiple graphs to/from a single file.

Code: Select all
procedure SaveMutipleGraphs(const FileName: String; Graphs: array of TSimpleGraph);
var
  Stream: TFileStream;
  I: Integer;
begin
  Stream := TFileStream.Create(FileName, fmCreate or fmShareExclusive);
  try
    for I := Low(Graphs) to High(Graphs) do
      Graphs[I].SaveToStream(Stream);
  finally
    Stream.Free;
  end;
end;

procedure LoadMutipleGraphs(const FileName: String; Graphs: array of TSimpleGraph);
var
  Stream: TFileStream;
  I: Integer;
begin
  Stream := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite);
  try
    for I := Low(Graphs) to High(Graphs) do
      Graphs[I].LoadFromStream(Stream);
  finally
    Stream.Free;
  end;
end;

Here is an example of usage:

Code: Select all
procedure TMainForm.btnSaveClick(Sender: TObject);
begin
  SaveMutipleGraphs('C:\TEST.MG', [SimpleGraph1, SimpleGraph2]);
end;

procedure TMainForm.btnLoadClick(Sender: TObject);
begin
  LoadMutipleGraphs('C:\TEST.MG', [SimpleGraph1, SimpleGraph2]);
end;

Cheers

Add recto verso option to simplegraph

PostPosted: November 1st, 2005, 10:48 am
by Mirage
Thank you, thank you, thank you, thank you for you Kambiz!
You solved me a major problem.
Thank you, thank you, thank you, thank you for my Allah god!

PostPosted: November 2nd, 2005, 9:31 am
by lbc
great job
thank you Kambiz