undoC.add (comd); comd.Execute (); redoC.add(comd); comd.Execute();}
public void paintHandler(object sender, PaintEventArgs e) {
Graphics g = e.Graphics ; blueC.draw(g); redC.draw (g); }
[STAThread]
static void Main(){
Application.Run(new Form1());} Command:
public interface Command { void Execute(); void Undo(); void Redo(); bool isUndo(); bool isRedo();}
public class UndoComd:Command { public static ArrayList undolist; public UndoComd(){
undolist = new ArrayList();} public void add(Command comd) { if(! comd.isUndo ()) {
undolist.Add(comd);}} public bool isUndo() { return true;} public void Undo() { } public void Execute() { int unIndex =undolist.Count - 1; if (unIndex >= 0){
Command cmd = (Command)undolist[unIndex]; cmd.Undo();
RedoComd.redolist = new ArrayList(); RedoComd.redolist.Add(cmd); undolist.Remove(unIndex);}}} public class RedoComd:Command { public static ArrayList redolist; public RedoComd(){
redolist = new ArrayList();} public void add(Command comd) { if(! comd.isRedo ()) {
redolist.Add(comd);}} public bool isRedo() {