Class DiagramCommandManager
Represents to map or bind command execution with the desired combination of key gestures.
Inheritance
System.Object
Syncfusion.Blazor.Diagrams.Internal.SfDiagramBaseExtension
DiagramCommandManager
Inherited Members
Namespace: Syncfusion.Blazor.Diagrams
Assembly: Syncfusion.Blazor.dll
Syntax
public class DiagramCommandManager : SfDiagramBaseExtension, IBaseInit
Remarks
CommandManager provides support to define custom commands. The custom commands are executed when the specified key gesture is recognized. |
Examples
<SfDiagram @ref="@Diagram" Height="600px"
Nodes="@NodeCollection">
@* Initializing the custom commands*@
<DiagramCommandManager>
<DiagramCommands>
<DiagramCommand Name = "customGroup" >
< DiagramKeyGesture Key="Keys.G" KeyModifiers="KeyModifiers.Control"></DiagramKeyGesture>
</DiagramCommand>
<DiagramCommand Name = "customUnGroup" >
< DiagramKeyGesture Key="Keys.U" KeyModifiers="KeyModifiers.Control"></DiagramKeyGesture>
</DiagramCommand>
</DiagramCommands>
</DiagramCommandManager>
@* To define the custom commands execution event *@
<DiagramEvents OnCommandExecuted="@CommandExecute"></DiagramEvents>
</SfDiagram>
@code
{
// Reference to diagram
SfDiagram Diagram;
// Defines diagram's nodes collection
public ObservableCollection<DiagramNode> NodeCollection { get; set; }
protected override void OnInitialized()
{
//Initializing the nodes collection
NodeCollection = new ObservableCollection<DiagramNode>();
DiagramNode DiagramNode1 = new DiagramNode()
{
Id = "node1",
OffsetX = 100,
OffsetY = 100,
Width = 100,
Height = 100,
Style = new NodeShapeStyle() { Fill = "#659be5", StrokeColor = "none" },
Annotations = new ObservableCollection<DiagramNodeAnnotation>() { new DiagramNodeAnnotation() { Content = "Node" } }
};
NodeCollection.Add(DiagramNode1);
DiagramNode DiagramNode2 = new DiagramNode()
{
Id = "node2",
OffsetX = 300,
OffsetY = 100,
Width = 100,
Height = 100,
Style = new NodeShapeStyle() { Fill = "#659be5", StrokeColor = "none" },
Annotations = new ObservableCollection<DiagramNodeAnnotation>() { new DiagramNodeAnnotation() { Content = "Node" } }
};
NodeCollection.Add(DiagramNode2);
}
/// <summary>
/// Custom command execution event
/// </summary>
public void CommandExecute(ICommandExecuteEventArgs args)
{
if (args.Gesture.KeyModifiers == KeyModifiers.Control && args.Gesture.Key == Keys.G)
{
//Custom command to group the selected nodes
Diagram.Group();
}
if (args.Gesture.KeyModifiers == KeyModifiers.Control && args.Gesture.Key == Keys.U)
{
//Custom command to ungroup the selected items
if (Diagram.SelectedItems.Nodes.Count > 0 && Diagram.SelectedItems.Nodes[0].Children != null && Diagram.SelectedItems.Nodes[0].Children.Length > 0)
{
Diagram.UnGroup();
}
}
}
}
Constructors
DiagramCommandManager()
Declaration
public DiagramCommandManager()
Properties
ChildContent
Represents a segment of UI content, implemented.
Declaration
public RenderFragment ChildContent { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Components.RenderFragment |
Commands
Stores the multiple command names with the corresponding command objects
Declaration
public List<DiagramCommand> Commands { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.List<DiagramCommand> |
jsProperty
Declaration
protected override string jsProperty { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Overrides
Syncfusion.Blazor.Diagrams.Internal.SfDiagramBaseExtension.jsProperty
mainParent
Declaration
protected override SfDiagramBaseExtension mainParent { get; set; }
Property Value
Type | Description |
---|---|
Syncfusion.Blazor.Diagrams.Internal.SfDiagramBaseExtension |
Overrides
Syncfusion.Blazor.Diagrams.Internal.SfDiagramBaseExtension.mainParent
Methods
BuildRenderTree(RenderTreeBuilder)
Declaration
protected override void BuildRenderTree(RenderTreeBuilder __builder)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder | __builder |
Dispose()
Declaration
public override void Dispose()
Overrides
Syncfusion.Blazor.Diagrams.Internal.SfDiagramBaseExtension.Dispose()
GetJSNamespace()
Declaration
public string GetJSNamespace()
Returns
Type | Description |
---|---|
System.String | Get the parent namespaces |
OnInitializedAsync()
Declaration
protected override Task OnInitializedAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | Returns asynchronous operation when the component is ready to start, having received its initial parameters from its parent in the render tree |
Overrides
OnParametersSetAsync()
Declaration
protected override Task OnParametersSetAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | Returns asynchronous operation when the component has received parameters from its parent in the render tree, and the incoming values have been assigned to properties |
updateChildProperties(String, Object)
Declaration
public void updateChildProperties(string key, object value)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | |
System.Object | value |