Scrool to a Specific Shape


Author
Message
Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K

Hi,

Here’s a sample code how to select a shape by its name (you can use also its ID or UniqueID) and center the viewport on it:

 

// Get the shape and select it

NShape shape = (NShape)document.ActiveLayer.GetChildByName("MyShape");

view.Selection.SingleSelect(shape);

 

// Center the viewport at the shape's center

NPointF origin = view.ViewportOrigin;

NPointF offset = shape.Center - view.Viewport.Center;

view.ViewportOrigin = new NPointF(origin.X + offset.X, origin.Y + offset.Y);



Best Regards,
Nevron Support Team


Ashton Hobbs
Ashton Hobbs
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)
Group: Forum Members
Posts: 3, Visits: 1
Is it possible to scroll to a specific shape in the diagram given the shapes UniqueID (or some other identifier for the shape).

I have an external list of the shapes in the diagram and when a user clicks on a an item in my list I want to scroll the diagram to ensure that the specific shape is visible (and selected).

Thanks
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search