Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Customizable GetNodeAt() method (Read 4986 times)
stefski
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 31
Location: Norway
Joined: Jul 17th, 2009
Customizable GetNodeAt() method
May 6th, 2011 at 12:59pm
Print Post  
Hi there,

another feature suggestion coming up...

In our use of Flowchart.NET, we have to deal with the situation that some DiagramItems/DiagramNodes are overlapping each other.

We make use of the DiagramItem.Locked property, DiagramItem.Visible, as well as threshold on finding items with GetNodeAt().

As a result, we now find ourselves in a situation where, when using the GetNodeAt() method, we get the wrong result.

Consider node X and node Y.
Node X.Visible = false.
Node X is on top of node Y.
We expect to get node Y, when using GetNodeAt(), but actually get node X.

I guess we could solve the issue on our side by using GetNodesAt(), though that does not provide the override accepting a threshold.

Another solution would be for the GetNodeAt() ignoring hidden objects (like it is already capable of ignoring selected and locked objects), but I think that would just be yet another override of the method, which would become insufficient as soon as someone else wants yet another kind of filtering.

So my feature suggestion this time is an "open" GetNodeAt() filtering mechanism, through either a delegate or interface argument:

public DiagramNode GetNodeAt(PointF point, float threshold, Predicate<T> match );

In this way the client can put in any condition of satisfaction he wants in the predicate function, like the .NET List<T>.Find( Predicate<T> match ), just that in this case, we get the basic threshold and coordinate matching functionality from FlowChart.NET.
  

Kind regards

Steffen Skov
OLGA Application Architect
Schlumberger Information Solutions AS
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Customizable GetNodeAt() method
Reply #1 - May 6th, 2011 at 4:15pm
Print Post  
Hi,

Ok. You can also implement that using the DiagramNode.ContainsPoint(point, threshold) method:

Code
Select All
DiagramNode GetNodeAt(PointF point, float threshold, Predicate<DiagramNode> match)
{
	for (int i = diagram.Items.Count - 1; i >= 0; i--)
	{
		var node = diagram.Items[i] as DiagramNode;
		if (node == null)
			continue;
		if (!match(node))
			continue;
		if (node.ContainsPoint(point, threshold))
			return node;
	}
	return null;
} 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
stefski
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 31
Location: Norway
Joined: Jul 17th, 2009
Re: Customizable GetNodeAt() method
Reply #2 - May 7th, 2011 at 7:41pm
Print Post  
Thanks Stoyan,

didn't think of ContainsPoint() myself. That little piece of code I think will save my day.

As always, swift and to the point answers. Smiley
  

Kind regards

Steffen Skov
OLGA Application Architect
Schlumberger Information Solutions AS
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint