public void StackWithNextCommand(IStackableCommand nextCommand) { var next = nextCommand as Class1; if (next != null) { NextNum = next.NextNum; } }
private bool StackCommand(ICommand myAction) { //get the previous item off the stack if (UndoStack.Count > 0) { //check if the previous item is stackable IStackableCommand prevStackable = UndoStack.Last.Value as IStackableCommand; if (null != prevStackable) { //check if the previous and current item can be stacked var nextStackable = myAction as IStackableCommand; if (prevStackable.CompareWithNextCommand(nextStackable)) { //stack the previous and current item and execute it prevStackable.StackWithNextCommand(nextStackable); return(prevStackable.Execute()); } } } return(false); }
public bool CompareWithNextCommand(IStackableCommand nextCommand) { var next = nextCommand as Class1; return(next != null && next._num.Name == _num.Name); }