FactoryItemTool Class
Allows you to create custom item tools.
Namespace: DevExpress.Diagram.Core
Assembly:
DevExpress.Diagram.v18.1.Core.dll
Declaration
public class FactoryItemTool :
ItemTool
Public Class FactoryItemTool
Inherits ItemTool
The example below illustrates how to create a custom rectangle and use it as the Ribbon’s Rectangle tool.
diagramControl1.OptionsBehavior.RectangleTool = new FactoryItemTool("CustomRect", () => "CustomRect",
diagram => new DiagramShape() {
Shape = BasicShapes.Rectangle,
ConnectionPoints = new PointCollection(new List<PointFloat>() { new PointFloat(0.5F, 0.5F) })},
BasicShapes.Rectangle.DefaultSize, BasicShapes.Rectangle.IsQuick);
diagramControl1.OptionsBehavior.RectangleTool = New FactoryItemTool("CustomRect", Function() "CustomRect",
Function(diagram) New DiagramShape() With {.Shape = BasicShapes.Rectangle,
.ConnectionPoints = New PointCollection(New List(Of PointFloat)() From {New PointFloat(0.5F, 0.5F)})},
BasicShapes.Rectangle.DefaultSize, BasicShapes.Rectangle.IsQuick)
To learn more, see the following examples:
The following code snippets (auto-collected from DevExpress Examples) contain references to the FactoryItemTool class.
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.
how-to-create-items-with-custom-content-in-diagramcontrol-t395119/CS/DXDiagram.ContentItem/MainWindow.xaml.cs#L30
DiagramStencil stencil = new DiagramStencil("CustomTools", "Content Item Tools");
stencil.RegisterTool(new FactoryItemTool(
"Text",
how-to-use-the-customdrawitem-event-to-draw-custom-icons-inside-diagram-items-t441104/CS/XtraDiagram.CustomDraw/Form1.cs#L26
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));
how-to-create-a-diagramshape-descendant-with-editable-and-serializable-properties-t395040/CS/DXDiagram.CustomShapeProperties/MainWindow.xaml.cs#L18
var stencil = new DevExpress.Diagram.Core.DiagramStencil("CustomStencil", "Custom Shapes");
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);
how-to-create-a-diagramshape-descendant-and-serialize-its-properties-t361265/CS/XtraDiagram.CustomShapeProperties/Form1.cs#L39
var stencil = new DevExpress.Diagram.Core.DiagramStencil("CustomStencil", "Custom Shapes");
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);
how-to-create-items-with-custom-content-in-diagramcontrol-t395119/VB/DXDiagram.ContentItem/MainWindow.xaml.vb#L32
Dim stencil As New DiagramStencil("CustomTools", "Content Item Tools")
stencil.RegisterTool(New FactoryItemTool("Text", Function() "Text", Function(diagram) New DiagramContentItem() With {.CustomStyleId = "formattedTextContentItem"}, New Size(230, 110), True))
stencil.RegisterTool(New FactoryItemTool("Logo", Function() "Logo", Function(diagram) New DiagramContentItem() With {.CustomStyleId = "devExpressLogoContentItem"}, New Size(230, 80), True))
how-to-use-the-customdrawitem-event-to-draw-custom-icons-inside-diagram-items-t441104/VB/XtraDiagram.CustomDraw/Form1.vb#L28
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 System.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 System.Windows.Size(150, 100), False))
how-to-create-a-diagramshape-descendant-with-editable-and-serializable-properties-t395040/VB/DXDiagram.CustomShapeProperties/MainWindow.xaml.vb#L16
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)
how-to-create-a-diagramshape-descendant-and-serialize-its-properties-t361265/VB/XtraDiagram.CustomShapeProperties/Form1.vb#L42
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)
Inheritance
ObjectDevExpress.Utils.ImmutableObject
DiagramToolDevExpress.Diagram.Core.ItemTool
FactoryItemTool
See Also