ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 SaveUndo not redoing more than 2 saveUndo's
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

PietH

South Africa
10 Posts

Posted - Oct 27 2012 :  09:37:21  Show Profile  Reply
Hello,
I saveundo like this every time the mouse on the ImageEnView1 is down. This is when something is done on the image. I have a counter to number each saveundo.

ImageEnProc1.SaveUndo(ieuImage);
UndoCnt:=UndoCnt+1;

The Undo code is this:
ImageEnProc1.UndoAt(UndoCnt);
UndoCnt:=UndoCnt-1;

Problem:
I make several edits to the image, then select undo. It undoes the last edit. When I press the Undo button again it undoes all the edits. If I keep pressing the undo button it looks like it redoes earlier edits. Strange.

I tried to just Undo with ImageEnProc1.Undo(True); but this only redoes the last edit. Pressing Undo button again has no effect. I want to undo at least 10 SaveUndo's.

How do I do this?
thanks and regards
Piet

Kind regards
Piet Henning

PietH

South Africa
10 Posts

Posted - Oct 27 2012 :  12:12:50  Show Profile  Reply
I got it.
The SaveUndo is working a "upside-down" The last Save Undo is always 0, then 1,2 etc. It work on a stacked list with the latest at the bottom.

Code is now this:
OnMouseDownevent:
ImageEnProc1.SaveUndo(ieuImage);
UndoCnt:=0;

UndoButtonClick:
ImageEnProc1.UndoAt(UndoCnt,true);
UndoCnt:=UndoCnt+1;

ImageEN, please add this type of undo to your UndoRedo sample.
I still need to figger out hoe to redo more than just the last undone step.

Kind regards
Piet Henning
Go to Top of Page

w2m

USA
1990 Posts

Posted - Oct 27 2012 :  16:09:04  Show Profile  Reply
You may have reached the undo limit.
procedure TForm1.FormCreate(Sender: TObject);
  // Set AutoUndo to False;
  ImageEnView1.Proc.AutoUndo := False;
  // The UndoLimit default is only 5 so only 5 undos are possible so
  // increase the UndoLimit  
  ImageEnView1.Proc.UndoLimit := 99;
end;

procedure TForm1.Cut1Click(Sender: TObject);
// SaveUndo then SelCutToClip
begin
  ImageEnView1.Proc.SaveUndoCaptioned('Cut ' + IntToStr(ImageEnView1.Proc.UndoCount + 1));
  Undo1.Hint := 'Cut ' + IntToStr(ImageEnView1.Proc.UndoCount + 1);
  ImageEnView1.Proc.SelCutToClip(True);
  ImageEnView1.Update;
end;

procedure TFormMain.Undo1Click(Sender: TObject);
// undo the last change
begin
  // Save in Redo list
  ImageEnView1.Proc.SaveRedo();
  ImageEnView1.Proc.Undo;
  ImageEnView1.Proc.ClearUndo;
  Undo1.Enabled := ImageEnView1.Proc.CanUndo;
  Redo1.Enabled := ImageEnView1.Proc.CanRedo;
end;

William Miller
Adirondack Software & Graphics
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: