写一个类,在每个文档里new 一个,然后名字用子文档名字,

解决方案 »

  1.   

    public class UndoAgent
    {
    public delegate void ActUndoEventHandler(object sender,ActUndoEventArgs e); public class ActUndoEventArgs:EventArgs
    {
    public ActUndoEventArgs(object document,object action)
    {
    this.Document=document;
    this.Action=action;
    }
    public object Document=0;
    public object Action=0;
    } public event ActUndoEventHandler ActUndo=null; protected virtual void OnActUndo(ActUndoEventArgs e)
    {
    if(this.ActUndo!=null)
    this.ActUndo(this,e);
    }
    private Hashtable _buff=new Hashtable(); private ArrayList GetActions(object document)
    {
    if(!this._buff.ContainsKey(document))
    {
    this._buff.Add(document,new ArrayList());
    }
    return this._buff[document] as ArrayList; 

    }
    public virtual void Save(object document)
    {
    if(this._buff.ContainsKey(document))
    {
    this._buff.Remove(document);
    }
    }
    public virtual void Load(object document)
    {
    //.... ....
    }
    public int Do(object document,object action)
    {
    return this.GetActions(document).Add(action);
    }
    public void Undo(object document,int step)
    {
    this.Load(document);
    ArrayList actions=this.GetActions(document);
    int i=0;
    for(i=0;i<step && i<actions.Count;i++)
    {
    this.OnActUndo(new ActUndoEventArgs(document,actions[i]));
    }
    for(int k=i;k<actions.Count;k++)
    {
    actions.RemoveAt(i);
    }
    }
    }
      

  2.   

    考虑简单方便快捷的方法就是~~~~
    当当当~~~
    你把所有的多文档页面建在同一页,然后挨个隐藏显示~~
    复杂一点的就是把你的页面对象serialize串行化后存在Buffer(很久没研究CS了:(,可能不是Buffer)里,到时候挨个反串行化就Ok了!!
    不知道你听明白没有???厚厚~~~