Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Dragging of ControlNodes (Read 3996 times)
CPF
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 14
Joined: Mar 16th, 2018
Dragging of ControlNodes
Mar 16th, 2018 at 11:55am
Print Post  
Hi there,

I'm facing a problem right now: I made an application wich lets the user create a controlnode into the diagram, which is filled with a custom control of me (some buttons, labels, etc.).

I want to drag them freely around in the diagram view. This seems only be possible, when I click the fine line between the usercontrol and the node.
What I want: I want to drag it, too, when I'm somewhere else inside the control.

Is that possible?
  
Back to top
 
IP Logged
 
CPF
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 14
Joined: Mar 16th, 2018
Re: Dragging of ControlNodes
Reply #1 - Mar 16th, 2018 at 2:36pm
Print Post  
I made further tests. They didn't solve my problem, but it's a step into the right direction:
The DiagramView Behaviour is set to LinkControls. ControlHandlesStyle is set to MoveOnly and ControlMouseAction is set to Ignore Control.

I made a ControlNode with a button in it, another one with a groupbox in it and a third one with my custom usercontrol in it.
The button-node and the groupbox node behave exactly like I want it to: I can focus it an drag it wherever inside of the node I am clicking.

BUT: My customControl still doesn't move this way, only at the edges.
I don't understand why. Is it because my user control consists of multiple WinformControls? Is it because of a groupbox-frame, which holds all other controls, so that there are too many layers, so the drag event can't be passed to the controlnode lying 'under' them?
Undecided
  
Back to top
 
IP Logged
 
CPF
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 14
Joined: Mar 16th, 2018
Re: Dragging of ControlNodes
Reply #2 - Mar 16th, 2018 at 2:45pm
Print Post  
After further tests I'm pretty sure it's because of the usercontrol containing a groupbox.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Dragging of ControlNodes
Reply #3 - Mar 16th, 2018 at 2:46pm
Print Post  
Hi,

If only for buttons and labels, better try using CompositeNodes instead of ControlNodes.

You should be able to move from inside a ControlNode by setting node.ControlMouseAction = IgnoreControl, also on the condition that the control does not capture mouse events. It only listens to MouseDown and MouseUp events of root hosted control though, and not of its child controls. If you also want the diagram to detect clicks on child controls, you must raise UserControl's MouseDown/Up events yourself when any child control is clicked.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
CPF
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 14
Joined: Mar 16th, 2018
Re: Dragging of ControlNodes
Reply #4 - Mar 16th, 2018 at 3:20pm
Print Post  
Thanks for the quick reply!

How do I add a customControl into a composite node? My custom control is very complex, it holds a creature for an RPG with a lot of functionality. You'll find two example nodes in the attachement.
  

2018-03-16_16_19_59-Start.png ( 109 KB | 116 Downloads )
2018-03-16_16_19_59-Start.png
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Dragging of ControlNodes
Reply #5 - Mar 16th, 2018 at 3:48pm
Print Post  
You cannot add user controls to composite nodes, the latter were meant to replace control nodes because hosted controls don't mix very well with the rest of the diagram - there are problems with z order, printing, zooming, also interaction as you see. You should still be able to reproduce your control from the image using CompositeNodes, e.g. by arranging TextComponents, ImageComponents and ButtonComponents in a Grid layout.

Regards,
Slavcho
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Dragging of ControlNodes
Reply #6 - Mar 16th, 2018 at 4:06pm
Print Post  
Alternatively check our WPF diagram component and create WPF user controls instead - integration of external components is better there as nodes and any other FrameworkElements are part of the same WPF visual tree.
  
Back to top
 
IP Logged
 
CPF
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 14
Joined: Mar 16th, 2018
Re: Dragging of ControlNodes
Reply #7 - Mar 27th, 2018 at 12:30pm
Print Post  
Is it possible to add the suggested WPF diagram component into a winforms application?

But I'm more likely willing to pass the mousemove events from my usercontrol to the parent node, which is containing my user control. I tried to hook the events, but the ControlNode doesn't provide any mouse events like mousemove. How is it possible to do it that way?
  
Back to top
 
IP Logged
 
CPF
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 14
Joined: Mar 16th, 2018
Re: Dragging of ControlNodes
Reply #8 - Mar 27th, 2018 at 12:47pm
Print Post  
Cheesy Cheesy Cheesy Thanks god, I found a simple and effective solution for my problem which I want to let you know:

When you override the WndProc Funktion of every panel layer, the movin is exactly passed in the way I want! In my case, I did an override for the groupbox and an override for the panel control arranging all those buttons and labels and now it works!
Just use the ovewritten Controls in the usercontrol. An example for an overwritten GroupBox:

public class GroupBoxMovable : GroupBox
{
    protected override void WndProc(ref Message m)
    {
        const int WM_NCHITTEST = 0x0084;
        const int HTTRANSPARENT = (-1);

        if (m.Msg == WM_NCHITTEST)
        {
            m.Result = (IntPtr)HTTRANSPARENT;
        }
        else
        {
            base.WndProc(ref m);
        }
    }
}
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Dragging of ControlNodes
Reply #9 - Mar 27th, 2018 at 1:07pm
Print Post  
Nice solution that Smiley You should be able to host WPF diagram control in WinForms using this class otherwise -

https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.integration.ele...

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