Add Text when adding Shape

Hello,

is it possible to add a text when adding a shape?

Lets say I want to draw a line and above the line there should be automatically added a text which I can enter for example for lenght measurements. 


Thank you


1 Reply

BS Balachandar Selvam Syncfusion Team September 7, 2022 02:06 PM UTC

We would like to inform you that this requirement can be achieved by adding the required text using AddText method based on the ToolbarItem’s name in the ToolbarItemSelected  event as shown in the below snippet, but the text and shape are different items. So, if we modify one item through interacting, then it will not alter the other item.


C#

public MainPage()

{

    ...

    imageEditor.ToolbarSettings.ToolbarItemSelected += ToolbarSettings_ToolbarItemSelected;

    imageEditor.RotatableElements = ImageEditorElements.Text;

    ...

}

 

private void ToolbarSettings_ToolbarItemSelected(object sender, ToolbarItemSelectedEventArgs e)

{

    if (e.ToolbarItem.Name == "Arrow")

    {

        Rectangle rect;

        if (Device.RuntimePlatform == Device.iOS)

        {

            rect = new Rectangle(22, 22, 47, 20);

        }

        else

        {

            rect = new Rectangle(42, 32, 17, 20);

        }

 

        imageEditor.AddText("20 cm.", new TextSettings()

        {

            Color = Color.Black,

            Angle = 322,

            Bounds = rect

        });

    }

}


We have prepared a sample for the same. Please find it in the attachment.


Please follow this link for more details about the shapes and events support of SfImageEditor.

https://help.syncfusion.com/xamarin/image-editor/shapes

https://help.syncfusion.com/xamarin/image-editor/toolbarcustomization#toolbaritemselected-event


If you want to sync both arrow and text, then we can provide it as a custom view. Please find the below user guide documentation for more information about custom view support in the SfImageEditor control.

https://help.syncfusion.com/xamarin/image-editor/customview


Attachment: ImageEditorDemo_d26f0c00.zip

Loader.
Up arrow icon