Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Implementing a custom behavior (Read 4748 times)
petrux
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 3
Joined: Aug 12th, 2011
Implementing a custom behavior
Aug 12th, 2011 at 9:40am
Print Post  
Hi there,

I'm a newbie and this is my first post. ^_^ Here is my question. I'm trying to implement this behavior on a diagram:

1. right click on thi diagram:
1.1 if no node is hit, create a new node
1.2 if a node is hit, user can draw a link to another node having the right mous button pressed, when the right mouse button is released, the link is created. I'd like to have the link preview in this case. But I really can't figure out how to achieve this behavior.

Could you help me (or link any documentation about the issue)?

thanks,
petrux - Italy

--
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Implementing a custom behavior
Reply #1 - Aug 12th, 2011 at 12:24pm
Print Post  
Unfortunately this is not currently possible because the right mouse button cannot be associated with a drawing action. I will see if we can modify the control to support this behavior through customization.

Regards,
Meppy
  
Back to top
 
IP Logged
 
petrux
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 3
Joined: Aug 12th, 2011
Re: Implementing a custom behavior
Reply #2 - Aug 12th, 2011 at 12:27pm
Print Post  
Meppy wrote on Aug 12th, 2011 at 12:24pm:
Unfortunately this is not currently possible because the right mouse button cannot be associated with a drawing action. I will see if we can modify the control to support this behavior through customization.


thanks for your reply.
I'll stay tuned! Smiley

Bye,
petrux

--
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Implementing a custom behavior
Reply #3 - Aug 15th, 2011 at 7:35am
Print Post  
Get this version of the control:

https://mindfusion.eu/download/WpfDiagram.2.6a.trial.zip

The above version adds a new mouse button action for the right mouse button - Draw. By using the following code, you will enable interactive creation of nodes and links through the right mouse button:

Code
Select All
diagram.RightButtonActions = MouseButtonActions.Draw; 


Now, in order to create new nodes on click (rather than on click & drag), you need to create a custom behavior class:

Code
Select All
public class CustomBehavior : LinkShapesBehavior
{
      public CustomBehavior(Diagram view)
            : base(view)
      {
      }

      protected override void OnMouseDown(Point mousePosition, MouseButton mouseButton)
      {
            if (mouseButton == MouseButton.Right)
            {
                  var node = Diagram.GetNodeAt(mousePosition);
                  if (node == null)
                  {
                        Diagram.Factory.CreateShapeNode(mousePosition.X - 20, mousePosition.Y - 20, 40, 40);
                        Diagram.CancelDrag();
                  }
            }

            base.OnMouseDown(mousePosition, mouseButton);
      }
} 


To use this behavior, assign an instance of this class to the Diagram.CustomBehavior:

Code
Select All
diagram.CustomBehavior = new CustomBehavior(diagram); 


Now, new nodes should be created through right-clicking and links should be created through right-clicking and dragging. Note, that the size of the newly created nodes is hardcoded in the CustomBehavior.OnMouseDown method above.

Regards,
Meppy
  
Back to top
 
IP Logged
 
petrux
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 3
Joined: Aug 12th, 2011
Re: Implementing a custom behavior
Reply #4 - Aug 16th, 2011 at 10:24am
Print Post  
Hi Meppy,

Meppy wrote on Aug 15th, 2011 at 7:35am:
Get this version of the control:

https://mindfusion.eu/download/WpfDiagram.2.6a.trial.zip
[cut]
Regards,
Meppy


thanks for your quick reply. I'll download the trial and try to do something good. By the way - as I assume you're in the development team - is there any address which I can send any suggestion (mostly about documentation)?

Thanks and have a nice day,
petrux

--
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Implementing a custom behavior
Reply #5 - Aug 16th, 2011 at 10:54am
Print Post  
All suggestions are welcome. Send them along with any additional questions you might have to support@mindfusion.eu.

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