internal void saveCommand(Command cmd, FlowChart flowChart) { if (maxDepth == 0 || !flowChart.confirmRecordAction(cmd)) { cmd.freeUndoResources(); return; } if (currCmd < commands.Count - 1) { for (int i = currCmd + 1; i < commands.Count; ++i) { commands[i].freeRedoResources(); } commands.RemoveRange(currCmd + 1, commands.Count - currCmd - 1); } commands.Add(cmd); currCmd++; if (commands.Count > maxDepth) { commands[0].freeUndoResources(); commands.RemoveAt(0); currCmd--; } flowChart.fireActionRecorded(cmd); }