- Home
- Forum
- Xamarin.Forms
- Set and get position of shape ou customview. Drawing guideline to center objects
Set and get position of shape ou customview. Drawing guideline to center objects
I would like to know, if is possible set or get the position of shape or customview, while dragging? Or if possible drawing guide line, like this:
Thanks.
SIGN IN To post a reply.
5 Replies
1 reply marked as answer
SS
Sridevi Sivakumar
Syncfusion Team
July 27, 2021 03:05 PM UTC
Hi Mário Cleber Bidóia,
Greetings from Syncfusion.
We would like to let you know that, you can get the position of the Shape/CustomView added on an image by using the Bounds property. On selecting a shape, ItemSelected event will be triggered. From this, you will get settings of selected shape with Bounds property from the ItemSelected event argument. The value of the Bounds will be in percentage, the value of the shape frame should fall between 0 and 100. Using this ratio value, we can get the X and Y position of the shape as per below code snippet.
[Xaml]:
Greetings from Syncfusion.
We would like to let you know that, you can get the position of the Shape/CustomView added on an image by using the Bounds property. On selecting a shape, ItemSelected event will be triggered. From this, you will get settings of selected shape with Bounds property from the ItemSelected event argument. The value of the Bounds will be in percentage, the value of the shape frame should fall between 0 and 100. Using this ratio value, we can get the X and Y position of the shape as per below code snippet.
[Xaml]:
|
<imageeditor:SfImageEditor Source="{Binding Image}" x:Name="editor" ItemSelected="SfImageEditor_ItemSelected" /> |
In below code snippet, we can get the editor image bounds form the SfImageEditor ActualImageRenderedBounds property, selected shape bounds value in the ItemSelected event argument, and editor image original size from the OriginalImageSize property.
[C#]:
|
private void SfImageEditor_ItemSelected(object sender, Syncfusion.SfImageEditor.XForms.ItemSelectedEventArgs args)
{
var selectedShapeBounds = (args.Settings as PenSettings).Bounds;
var imagebounds = editor.ActualImageRenderedBounds;
var size = editor.OriginalImageSize;
var selectedShapeXPosition = ((size.Width / 100) * selectedShapeBounds.X) + imagebounds.X;
var selectionShapeYPosition = ((size.Height / 100) * selectedShapeBounds.Y) + imagebounds.Y; } |
Let us know if you need any further assistance.
Regards,
Sridevi S.
Marked as answer
Great. It's Perfect.
And about drawing guide lines? Any suggestion?
And another doubt, when use "editor.AddShape(ShapeType.Line);" is possible set begin point and end point for drawing the line?
Thaks a lot!!!
SS
Sridevi Sivakumar
Syncfusion Team
July 29, 2021 07:37 AM UTC
Hi Mário Cleber Bidóia,
Thanks for your update.
Query: when use "editor.AddShape(ShapeType.Line);" is it possible to set begin point and endpoint for drawing the line?
In SfImageEditor, we don't have support for adding the start point and end point for the line shape type, but we can change the start and endpoint with user interaction.
Let us know if you need any further assistance.
Regards,
Sridevi S.
Thanks for your update.
Query: when use "editor.AddShape(ShapeType.Line);" is it possible to set begin point and endpoint for drawing the line?
In SfImageEditor, we don't have support for adding the start point and end point for the line shape type, but we can change the start and endpoint with user interaction.
Let us know if you need any further assistance.
Regards,
Sridevi S.
AW
AD Ware
February 20, 2023 09:32 PM UTC
Hi hello sorry for bothering you but is there a solution to the guide lines?
ET
Eswaran Thirugnanasambandam
Syncfusion Team
February 22, 2023 10:24 AM UTC
Hi AD Ware,
The current implementation of the SfImageEditor does not have support for displaying guidelines when adding shapes.
Regards,
Eswaran
SIGN IN To post a reply.
- 5 Replies
- 4 Participants
- Marked answer
-
MC Mário Cleber Bidóia
- Jul 27, 2021 02:23 AM UTC
- Feb 22, 2023 10:24 AM UTC