Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Custom node select box (Read 3507 times)
Waterfiets
Junior Member
**
Offline


I Love MindFusion!

Posts: 78
Joined: Sep 27th, 2013
Custom node select box
Oct 7th, 2013 at 7:47am
Print Post  

Hi there,

I was working on creating a custom node for my modeler. This is working fine, and with the this.HandlesStyle = HandlesStyle.MoveOnly i was able to put the node to move only aswell.

The next problem i have can be seen in this screenshot.



The thing is, that the border doesn't fit to the size of the custom node we've created. Could you give us some insight on how to change this?

Thanks in advance.

Greets,

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Custom node select box
Reply #1 - Oct 7th, 2013 at 8:20am
Print Post  
Hi,

If that's a custom Shape object you assign to ShapeNodes, you must specify its coordinates as percentage of the node size, i.e. they should stay within the [0-100] range.

If you draw the shape yourself from DiagramNode.Draw override or by handling the DrawNode event for custom drawing, make sure the coordinates of the graphics primitives you are using are entirely inside the node's bounding rectangle.

You could also draw the selection thingy to match the node's shape by setting node.HandlesStyle = Custom and handling the DrawAdjustmentHandles event, if you don't want it to be a rectangle.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Waterfiets
Junior Member
**
Offline


I Love MindFusion!

Posts: 78
Joined: Sep 27th, 2013
Re: Custom node select box
Reply #2 - Oct 7th, 2013 at 9:57am
Print Post  
Hi Stoyan,

It works, i've created a custom selection thingy, but now i'm not able to move the node inside the diagram frame. Is this because i have to handle the HitTestEventArgs? I've tried to handle it but i'm not completely sure if im on the right track. It's not working atm.

Here is my code for the HitTextEventArgs:
Code
Select All
        void diagram_HitTestAdjustmentHandles(object sender, HitTestEventArgs e)
        {
            ShapeNode shapeNode = e.Item as ShapeNode;
            if (shapeNode != null)
            {
                if (shapeNode.Bounds.Contains(e.MousePosition))
                {
                    e.HitResult = 1;
                }
            }

        } 



Greets,

Sander
  
Back to top
 
IP Logged
 
Waterfiets
Junior Member
**
Offline


I Love MindFusion!

Posts: 78
Joined: Sep 27th, 2013
Re: Custom node select box
Reply #3 - Oct 7th, 2013 at 10:01am
Print Post  
Hi Stoyan,

Nevermind my lastpost, I've found out what i did wrong, i forgot to add it to the eventhandlers. Stupid me Embarrassed

Greets,

Sander
  
Back to top
 
IP Logged
 
Waterfiets
Junior Member
**
Offline


I Love MindFusion!

Posts: 78
Joined: Sep 27th, 2013
Re: Custom node select box
Reply #4 - Oct 7th, 2013 at 1:50pm
Print Post  

Hi Stoyan,

A weird thing came up.

At the moment I've got this custom border on the surface, which is fine. But the thing is, if i want to drag the node to a different location, i can only do this by pressing the left mouse button in the location where there original border was. If i go outside the invisible border but still inside my new border i cant move it.

Greets,

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Custom node select box
Reply #5 - Oct 7th, 2013 at 2:13pm
Print Post  
Hi Sander,

The control checks if a point is inside node.Bounds before calling any other hit-testing code, so your graphics elements are still drawn outside the node's bounding rectangle. Note that the control does not automatically set the node's size to what you draw from within the Draw override. Instead, you will have to set node.Bounds to a large enough Rect to contains all graphics; e.g. if you want a shape covering 350 points by 250 points, set Bounds' width and height to these same values. Bounds is considered by many other functions too, like link routing, grid alignment, automatic layout, etc.

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