Skip to main content

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.v24.2.Core.dll

Declaration

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
)

Parameters

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.

Optional Parameters

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.

Returns

Type Description
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.

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);
See Also