Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) send event from node not work (Read 6077 times)
PDM.
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 256
Joined: Dec 2nd, 2010
send event from node not work
Jun 12th, 2012 at 8:47am
Print Post  

Hello
I create a node in this way:


          var newobject = new customnode();
          var node = new DiagramNodeAdapter(form, newobject);
           node.MouseLeftButtonDown += new MouseButtonEventHandler(mymousevent);
           node.SizeSyncMode = SizeSyncMode.SetSize;
           node.Bounds = new Rect(e.MousePosition, new Size(100, 100));
           form.Nodes.Add(node);
           node.HandlesStyle = HandlesStyle.Custom;
           node.Selected = true;




Then on the for i have something like:

    private void mymousevent(object sender, MouseButtonEventArgs e)
   {
   //my coder to execute
    }



node.MouseLeftButtonDown += new MouseButtonEventHandler(mymousevent);
is not fired !
Some idea why?

Cheesy
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: send event from node not work
Reply #1 - Jun 12th, 2012 at 8:57am
Print Post  
Hi,

Try setting node.MouseInputMode = HandledByControl, or instead of MouseLeftButtonDown handle the PreviewMouseLeftButtonDown event.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
PDM.
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 256
Joined: Dec 2nd, 2010
Re: send event from node not work
Reply #2 - Jun 12th, 2012 at 9:11am
Print Post  
I alreay try node.PreviewMouseLeftButtonDown += new MouseButtonEventHandler etc etc
Not work!

node.MouseInputMode = HandledByControl,  ?
That o exists : (
  
Back to top
 
IP Logged
 
PDM.
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 256
Joined: Dec 2nd, 2010
Re: send event from node not work
Reply #3 - Jun 12th, 2012 at 9:12am
Print Post  
You make reference to  node.MouseInputMode = MouseInputMode.HandledByHostedControl;

I asume yes, testing now!  : )
  
Back to top
 
IP Logged
 
PDM.
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 256
Joined: Dec 2nd, 2010
Re: send event from node not work
Reply #4 - Jun 12th, 2012 at 9:15am
Print Post  
Using node.MouseInputMode = MouseInputMode.HandledByHostedControl;
No fix the problem, and also no is usefull due after that cant resize node using the handlers Sad
« Last Edit: Jun 12th, 2012 at 10:34am by PDM. »  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: send event from node not work
Reply #5 - Jun 12th, 2012 at 1:05pm
Print Post  
You shouldn't attach a handler to the adapter node, but to the hosted control.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
PDM.
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 256
Joined: Dec 2nd, 2010
Re: send event from node not work
Reply #6 - Jun 12th, 2012 at 2:04pm
Print Post  
Sorry, not understand, som example please.
Anyway no any of this solution work, event never fired.
Some solution please?
THK!
Wink
« Last Edit: Jun 12th, 2012 at 3:42pm by PDM. »  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: send event from node not work
Reply #7 - Jun 12th, 2012 at 4:46pm
Print Post  
After this code

var newobject = new customnode();
var node = new DiagramNodeAdapter(form, newobject);

instead of

node.MouseLeftButtonDown += new MouseButtonEventHandler(mymousevent);

set

newobject.MouseLeftButtonDown += new MouseButtonEventHandler(mymousevent);

I.e. the event will be raised by the hosted control, not by the DiagramNodeAdapter.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
PDM.
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 256
Joined: Dec 2nd, 2010
Re: send event from node not work
Reply #8 - Jun 12th, 2012 at 4:58pm
Print Post  
Sorry but that not work is the first thing i test before post here  in the forum  Sad
  
Back to top
 
IP Logged
 
PDM.
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 256
Joined: Dec 2nd, 2010
Re: send event from node not work
Reply #9 - Jun 12th, 2012 at 5:04pm
Print Post  
           var newobject = new customnode();
           newobject.MouseLeftButtonDown += new MouseButtonEventHandler(mymousevent);
           var node = new DiagramNodeAdapter(form, newobject);
           node.SizeSyncMode = SizeSyncMode.SetSize;
           node.Bounds = new Rect(e.MousePosition, new Size(100, 100));
           form.Nodes.Add(node);
           node.HandlesStyle = HandlesStyle.Custom;
           node.Selected = true;


Also tested with PreviewMouseLeftButtonDown
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: send event from node not work
Reply #10 - Jun 12th, 2012 at 6:54pm
Print Post  
Adding the code below to the FormEditor example shows the debug output for all the types of controls there. If that doesn't work for your customnode control, I suppose it simply never raises the event. You could check if there is some OnPreviewMouseLeftButtonDown override that does not call base - that would prevent the event from being raised.

Code
Select All
private void form_NodeCreated(object sender, NodeEventArgs e)
{
	var adapter = (DiagramNodeAdapter)e.Node;
	adapter.Control.PreviewMouseLeftButtonDown += OnCtrlMouseLeftButtonDown;
	adapter.MouseInputMode = MouseInputMode.HandledByHostedControl;
}

void OnCtrlMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
	Debug.WriteLine("mouse down");
} 



I hope that helps,
Stoyan
« Last Edit: Jun 13th, 2012 at 6:39am by Stoyo »  
Back to top
 
IP Logged
 
PDM.
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 256
Joined: Dec 2nd, 2010
Re: send event from node not work
Reply #11 - Jun 14th, 2012 at 5:29am
Print Post  
Thankyou stoyo, i debuged now and see why event no is fired.
No is fixable.

The question, now is, how can send event from inside of custom node to for have fire some event live in form code?

You know some way to do that?

If yes, can tellme how?

Example:
How can i have this event inside a custom node and make form listen to this event:

this.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(mousevent);

Basically i wnat send event from inside of node to code is located in the form.

If pssible ia apreciate showme some exmaple.

Thankyou
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: send event from node not work
Reply #12 - Jun 14th, 2012 at 10:16am
Print Post  
You could try the following to raise the standard PreviewMouseLeftButtonDown event at any time, or otherwise define and raise your custom event using the usual .NET event pattern.

base.OnPreviewMouseLeftButtonDown(
     new MouseButtonEventArgs(Mouse.PrimaryDevice, DateTime.Now.Millisecond, MouseButton.Left));

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint