menu

Blazor

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class DiagramHistoryManager - Blazor API Reference | Syncfusion

    Show / Hide Table of Contents

    Class DiagramHistoryManager

    Represents the manager that handles undo and redo operations for a diagram, notifying when changes are reverted or restored.

    Inheritance
    System.Object
    DiagramHistoryManager
    Namespace: Syncfusion.Blazor.Diagram
    Assembly: Syncfusion.Blazor.dll
    Syntax
    public class DiagramHistoryManager : ComponentBase
    Remarks

    The DiagramHistoryManager is crucial for maintaining the state of a diagram by allowing users to undo and redo changes.

    Constructors

    DiagramHistoryManager()

    Initializes a new instance of the DiagramHistoryManager class.

    Declaration
    public DiagramHistoryManager()

    Properties

    CanRedo

    Gets or sets a value indicating whether the history entry can be redone.

    Declaration
    public bool CanRedo { get; set; }
    Property Value
    Type
    System.Boolean
    Remarks

    When set to true, the history manager enables reapplying the last undone action, facilitating the reinstatement of changes that were reversed, thus enhancing the flexibility of the undo-redo workflow.

    CanUndo

    Gets or sets a value indicating whether the history entry can be undone.

    Declaration
    public bool CanUndo { get; set; }
    Property Value
    Type
    System.Boolean
    Remarks

    Setting this property to true allows the history manager to revert the most recent action, ensuring that accidental changes can be easily undone to restore previous states.

    ChildContent

    Gets or sets the child content for the history manager.

    Declaration
    public RenderFragment ChildContent { get; set; }
    Property Value
    Type
    Microsoft.AspNetCore.Components.RenderFragment
    Remarks

    Allows customization of the history manager's content using render fragments, enabling dynamic and flexible UI updates within the diagram component. It supports customization of the user interface by defining children elements that are rendered dynamically.

    CurrentEntry

    Gets or sets the current entry object.

    Declaration
    public HistoryEntryBase CurrentEntry { get; set; }
    Property Value
    Type
    HistoryEntryBase
    Remarks

    Represents the specific history entry currently active within the diagram's history stack, allowing users to query or modify the current state of the undo and redo operations.

    HistoryAdding

    Gets or sets a callback that occurs determining if changes should be stored in the history.

    Declaration
    public EventCallback<HistoryAddingEventArgs> HistoryAdding { get; set; }
    Property Value
    Type
    Microsoft.AspNetCore.Components.EventCallback<HistoryAddingEventArgs>
    Remarks

    This event is triggered before a change is added to the history, allowing you to decide whether it should be committed.

    Examples
    <SfDiagramComponent Width="800px" Height="800px">
        <DiagramHistoryManager HistoryAdding="OnHistoryAdding"></DiagramHistoryManager>
    </SfDiagramComponent>
    @code
    {
        private void OnHistoryAdding(HistoryAddingEventArgs args)
        {
            args.Cancel = true;
        }
    }

    Redo

    Gets or sets the callback method that is invoked when a custom entry is in the redo stage.

    Declaration
    public EventCallback<HistoryEntryBase> Redo { get; set; }
    Property Value
    Type
    Microsoft.AspNetCore.Components.EventCallback<HistoryEntryBase>
    Remarks

    Allows integration of custom logic during the redo operation within the diagram component, enhancing the flexibility and control over redo actions.

    Examples
    <SfDiagramComponent Width="800px" Height="800px">
        <DiagramHistoryManager Redo="onCustomRedo"></DiagramHistoryManager>
    </SfDiagramComponent>
    @code
    {
        private void onCustomRedo(HistoryEntryBase entry)
        {
            Node current = entry.UndoObject.Clone() as Node;
            (entry.UndoObject as Node).AdditionalInfo[(entry.UndoObject as Node).ID] = "Description";
            entry.RedoObject = current;
        }
    }

    StackLimit

    Gets or sets the number of history entries that can be stored on the history list to limit undo, redo stack.

    Declaration
    public int StackLimit { get; set; }
    Property Value
    Type Description
    System.Int32

    An System.Int32 representing the maximum number of history entries. The default value is 0.

    Remarks

    This property helps control memory usage by limiting the number of actions stored in the history list for undo and redo operations.

    Examples
    <SfDiagramComponent Height="900px">
        <DiagramHistoryManager StackLimit="@stack" ></DiagramHistoryManager>
    </SfDiagramComponent>

    Undo

    Gets or sets the callback method that is invoked when a custom entry is in the undo stage.

    Declaration
    public EventCallback<HistoryEntryBase> Undo { get; set; }
    Property Value
    Type
    Microsoft.AspNetCore.Components.EventCallback<HistoryEntryBase>
    Remarks

    Allows integration of custom logic during the undo operation within the diagram component, enhancing the flexibility and control over undo actions.

    Examples
    <SfDiagramComponent Width="800px" Height="800px">
        <DiagramHistoryManager Undo="onCustomUndo"></DiagramHistoryManager>
    </SfDiagramComponent >
    @code
    {
        private void onCustomUndo(HistoryEntryBase entry)
        {
            (entry.RedoObject) = entry.UndoObject.Clone() as Node;
            (entry.UndoObject as Node).AdditionalInfo[(entry.UndoObject as Node).ID] = "Start";
        }
    }

    Methods

    BuildRenderTree(RenderTreeBuilder)

    Declaration
    protected override void BuildRenderTree(RenderTreeBuilder __builder)
    Parameters
    Type Name Description
    Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder

    Dispose()

    This method releasing all unmanaged resources.

    Declaration
    public void Dispose()

    EndGroupAction()

    Ends a group action which encapsulates multiple changes for combined undo/redo operations within the Syncfusion.Blazor.Diagram.DiagramHistoryManager.Diagram.

    Declaration
    public void EndGroupAction()
    Remarks

    This method finalizes the grouping of changes, allowing them to be treated as a single action in the undo/redo sequence, thus enhancing the user's control over multiple related modifications.

    Examples
    // End the grouping of changes
    diagram.EndGroupAction();

    OnAfterRenderAsync(Boolean)

    Method invoked after each time the component has been rendered.

    Declaration
    protected override Task OnAfterRenderAsync(bool firstRender)
    Parameters
    Type Name Description
    System.Boolean firstRender

    Set to true for the first time component rendering, otherwise gets false.

    Returns
    Type Description
    System.Threading.Tasks.Task

    A System.Threading.Tasks.Task representing any asynchronous operation.

    OnInitializedAsync()

    This method is invoked when the component is ready to start.

    Declaration
    protected override Task OnInitializedAsync()
    Returns
    Type
    System.Threading.Tasks.Task

    OnParametersSetAsync()

    Method invoked when any changes in component state occur.

    Declaration
    protected override Task OnParametersSetAsync()
    Returns
    Type Description
    System.Threading.Tasks.Task

    ="Task".

    StartGroupAction()

    Initiates a group action allowing you to revert or restore multiple changes through a single undo/redo command within the Syncfusion.Blazor.Diagram.DiagramHistoryManager.Diagram.

    Declaration
    public void StartGroupAction()
    Remarks

    This method starts the grouping of changes, which is useful for managing multiple related modifications in a unified manner using undo/redo functionality.

    Examples
    // Start the grouping of changes 
    diagram.StartGroupAction();
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved