Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Prevent a shape from going outside the bounds of diagramview (Read 3360 times)
saad
Full Member
***
Offline


I Love MindFusion!

Posts: 117
Joined: Oct 8th, 2012
Prevent a shape from going outside the bounds of diagramview
Oct 25th, 2012 at 6:49am
Print Post  
Any way to prevent the shape so that if its dragged way too over the edge, it falls back right at the end of the diagram bounds instead of being cut off like in the photo attached?
  

Capture_023.PNG (Attachment deleted)
Back to top
 
IP Logged
 
saad
Full Member
***
Offline


I Love MindFusion!

Posts: 117
Joined: Oct 8th, 2012
Re: Prevent a shape from going outside the bounds of diagramview
Reply #1 - Oct 25th, 2012 at 7:03am
Print Post  
This

Code
Select All
diagram.RestrictItemsToBounds= RestrictToBounds.InsideOnly; 



does nothing to prevent the behavior mentioned.

What's it supposed to do anyway?
  
Back to top
 
IP Logged
 
saad
Full Member
***
Offline


I Love MindFusion!

Posts: 117
Joined: Oct 8th, 2012
Re: Prevent a shape from going outside the bounds of diagramview
Reply #2 - Oct 25th, 2012 at 4:06pm
Print Post  
Is there a way to prevent a shape drifting off the Bounds.Bottom of diagram?

  

Capture_025.PNG (Attachment deleted)
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Prevent a shape from going outside the bounds of diagramview
Reply #3 - Oct 25th, 2012 at 4:21pm
Print Post  
Apparently that property is used only in the Windows version. You could handle NodeModified to return the node to the diagram's bounding rect. E.g. if you detect that node.Bounds.Bottom > diagram.Bounds.Bottom, or corresponding comparison for Right, then you return the node to position diagram.Bounds.Bottom - node.Bounds.Height or diagram.Bounds.Right - node.Bounds.Width.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
saad
Full Member
***
Offline


I Love MindFusion!

Posts: 117
Joined: Oct 8th, 2012
Re: Prevent a shape from going outside the bounds of diagramview
Reply #4 - Oct 30th, 2012 at 7:51pm
Print Post  
Solved

Heres how:

In protected void diagramView_NodeModified(object sender, NodeEventArgs e)

Code
Select All
// adjust DIAGRAM HEIGHT as lanes are added / dropped to compact the diagram around lanes

        // refering diagram
        //Diagram diagramPB = diagramView.Diagram;

        // finding last stage
        ShapeNode lastShapeNode = diagramPB.FindNodeById("Stage " + extVarStages) as ShapeNode;

        // check if last shape node's bottom is greater than diagram height,
        // if so increase diagram height to last shape node's bottom
        if (lastShapeNode.Bounds.Bottom > diagramHeight)
        {

            diagramHeight = Convert.ToInt32(lastShapeNode.Bounds.Bottom);
            diagramPB.Bounds = new System.Drawing.RectangleF(0, 0, diagramWidth, diagramHeight);
        }

        // check if last shape node's bottom is lesser than diagram height,
        // if so decrease diagram height to last shape node's bottom
        if (lastShapeNode.Bounds.Bottom < diagramHeight)
        {

            diagramHeight = Convert.ToInt32(lastShapeNode.Bounds.Bottom);
            diagramPB.Bounds = new System.Drawing.RectangleF(0, 0, diagramWidth, diagramHeight);
        }
 

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