Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic How to delete ShapeNode or Link Programatically (Read 4638 times)
saad
Full Member
***
Offline


I Love MindFusion!

Posts: 117
Joined: Oct 8th, 2012
How to delete ShapeNode or Link Programatically
Oct 30th, 2012 at 3:57pm
Print Post  
In imagemap server side asp.net code, how do you delete a shapenode or link, programatically?
  
Back to top
 
IP Logged
 
saad
Full Member
***
Offline


I Love MindFusion!

Posts: 117
Joined: Oct 8th, 2012
Re: How to delete ShapeNode or Link Programatically
Reply #1 - Oct 30th, 2012 at 7:38pm
Print Post  
My purpose was to delete a link if it was originating or its destination was a lane.

Here is how I did it.

In protected void diagramView_LinkCreated(object sender, LinkEventArgs e)

Code
Select All
// refering diagram
        Diagram diagramPB = diagramView.Diagram;

 // delete / remove current link if its associated with a stage/lane

            // iterate through lanes/stages
            for (int i = 1; i <= extVarStages; i++)
            {
                // reference current node (lane/stage) to compare with
                ShapeNode currShapeNode = diagramPB.FindNodeById("Stage " + i) as ShapeNode;

                // check if current links' origin or destination node is any stage/lane
                if (e.Link.Origin == currShapeNode | e.Link.Destination == currShapeNode)
                {

                    // get index of current link
                    int indexOfCurrLink = diagramPB.Links.IndexOf(e.Link);

                    // if current link exists
                    if (diagramPB.Links.GetAt(indexOfCurrLink) != null)
                    {
                        // remove link from diagram at position specified by index of current link
                        diagramPB.Links.RemoveAt(indexOfCurrLink);

                        // refresh page while maintaining URL with any querystrings
                        Response.Redirect(Request.RawUrl);
                    }
                }

            }
 

« Last Edit: Oct 30th, 2012 at 9:19pm by saad »  
Back to top
 
IP Logged
 
saad
Full Member
***
Offline


I Love MindFusion!

Posts: 117
Joined: Oct 8th, 2012
Re: How to delete ShapeNode or Link Programatically
Reply #2 - Oct 30th, 2012 at 9:22pm
Print Post  
In above code i came up with i'm making a major mistake here:

Code
Select All
// refresh page while maintaining URL with any querystrings
                        Response.Redirect(Request.RawUrl); 



In turn I changed it to:

Code
Select All
UpdatePanel1.Update(); 



Which is fine except now the image of the arrow remains plastered on the screen.

This is not efficient.

Is there is a way to prevent a shapenode from having incoming or outgoing links?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to delete ShapeNode or Link Programatically
Reply #3 - Oct 31st, 2012 at 7:40am
Print Post  
Deleting the newly created link from LinkCreated should look like this:

diagram.Links.Remove(e.Link);

without updating or redirecting anything afterwards. That doesn't show an arrow plastered on the screen in my test. Setting Locked = true for your lane nodes should prevent drawing links to them.

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


I Love MindFusion!

Posts: 117
Joined: Oct 8th, 2012
Re: How to delete ShapeNode or Link Programatically
Reply #4 - Oct 31st, 2012 at 7:42am
Print Post  
Solved
Excellent!
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint