public ICmd Exec() { List <ICmd> invList = new List <ICmd>(); //list to store returned inverses for (int i = 0; i < list.Count; i++) //loop through entire list { invList.Add(list[i].Exec()); //call execute function for each element in the list and add returned inverse to inverse list } var inverse = new MultiCmd(invList); //create new inverse element return(inverse); }
public void pushToUndoBGColorGroup(List <Cell> list) //push group of color changes to undo stack { List <ICmd> cmds = new List <ICmd>(); for (int i = 0; i < list.Count; i++) //loop through list of cells to create list of restore background color objects { RestoreBackgroundColor temp = new RestoreBackgroundColor(list[i], list[i].getBGColor()); cmds.Add(temp); } MultiCmd mcmd = new MultiCmd(cmds); //create new multi command object mcmd.setMessage(" change in background color of cells"); undo.Push(mcmd); //add multi command object to list }