Enabled: Boolean;
Enabled: Boolean;
The Enabled property indicates whether the Undo/Redo stack is available for the user.
If the property value is False, the Undo stack is unavailable. To enable Undo/Redo stack, set the Enabled property to True. After that, all actions executed by the user are saved in the stack and, if required, can be canceled or repeated. The number of operations that can be stored in the stack is limited by the number set in the Limit property.
To cancel the actions done, use the Undo method, to repeat the actions done, use the Redo method.
Executing the example requires a form, the ReportBox and UiReport components placed on this form and the Toolbar1 toolbar that contains five buttons. Create event handlers for the buttons. The UiReport component is a data source for ReportBox.
Class SAMPLEForm: Form
ReportBox1: ReportBox;
UiReport1: UiReport;
Toolbar1: Toolbar;
ToolbarButton1: ToolbarButton;
ToolbarButton2: ToolbarButton;
ToolbarButton3: ToolbarButton;
ToolbarButton4: ToolbarButton;
ToolbarButton5: ToolbarButton;
UnRed: IUndoRedo;
Sub SAMPLEFormOnCreate(Sender: Object; Args: IEventArgs);
Var
MB: IMetabase;
Report: IPrxReport;
Begin
MB := MetabaseClass.Active;
Report := MB.ItemById("Report_1").Edit As IPrxReport;
UiReport1.Instance := Report;
UnRed := Report.UndoRedo;
UnRed.Enabled := True;
UnRed.Limit := 10;
End Sub SAMPLEFormOnCreate;
Sub ToolbarButton1OnClick(Sender: Object; Args: IEventArgs);
Begin
If UnRed.UndoCount > 0 Then
UnRed.Undo;
End If;
End Sub ToolbarButton1OnClick;
Sub ToolbarButton2OnClick(Sender: Object; Args: IEventArgs);
Begin
If UnRed.RedoCount > 0 Then
UnRed.Redo;
End If;
End Sub ToolbarButton2OnClick;
Sub ToolbarButton3OnClick(Sender: Object; Args: IEventArgs);
Begin
UnRed.Flush;
End Sub ToolbarButton3OnClick;
Sub ToolbarButton4OnClick(Sender: Object; Args: IEventArgs);
Begin
If UnRed.UndoCount > 0 Then
text := UnRed.UndoState(UnRed.UndoCount - 1).Action;
End If;
End Sub ToolbarButton4OnClick;
Sub ToolbarButton5OnClick(Sender: Object; Args: IEventArgs);
Begin
If UnRed.RedoCount > 0 Then
text := UnRed.RedoState(UnRed.RedoCount - 1).Action;
End If;
End Sub ToolbarButton5OnClick;
End Class SAMPLEForm;
After executing the example clicking the Button1 button cancels the last executed operation; clicking the Button2 button repeats the canceled operation; clicking the Button3 button clears Undo/Redo stack; clicking the Button4 button displays description of the last operation stored in the Undo stack in the form's text box; clicking the Button5 button displays description of the last operation stored in the Redo stack in the form's text box.
Executing the example requires a form, the ReportBoxNet and UiReportNet components on this form and the ToolStrip1 toolbar that contains five buttons. Create event handlers for the buttons. The UiReportNet component is a data source for ReportBoxNet.
Imports Prognoz.Platform.Forms.Net;
Imports Prognoz.Platform.Interop.Metabase;
Imports Prognoz.Platform.Interop.Report;
Imports Prognoz.Platform.Interop.ForeSystem;
Public Partial Class SAMPLEForm: Prognoz.Platform.Forms.Net.ForeNetForm
Public Constructor SAMPLEForm();
Begin
InitializeComponent();
End Constructor;
UnRed: IUndoRedo;
Private Sub SAMPLEForm_Load(sender: System.Object; e: System.EventArgs);
Var
MB: IMetabase;
Report: IPrxReport;
Begin
MB := self.Metabase;
Report := MB.ItemById["Report2"].Edit() As IPrxReport;
UiReportNet1.ReportUi.Instance := Report;
UnRed := Report.UndoRedo;
UnRed.Enabled := True;
UnRed.Limit := 10;
End Sub;
Private Sub toolStripButton1_Click(sender: System.Object; e: System.EventArgs);
Begin
If UnRed.UndoCount > 0 Then
UnRed.Undo(1);
End If;
End Sub;
Private Sub toolStripButton2_Click(sender: System.Object; e: System.EventArgs);
Begin
If UnRed.RedoCount > 0 Then
UnRed.Redo(1);
End If;
End Sub;
Private Sub toolStripButton3_Click(sender: System.Object; e: System.EventArgs);
Begin
UnRed.Flush();
End Sub;
Private Sub toolStripButton4_Click(sender: System.Object; e: System.EventArgs);
Begin
If UnRed.UndoCount > 0 Then
text := UnRed.UndoState[UnRed.UndoCount - 1].Action;
End If;
End Sub;
Private Sub toolStripButton5_Click(sender: System.Object; e: System.EventArgs);
Begin
If UnRed.RedoCount > 0 Then
text := UnRed.RedoState[UnRed.RedoCount - 1].Action;
End If;
End Sub;
End Class;
After executing the example clicking the Button1 button cancels the last executed operation; clicking the Button2 button repeats the canceled operation; clicking the Button3 button clears Undo/Redo stack; clicking the Button4 button displays description of the last operation stored in the Undo stack in the form's text box; clicking the Button5 button displays description of the last operation stored in the Redo stack in the form's text box.
See also: