public PropertyCommand(ElementList elements, Controller controller) : base(controller) { _elements = elements; _momentos = new List <ElementMomento>(); //Loop through and add a momento for each element foreach (Element element in elements) { ElementMomento momento = new ElementMomento(element); _momentos.Add(momento); } }
private void UndoRedo() { int index = 0; //Loop through each element and write the contents of the matching momento back into the element foreach (Element element in Elements) { //Get a momento of the element in its current state ElementMomento momento = new ElementMomento(element); //Write the momento into the element and save the new momento _momentos[index].WriteItem(element); _momentos[index] = momento; index++; } }