Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic How can I navigate through nodes (Read 2832 times)
francisco.leonardo
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 6
Joined: Jan 30th, 2008
How can I navigate through nodes
Mar 26th, 2008 at 12:53pm
Print Post  
I need navigate through the diagram nodes using the directional keys from keyboard (up, down, left, right). How can I do this?

Thanks,
Francisco
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How can I navigate through nodes
Reply #1 - Mar 26th, 2008 at 1:08pm
Print Post  
You will have to inherit from the DiagramView class and override its IsInputKey method:

Code
Select All
protected override bool IsInputKey(keys keyData)
{
	switch (keyData)
	{
		case keys.Up:
		case keys.Down:
		case keys.Left:
		case keys.Right:
			return true;
		default:
			return base.IsInputKey(keyData);
	}
}
 



Then you will receive DiagramView.KeyDown events and can navigate through the nodes according to the pressed key.

Stoyan
  
Back to top
 
IP Logged
 
francisco.leonardo
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 6
Joined: Jan 30th, 2008
Re: How can I navigate through nodes
Reply #2 - Mar 27th, 2008 at 7:49pm
Print Post  
I'm using the DiagramView KeyUp event to call the appropriate method depending on the key. For example, if I press and release the UP key I'm calling a OnDirectionalUpKey() method. In this method I need to select the nearest node above the current node. There is any easy way to tho this? Or I will need to implement an algorithm to increment X and Y coords and call the GetNodeAt(x,y) method?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How can I navigate through nodes
Reply #3 - Mar 28th, 2008 at 10:35am
Print Post  
Hi,

https://mindfusion.eu/_temp/fcnet504.zip

We've added a Diagram.Navigate(PointF directionVector) method for you. It looks for the nearest item in the specified direction from the ActiveItem, and selects it. You could use it like this

PointF right = new PointF(1, 0);
diagram.Navigate(right);

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
francisco.leonardo
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 6
Joined: Jan 30th, 2008
Re: How can I navigate through nodes
Reply #4 - Mar 28th, 2008 at 7:17pm
Print Post  
Stoyo,

Thanks for the example. It works, but I had to do some workarounds because the navigation wasn't uniform. Sometimes the diagram.Navigate() method isn't activating any item so the diagram.ActiveItem property is returning NULL.

Although, this files that you sent me are trial. I have a license of the version 5.0.3. How can I proceed to have the same non trial files?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How can I navigate through nodes
Reply #5 - Mar 28th, 2008 at 7:44pm
Print Post  
So what part of the navigation isn't uniform? - we would like to improve it. I will send you a PM with a link to the full version, if you've registered on the forum with the same email you used when purchased the license. Otherwise - please e-mail me from that address.

Thanks,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint