public override void saveState(object state) { UndoMemento memento = new UndoMemento() { State = new Computer(this.Name, this.X, this.Y, this.Width, this.Height, this.Type) }; }
public override UndoMemento changeProperty(object state) { UndoMemento memento = new UndoMemento() { State = new Computer(this.Name, this.X, this.Y, this.Width, this.Height, this.Type) }; X = x; Y = y; return(memento); }
public UndoMemento ChangeType(string type) { UndoMemento memento = new UndoMemento() { State = new TypeClass() { type = this.Type }, Command = new Action <object>(UndoChangeType) }; Type = type; return(memento); }
public UndoMemento ChangeSize(double width, double height) { UndoMemento memento = new UndoMemento() { State = new Size() { Width = this.Width, Height = this.Height }, Command = new Action <object>(UndoChangeSize) }; Width = width; Height = height; return(memento); }
// The method to change the object state and perform operation but also externalize the previous state public UndoMemento ChangePosition(double x, double y) { UndoMemento memento = new UndoMemento() { State = new Position() { X = this.X, Y = this.Y }, Command = new Action <object>(UndoChangePosition) }; X = x; Y = y; return(memento); }
public void swapUndo() { //Debug.Log("swapUndo:" + objectToUndo.name); //Debug.Log(oppositeUndoMemento == null); if (oppositeUndoMemento == null) { oppositeUndoMemento = createMementoFunc(); oppositeUndoMemento.save(objectToUndo); } undoMemento.restore(objectToUndo); var lTemp = undoMemento; undoMemento = oppositeUndoMemento; oppositeUndoMemento = lTemp; //Debug.Log(oppositeUndoMemento == null); }
public UndoObject(Object pObjectToUndo, System.Func<UndoMemento> pCreateMementoFunc) { //Debug.Log("UndoObject:" + pObjectToUndo.name); createMementoFunc = pCreateMementoFunc; objectToUndo = pObjectToUndo; undoMemento = createMementoFunc(); undoMemento.save(objectToUndo); oppositeUndoMemento = null; }