Profile Picture

Transform Shape Bounds to screen bounds

Posted By Kevin Harrison 4 Years Ago
Author
Message
Kevin Harrison
Posted 4 Years Ago
View Quick Profile
Supreme Being

Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)

Group: Forum Members
Last Active: 3 days ago @ 10:28 AM
Posts: 176, Visits: 1,705
Hi
We want to simulate clicking on a shape in a diagram for testing purposes.
How do I transform the shape bounds within the view to screen coordinates?
Thanks
Kevin


Kevin Harrison
Posted 4 Years Ago
View Quick Profile
Supreme Being

Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)

Group: Forum Members
Last Active: 3 days ago @ 10:28 AM
Posts: 176, Visits: 1,705
We've tried using shape.WorldTransform.TransformBounds(shape.Bounds).
The relative positions of the shapes are correct, but they are not the coordinates of the pixels on the screen. What offset do we need to apply?
Thanks
Kevin

Nevron Support
Posted 4 Years Ago
View Quick Profile
Supreme Being

Supreme Being (3,954 reputation)Supreme Being (3,954 reputation)Supreme Being (3,954 reputation)Supreme Being (3,954 reputation)Supreme Being (3,954 reputation)Supreme Being (3,954 reputation)Supreme Being (3,954 reputation)Supreme Being (3,954 reputation)Supreme Being (3,954 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 2,888, Visits: 3,074
Hi,

The bounds of a shape are in scene coordinates, so in order to get its bounds in screen coordinates you should first convert the scene coordinates to device coordinates using the drawing view's SceneToDevice transform and then convert the result to screen coordinates using the standard WinForms Control.PointToScreen method. Here's an example:


NRectangleF bounds = view.SceneToDevice.TransformBounds(shape.Bounds);
Point topLeft = view.PointToScreen(bounds.Location.Round().ToPoint());
Point bottomRight = view.PointToScreen(bounds.RightBottom.Round().ToPoint());


For more information about the coordinate systems used in Nevron Diagram for .NET, check out the Coordinate Systems documentation topic.

Best Regards,
Nevron Support Team



Kevin Harrison
Posted 4 Years Ago
View Quick Profile
Supreme Being

Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)

Group: Forum Members
Last Active: 3 days ago @ 10:28 AM
Posts: 176, Visits: 1,705
Thanks guys.



Similar Topics


Reading This Topic