Hi Lawson,
This is rajesh from india I am also implementing the Undo/Redo control to our designer. I am also getting the same problem as you and inaddition to that i am not able to perform undo action after performing the delete and cut. If you able to perform undo on delete and cut please give me your
UndoEnine class implementation code please send me as early as possible because i need it very much.
and my UndoEngine class implementation is like this
public
class UndoEngineService : UndoEngine
{
List<UndoEngine.UndoUnit> undoUnitList = new List<UndoUnit>();
// points to the command that should be executed for Redo
int currentPos = 0;
public UndoEngineService(IServiceProvider provider) : base(provider)
{
}
public void DoUndo()
{
if (currentPos > 1)
{
UndoEngine.UndoUnit undoUnit = undoUnitList[currentPos-1];
undoUnit.Undo();
currentPos--;
}
UpdateUndoRedoMenuCommandsStatus();
}
public void DoRedo()
{
if (currentPos < undoUnitList.Count)
{
UndoEngine.UndoUnit undoUnit = undoUnitList[currentPos];
undoUnit.Undo();
currentPos++;
}
UpdateUndoRedoMenuCommandsStatus();
}
private void UpdateUndoRedoMenuCommandsStatus()
{
// this components maybe cached.
MenuCommandService menuCommandService = GetService(typeof(MenuCommandService)) as MenuCommandService;
MenuCommand undoMenuCommand = menuCommandService.FindCommand(StandardCommands.Undo);
MenuCommand redoMenuCommand = menuCommandService.FindCommand(StandardCommands.Redo);
if (undoMenuCommand != null)
undoMenuCommand.Enabled = currentPos > 0;
if (redoMenuCommand != null)
redoMenuCommand.Enabled = currentPos <
this.undoUnitList.Count;
}
protected override void AddUndoUnit(UndoEngine.UndoUnit unit)
{
undoUnitList.RemoveRange(currentPos, undoUnitList.Count - currentPos);
undoUnitList.Add(unit);
currentPos = undoUnitList.Count;
}
public static int myNumber = 0;
protected override UndoEngine.UndoUnit CreateUndoUnit(string name, bool primary)
{
return base.CreateUndoUnit(name, primary);
}
protected override void DiscardUndoUnit(UndoEngine.UndoUnit unit)
{
undoUnitList.Remove(unit);
base.DiscardUndoUnit(unit);
}
protected override void OnUndoing(EventArgs e)
{
base.OnUndoing(e);
}
protected override void OnUndone(EventArgs e)
{
base.OnUndone(e);
}
please send me your UndoEngine class implementation to my gmail id rajesh1533@gmail.com
plese send me.
Thanks and Regards
Rajesh