Select a tool from code in ImageEditor

Hello all,
is it possible to select an editor tool from code? I would like to set FreehandDrawing as default with specific color and stroke width when the component finished loading the image.

From the docs I cannot see any property or method to accomplish this.



1 Reply

YA YuvanShankar Arunagiri Syncfusion Team November 20, 2024 10:17 AM UTC

Hi Markus,


We have checked your reported query and using the ShapeChanging event of image editor, we can set the default stroke color and stroke width of freehand draw annotation. Refer to the below code snippet.


@using Syncfusion.Blazor.ImageEditor

 

<SfImageEditor Height="400">

    <ImageEditorEvents ShapeChanging="ShapeChanging"></ImageEditorEvents>

</SfImageEditor>

 

@code {

    private void ShapeChanging(ShapeChangeEventArgs args)

    {

        if (args.CurrentShapeSettings.Type == ShapeType.FreehandDraw)

        {

            args.CurrentShapeSettings.StrokeColor = "red";

            args.CurrentShapeSettings.StrokeWidth = 5;

        }

    }

}


Get back to us if you need any further assistance on this.


Regards,

YuvanShankar A


Loader.
Up arrow icon