Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Finding items in view (Read 1028 times)
gea
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 6
Joined: Apr 2nd, 2008
Finding items in view
Sep 25th, 2012 at 9:59pm
Print Post  
I want to enumerate the DiagramItems visible for the given DiagramView scroll position.   I can get the RectangleF in document terms, that is ClientToDoc() of the ClientRectangle of the DiagramView.  How do I go from that to DiagramItems?  Using v5.5.
  
Back to top
 
IP Logged
 
Lyubo
God Member
*****
Offline


MindFusion team

Posts: 511
Joined: Jun 17th, 2010
Re: Finding items in view
Reply #1 - Sep 26th, 2012 at 6:05am
Print Post  
Hi,

After you've determined the viewport, enumerate the DiagramItem instances in the Diagram.Items collection and check if their bounds intersect with the client rectangle. For example:

Code
Select All
RectangleF viewport = diagramView1.ClientToDoc(diagramView1.ClientRectangle);
List<DiagramItem> visible = new List<DiagramItem>();

foreach (DiagramItem item in diagramView1.Diagram.Items)
{
    if (item.GetBounds().IntersectsWith(viewport))
        visible.Add(item);
} 



Since v6.0 of the component, Diagram item collection types implement the generic IList interface, so the enumaration could be done in a one line Linq query:

Code
Select All
var visible = diagram1.Items.Where(x => x.GetBounds().IntersectsWith(viewport)); 



Regards,
Lyubo
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint