示例#1
0
    private void Did(IUndoRedo iur)
    {
        try
        {
            m_UndoStack.Push(iur);
            m_RedoStack.Clear();
        }
        catch (System.Exception ex)
        {
            DebugUtility.ShowExceptionMessageBox("添加撤销操作失败", ex);
        }
        DoSomething(this, new DoSomethingEventArgs(DoEventType.Did, iur.GetDoType()));

        // 暂时不处理 Stack超出上限
        //if (m_UndoStack.Count >= GlobalData.UNDO_MAX_COUNT)
        //{
        //	Stack<IUndoRedo> undoCopyStack = new Stack<IUndoRedo>();
        //	for(int undoIdx = 0; undoIdx < GlobalData.UNDO_SAVE_COUNT; undoIdx++)
        //	{
        //		undoCopyStack.Push(m_UndoStack.Pop());
        //	}

        //	m_UndoStack.Clear();
        //	while(undoCopyStack.Count > 0)
        //	{
        //		m_UndoStack.Push(undoCopyStack.Pop());
        //	}
        //}
    }
示例#2
0
    public void Redo()
    {
        if (CanRedo())
        {
            try
            {
                m_CsvForm.BeforeChangeCellValue();
                IUndoRedo iur = m_RedoStack.Pop();
                iur.Redo(m_CsvForm.GetDataGridView(), m_CsvForm.GetDataTable());
                m_UndoStack.Push(iur);
                DoSomething(this, new DoSomethingEventArgs(DoEventType.Redo, iur.GetDoType()));
                m_CsvForm.AfterChangeCellValue();

                MainForm.Instance.UpdateCellEdit();
            }
            catch (System.Exception ex)
            {
                DebugUtility.ShowExceptionMessageBox("重做失败", ex);
            }
        }
    }