corelibraries-devexpress-dot-diagram-dot-core-dot-diagramstencil-dot-registertool-x28-devexpress-dot-diagram-dot-core-dot-itemtool-x29.md
Adds the specified item tool to the stencil.
Namespace : DevExpress.Diagram.Core
Assembly : DevExpress.Diagram.v25.2.Core.dll
NuGet Package : DevExpress.Diagram.Core
public void RegisterTool(
ItemTool tool
)
Public Sub RegisterTool(
tool As ItemTool
)
| Name | Type | Description |
|---|---|---|
| tool | DevExpress.Diagram.Core.ItemTool |
A DevExpress.Diagram.Core.ItemTool descendant.
|
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
stencil.RegisterTool(new FactoryItemTool(
id: "Text",
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
stencil.RegisterTool(itemTool);
}
wpf-diagram-register-factoryitemtools-for-shapes/CS/WpfApp13/MainWindow.xaml.cs#L32
stencil.RegisterTool(itemTool);
}
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
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))
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
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
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
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