corelibraries-devexpress-dot-diagram-dot-core-dot-shapedescription-dot-createsvgshape-x28-string-string-stream-boolean-func-size-ienumerable-point-string-string-x29.md
Creates a diagram shape from a stream that contains an SVG image.
Namespace : DevExpress.Diagram.Core
Assembly : DevExpress.Diagram.v25.2.Core.dll
NuGet Package : DevExpress.Diagram.Core
public static ShapeDescription CreateSvgShape(
string shapeId,
string name,
Stream svgStream,
bool isQuick = false,
Func<Size, IEnumerable<Point>> getConnectionPoints = null,
string backgroundColorCode = null,
string strokeColorCode = null
)
Public Shared Function CreateSvgShape(
shapeId As String,
name As String,
svgStream As Stream,
isQuick As Boolean = False,
getConnectionPoints As Func(Of Size, IEnumerable(Of Point)) = Nothing,
backgroundColorCode As String = Nothing,
strokeColorCode As String = Nothing
) As ShapeDescription
| Name | Type | Description |
|---|---|---|
| shapeId | String |
A string value that identifies the shape.
| | name | String |
A string value that is the name of the shape.
| | svgStream | Stream |
A System.IO.Stream object that contains the SVG image.
|
| Name | Type | Default | Description |
|---|---|---|---|
| isQuick | Boolean | False |
true to display the shape within the Quick Shapes category of the Shapes toolbox; otherwise, false.
| | getConnectionPoints | Func<Size, IEnumerable<Point>> | null |
A function that specifies the coordinates of connection points.
| | backgroundColorCode | String | null |
A string value that represents the code of the color to be swapped with the theme’s background color.
| | strokeColorCode | String | null |
A string value that represents the code of the color to be swapped with the theme’s foreground color.
|
| Type | Description |
|---|---|
| ShapeDescription |
A ShapeDescription object that represents the shape.
|
The following snippet illustrates how to create an SVG shape with a connection point in the center and add it to the toolbox.
var stencil = new DevExpress.Diagram.Core.DiagramStencil("OfficeStencil", "Office Shapes");
using (System.IO.FileStream stream = System.IO.File.Open("..\\..\\Armchair.svg", System.IO.FileMode.Open)) {
var shapeDescription = DevExpress.Diagram.Core.ShapeDescription.CreateSvgShape("Armchair", "Armchair", stream, false, (s) => new[] { new System.Windows.Point(s.Width / 2, s.Height / 2) });
stencil.RegisterShape(shapeDescription);
}
DiagramToolboxRegistrator.RegisterStencil(stencil);
Dim stencil = New DevExpress.Diagram.Core.DiagramStencil("OfficeStencil", "Office Shapes")
Using stream As System.IO.FileStream = System.IO.File.Open("..\..\Armchair.svg", System.IO.FileMode.Open)
Dim shapeDescription = DevExpress.Diagram.Core.ShapeDescription.CreateSvgShape("Armchair", "Armchair", stream, False, Function(s) { New System.Windows.Point(s.Width \ 2, s.Height \ 2) })
stencil.RegisterShape(shapeDescription)
End Using
DiagramToolboxRegistrator.RegisterStencil(stencil)
See Also