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
 Undo events?
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

PeterPanino

859 Posts

Posted - Sep 14 2017 :  04:19:18  Show Profile  Reply
When the user has returned to the beginning of the Undo chain by doing repeated Undo (so there are not any more changes left to Undo), how can I get notified?

There are no Undo events in TImageEnView to notify me about the current position in the Undo chain when the user undoes a change.

Generally, I prefer being notified instead of having to ask.

w2m

USA
1990 Posts

Posted - Sep 14 2017 :  10:09:09  Show Profile  Reply
procedure TForm1.UndoClick(Sender: TObject);
begin
  If ImageEnView1.Proc.CanUndo then
  begin
    ImageEnView1.Proc.Undo;
    ImageEnView1.Proc.ClearUndo;
  else
    ShowMessage('Nothing to Undo!');
end;

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
Go to Top of Page

PeterPanino

859 Posts

Posted - Sep 14 2017 :  12:35:08  Show Profile  Reply
Bill, thank you for the answer.

I strongly suggest implementing an EVENT OnUndoRedo which contains as parameters:

• UndoAction: Boolean (if True, the user has made an Undo, if False, the user has made a Redo)

• var UndoPos: Integer (current position in the Undo chain; if 0, there is nothing to Undo)

This is much better and more efficient and more logical and more useful than having explicitly to ask for this information!

PLEASE!
Go to Top of Page

xequte

38176 Posts

Posted - Sep 14 2017 :  22:26:29  Show Profile  Reply
Hi

I'll add an OnUndoRedo event in the next update, but you can just use the OnImageChange event:

procedure TForm1.ImageEnView1ImageChange(Sender: TObject);
begin
  // Update status of buttons
  btnSave.Enabled := ImageEnView1.IEBitmap.Modified;
  btnUndo.Enabled := ImageEnView1.Proc.CanUndo;
  btnRedo.Enabled := ImageEnView1.Proc.CanRedo;
end;



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

PeterPanino

859 Posts

Posted - Sep 16 2017 :  16:05:02  Show Profile  Reply
Hi Nigel,

1. any Undo de facto calls the OnImageChange event-handler TWICE which is inefficient and could lead to logical contradictions (if you do other things in this event-handler).

2. Also the fact that both image-processings and Undo call the OnImageChange event-handler could lead to logical contradictions and thus unwanted effects.

Considering this I think an OnUndoRedo event would make sense because it would allow reacting only to changes in the Undo chain and thus handling these changes more consistently.
Go to Top of Page

xequte

38176 Posts

Posted - Sep 17 2017 :  20:13:53  Show Profile  Reply
Hi Peter

I cannot reproduce the duplicate OnImageChange call. Can you give me more info.

You can email us for a pre-release which includes OnUndoRedo.



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

PeterPanino

859 Posts

Posted - Sep 18 2017 :  09:01:36  Show Profile  Reply
I work with CodeSite which gives me an exact feedback from what happens at run-time.

1. Place a CodeSite.Send in the OnImageChange event-handler:

procedure TFormMain.imgImportEditorImageChange(Sender: TObject);
begin
  CodeSite.Send('TFormMain.imgImportEditorImageChange: test');  
end;


2. Then I press Ctrl-Z (on my German keyboard) ONCE to Undo a previous Edit action.

3. In the CodeSite Live Viewer you can see that the OnImageChange event-handler has been called twice (in a time-distance of 3 milliseconds):

Go to Top of Page

xequte

38176 Posts

Posted - Sep 18 2017 :  16:50:13  Show Profile  Reply
Hi

Ctrl-Z? So, are you using a TImageEnViewUndo action?

What type of method is being undone?





Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: