corelibraries-devexpress-dot-diagram-dot-core-dot-diagramstencil-dot-registershape-x28-devexpress-dot-diagram-dot-core-dot-shapedescriptionbase-x29.md
Adds the specified shape to the stencil.
Namespace : DevExpress.Diagram.Core
Assembly : DevExpress.Diagram.v25.2.Core.dll
NuGet Package : DevExpress.Diagram.Core
public void RegisterShape(
ShapeDescriptionBase shape
)
Public Sub RegisterShape(
shape As ShapeDescriptionBase
)
| Name | Type | Description |
|---|---|---|
| shape | ShapeDescriptionBase |
A ShapeDescriptionBase descendant representing the shape to add to the stencil.
|
The example below illustrates how to add an SVG shape to a stencil.
//create or get the stencil you want to add your SVG to
var stencil = DiagramToolboxRegistrator.GetStencil("SvgShapes");
//open the file here
using (Stream file = File.OpenRead(filePathToSVGFile)) {
String id = "SVGid";
String name = "SVGname";
//create your shapeDescription with the SVG
var shapeDescription = ShapeDescription.CreateSvgShape(id, name, file, false);
//add the shapeDescription to your stencil
stencil.RegisterShape(shapeDescription);
}
'create or get the stencil you want to add your SVG to
Dim stencil = DiagramToolboxRegistrator.GetStencil("SvgShapes")
'open the file here
Using file As Stream = System.IO.File.OpenRead(filePathToSVGFile)
Dim id As String = "SVGid"
Dim name As String = "SVGname"
'create your shapeDescription with the SVG
Dim shapeDescription = ShapeDescription.CreateSvgShape(id, name, file, False)
'add the shapeDescription to your stencil
stencil.RegisterShape(shapeDescription)
End Using
To register custom diagram items, use the DiagramStencil.RegisterTool method.
The following code snippets (auto-collected from DevExpress Examples) contain references to the RegisterShape(ShapeDescriptionBase) 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-diagram-register-and-use-svg-shapes/CS/DiagramSVGItemsWpf/MainWindow.xaml.cs#L25
.Update(getConnectionPoints: (w, h, p) => new[] { new Point(w / 2, h / 2) });
stencil.RegisterShape(shape);
}
how-to-register-and-use-svg-shapes-t478182/CS/DiagramSVGItemsWinForms/Form1.cs#L39
.Update(getConnectionPoints: (w, h, p) => new[] { new System.Windows.Point(w / 2, h / 2) });
stencil.RegisterShape(shape);
}
wpf-diagram-register-and-use-svg-shapes/VB/DiagramSVGItemsWpf/MainWindow.xaml.vb#L43
Dim shape = DevExpress.Diagram.Core.ShapeDescription.CreateSvgShape(name_Renamed, name_Renamed, stream).Update(getDefaultSize:= Function() New System.Windows.Size(100, 100)).Update(getConnectionPoints:= Function(w, h, p) { New System.Windows.Point(w / 2, h / 2) })
stencil.RegisterShape(shape)
End Using
how-to-register-and-use-svg-shapes-t478182/VB/DiagramSVGItemsWinForms/Form1.vb#L34
Dim shape = DevExpress.Diagram.Core.ShapeDescription.CreateSvgShape(name_Renamed, name_Renamed, stream).Update(getDefaultSize:= Function() New System.Windows.Size(100, 100)).Update(getConnectionPoints:= Function(w, h, p) { New System.Windows.Point(w / 2, h / 2) })
stencil.RegisterShape(shape)
End Using
See Also