Back to Devexpress

ShapeDescription.CreateSvgShape(String, String, Stream, Boolean, Func<Size, IEnumerable<Point>>, String, String) Method

corelibraries-devexpress-dot-diagram-dot-core-dot-shapedescription-dot-createsvgshape-x28-string-string-stream-boolean-func-size-ienumerable-point-string-string-x29.md

latest4.8 KB
Original Source

ShapeDescription.CreateSvgShape(String, String, Stream, Boolean, Func<Size, IEnumerable<Point>>, String, String) Method

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

Declaration

csharp
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
)
vb
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

Parameters

NameTypeDescription
shapeIdString

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.

|

Optional Parameters

NameTypeDefaultDescription
isQuickBooleanFalse

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.

|

Returns

TypeDescription
ShapeDescription

A ShapeDescription object that represents the shape.

|

Remarks

The following snippet illustrates how to create an SVG shape with a connection point in the center and add it to the toolbox.

csharp
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);
vb
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

ShapeDescription Class

ShapeDescription Members

DevExpress.Diagram.Core Namespace