undocomd.cs
来自「c#设计模式随书源码 c#设计模式随书源码」· CS 代码 · 共 39 行
CS
39 行
using System;
using System.Drawing ;
using System.Windows.Forms;
using System.Collections ;
namespace UndoCommand
{
/// <summary>
/// Summary description for UndoCommand.
/// </summary>
public class UndoComd:Command {
private 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 index = undoList.Count - 1;
if (index >= 0) {
Command cmd = (Command)undoList[index];
cmd.Undo();
undoList.RemoveAt(index);
}
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?