Gets the UndoStack object used for undo/redo operations.

Namespace:  C1.Win.C1ReportDesigner
Assembly:  C1.Win.C1ReportDesigner.2 (in C1.Win.C1ReportDesigner.2.dll)

Syntax

Remarks

The UndoStack allows you to save the state of the designer and restore it on demand.

The UndoStack is used internally by the designer control. For example, when the user moves a group of fields with the mouse, the control automatically saves the state of the report before the change so it can be undone.

Before changing the report using code, you should also save the state of the control by calling the SaveState()()()() method.

Examples

The code below shows how to use the SaveState()()()() method to save the report state before performing clipboard operations such as Cut, Paste, and Delete.
Copy CodeC#
// handle clipboard commands (for reports and fields)
private void HandleClipboard(ToolBarButton cmd)
{
    // save undo state for all but copy
    if (cmd != _btnCopy)
    {
        _designer.UndoStack.SaveState();
        _dirty = true;
    }

    // execute command
    ClipboardHandler clip = _designer.ClipboardHandler;
    if (cmd == _btnCut)    clip.Cut();
    if (cmd == _btnCopy)   clip.Copy();
    if (cmd == _btnPaste)  clip.Paste();
    if (cmd == _btnDelete) clip.Delete();

    // update UI when done
    UpdateUI();
}

Note that after performing the action, the code calls an UpdateUI method. This method is implemented by the application to update the enabled state of several UI elements and indicate to the user whether he can perform operations such as Undo/Redo, Cut/Copy/Paste, etc.

Here is a simple implementation of a UpdateUI method in a report designer application.

Copy CodeC#
// update UI (_menus, toolbars, etc)
private void UpdateUI()
{
    _btnUndo.Enabled   = _designer.UndoStack.CanUndo;
    _btnRedo.Enabled   = _designer.UndoStack.CanRedo;
    _btnCut.Enabled    =
    _btnCopy.Enabled   = 
    _btnDelete.Enabled = _designer.ClipboardHandler.CanCut;
    _btnPaste.Enabled  = _designer.ClipboardHandler.CanPaste;
}

See Also