Back to Devexpress

DiagramStencil.RegisterTool(ItemTool) Method

corelibraries-devexpress-dot-diagram-dot-core-dot-diagramstencil-dot-registertool-x28-devexpress-dot-diagram-dot-core-dot-itemtool-x29.md

latest7.8 KB
Original Source

DiagramStencil.RegisterTool(ItemTool) Method

Adds the specified item tool to the stencil.

Namespace : DevExpress.Diagram.Core

Assembly : DevExpress.Diagram.v25.2.Core.dll

NuGet Package : DevExpress.Diagram.Core

Declaration

csharp
public void RegisterTool(
    ItemTool tool
)
vb
Public Sub RegisterTool(
    tool As ItemTool
)

Parameters

NameTypeDescription
toolDevExpress.Diagram.Core.ItemTool

A DevExpress.Diagram.Core.ItemTool descendant.

|

Remarks

The RegisterTool method is used to register custom diagram items in the Shapes Panel. To register regular shapes, use the DiagramStencil.RegisterShape method.

The following code snippets (auto-collected from DevExpress Examples) contain references to the RegisterTool(ItemTool) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

wpf-diagramcontrol-create-items-with-custom-content/CS/DXDiagram.ContentItem/MainWindow.xaml.cs#L17

csharp
stencil.RegisterTool(new FactoryItemTool(
    id: "Text",

how-to-use-the-customdrawitem-event-to-draw-custom-icons-inside-diagram-items-t441104/CS/XtraDiagram.CustomDraw/Form1.cs#L26

csharp
var stencil = new DiagramStencil("customShapes", "Custom Shapes");
stencil.RegisterTool(new FactoryItemTool("activeTaskShape", () => "Active Task", diagram => new DiagramShapeEx { Content = "Active Task", Status = Status.Active }, new System.Windows.Size(150, 100), false));
stencil.RegisterTool(new FactoryItemTool("inactiveTaskShape", () => "Inactive Task", diagram => new DiagramShapeEx { Content = "Inactive Task", Status = Status.Inactive }, new System.Windows.Size(150, 100), false));

winforms-diagram-register-factoryitemtools-for-shapes/CS/WindowsFormsApp4/Form1.cs#L32

csharp
stencil.RegisterTool(itemTool);
}

wpf-diagram-register-factoryitemtools-for-shapes/CS/WpfApp13/MainWindow.xaml.cs#L32

csharp
stencil.RegisterTool(itemTool);
}

how-to-create-a-diagramshape-descendant-and-serialize-its-properties-t361265/CS/XtraDiagram.CustomShapeProperties/Form1.cs#L40

csharp
var itemTool = new FactoryItemTool("CustomShape", () => "Custom Shape", diagram => { DiagramShapeEx customShape = new DiagramShapeEx() { Width = 100, Height = 50 }; return customShape; }, new System.Windows.Size(100, 50), false);
stencil.RegisterTool(itemTool);
DevExpress.Diagram.Core.DiagramToolboxRegistrator.RegisterStencil(stencil);

wpf-diagramcontrol-create-items-with-custom-content/VB/DXDiagram.ContentItem/MainWindow.xaml.vb#L18

vb
Dim stencil As DiagramStencil = New DiagramStencil("CustomTools", "Content Item Tools")
stencil.RegisterTool(New FactoryItemTool(id:="Text", getName:=Function() "Text", createItem:=Function(diagram) New DiagramContentItem() With {.CustomStyleId = "formattedTextContentItem"}, defaultSize:=New Size(230, 110), isQuick:=True))
stencil.RegisterTool(New FactoryItemTool(id:="Logo", getName:=Function() "Logo", createItem:=Function(diagram) New DiagramContentItem() With {.CustomStyleId = "devExpressLogoContentItem"}, defaultSize:=New Size(230, 80), isQuick:=True))

how-to-use-the-customdrawitem-event-to-draw-custom-icons-inside-diagram-items-t441104/VB/XtraDiagram.CustomDraw/Form1.vb#L23

vb
Dim stencil = New DiagramStencil("customShapes", "Custom Shapes")
stencil.RegisterTool(New FactoryItemTool("activeTaskShape", Function() "Active Task", Function(diagram) New DiagramShapeEx With {.Content = "Active Task", .Status = Status.Active}, New Windows.Size(150, 100), False))
stencil.RegisterTool(New FactoryItemTool("inactiveTaskShape", Function() "Inactive Task", Function(diagram) New DiagramShapeEx With {.Content = "Inactive Task", .Status = Status.Inactive}, New Windows.Size(150, 100), False))

winforms-diagram-register-factoryitemtools-for-shapes/VB/WindowsFormsApp4/Form1.vb#L27

vb
Dim itemTool = New FactoryItemTool("CustomShape1", Function() "Custom Shape 1", Function(diagram) New DiagramShape() With {.Content = "Predefined text"}, New System.Windows.Size(200, 200), False)
    stencil.RegisterTool(itemTool)
End Sub

wpf-diagram-register-factoryitemtools-for-shapes/VB/WpfApp13/MainWindow.xaml.vb#L27

vb
Dim itemTool = New FactoryItemTool("CustomShape1", Function() "Custom Shape 1", Function(diagram) New DiagramShape() With {.Content = "Predefined text"}, New Size(200, 200), False)
    stencil.RegisterTool(itemTool)
End Sub

how-to-create-a-diagramshape-descendant-and-serialize-its-properties-t361265/VB/XtraDiagram.CustomShapeProperties/Form1.vb#L42

vb
Dim stencil = New DevExpress.Diagram.Core.DiagramStencil("CustomStencil", "Custom Shapes")
stencil.RegisterTool(New FactoryItemTool("CustomShape", Function() "Custom Shape", Function(diagram) New DiagramShapeEx(), New System.Windows.Size(230, 110), False))
DevExpress.Diagram.Core.DiagramToolboxRegistrator.RegisterStencil(stencil)

See Also

Tools

DiagramStencil Class

DiagramStencil Members

DevExpress.Diagram.Core Namespace