ImageEn, unit imageenproc

TImageEnProc.Undo

TImageEnProc.Undo


Declaration

procedure Undo(AutoRedo: Boolean = False);


Description

Replaces the current image with the last image in the Undo stack.

Parameter Description
AutoRedo Set to true for automatic undo/redo support. Saves the current state (before undo) to the redo stack (i.e. calls SaveRedo is called) and removes this entry from the Undo stack (i.e. using ClearUndo)




Demo

Demo  Demos\ImageEditing\UndoRedo\UndoRedo.dpr


Example

// Multiple Undo/Redo Example

procedure TForm1.FormCreate(Sender: TObject);
begin
  ImageEnView1.Proc.UndoLimit := 20; // 20 levels of undo
end;

procedure TForm1.ImageEnView1ImageChange(Sender: TObject);
begin
  // When image changes update our menu items
  UpdateMenu;
end;

procedure TForm1.Undo1Click(Sender: TObject);
begin
  // Undo (with automatic saving of redo)
  ImageEnView1.Proc.Undo( True );
  UpdateMenu;
end;

procedure TForm1.Redo1Click(Sender: TObject);
begin
  // Redo (with automatic saving of undo)
  ImageEnView1.Proc.Redo( True );
  UpdateMenu;
end;

procedure TForm1.UpdateMenu;
begin
  // Undo menu
  Undo1.Enabled := ImageEnView1.Proc.CanUndo;
  if ImageEnView1.Proc.CanUndo then
    Undo1.Caption := 'Undo ' + ImageEnView1.Proc.UndoCaptions[0]
  else
    Undo1.Caption := 'Undo';

  // Redo menu
  Redo1.Enabled := ImageEnView1.Proc.CanRedo;
  if ImageEnView1.Proc.CanRedo then
    Redo1.Caption := 'Redo ' + ImageEnView1.Proc.RedoCaptions[0]
  else
    Redo1.Caption := 'Redo';
end;


Compatibility Information

In v6.2.1 and older versions, AutoRedo did not remove the undone item from the Undo List. From v6.3.0, AutoRedo clears the entries.
To return to the older functionality, enable the IEUseLegacyUndoFunctionality define in ie.inc


See Also

Published Property  AutoUndo
Public Property  CanUndo
Public Method  ClearAllUndo
Public Method  ClearUndoAt
Public Method  ClearUndo
Public Method  GetUndoInfo
Public Method  SaveUndo
Public Method  UndoAt
Public Property  UndoCaptions
Public Property  UndoCount
Published Property  UndoLimit
Public Property  UndoLocation
Public Method  UndoRect
Public Method  OnSaveUndo
Public Method  Redo