Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic How can I add multiple decisions nodes to the sing (Read 2510 times)
deepak
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 19
Joined: Jun 29th, 2011
How can I add multiple decisions nodes to the sing
Jul 26th, 2011 at 11:36am
Print Post  
Hi

I want to add the multiple decision nodes to the one activity node.
By default one decision node is connected to the activity node.
When I drag the decision node & drop on activity link then I want to add the second decision node(single decision node created) under the activity node.


        _____________
            |Activity Node|
               -------------
                     |
                     |drop here
          -------------------------
        |            |               |
       / \          / \            / \
      /   \        /   \          /   \
     /       \     /      \       /     \
   /default\ / New  \   / New \
    \ node / \ Node /   \ Node/
     \       /   \        /      \     / 
      \    /       \    /         \   / 
       \_/         \  /           \ /
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: How can I add multiple decisions nodes to the
Reply #1 - Jul 26th, 2011 at 12:12pm
Print Post  
Check the WorkflowDesigner sample. It demonstrates a very similar scenario.

Let me know if this helps.

Regards,
Meppy
  
Back to top
 
IP Logged
 
deepak
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 19
Joined: Jun 29th, 2011
Re: How can I add multiple decisions nodes to the
Reply #2 - Jul 27th, 2011 at 5:19am
Print Post  
I already refer this sample. It’s not working what I want.
I used the following code.
private void diagramView1_DragDrop(object sender, DragEventArgs e)
{
   case "Activity":
        CreateActivity(link);
        break;
   case "IfElse":
        CreateNewIfElse(link);
        break;
   case "While":
        CreateWhile(link);
        break;
   case "Process":
        CreateProcess(link);
        break;
   case "Decision":
        CreateDecision(link);
        break;
}
private void CreateProcess(DiagramLink link)
{
   DiagramLink lastLink = diagram.Links[diagram.Links.Count - 1];
   CreateActivityNew(lastLink);
}
private void CreateActivityNew(DiagramLink link)
{
   ShapeNode origin = link.Origin as ShapeNode;
   ShapeNode dest = link.Destination as ShapeNode;

   string oldLogicID = link.LayoutTraits[Connector].ToString();
   diagram.Links.Remove(link);

   ShapeNode newActivity = diagram.Factory.CreateShapeNode(defaultPosition, Shapes.Process);
   newActivity.LayoutTraits[WorkflowItemId] = "Activity";
   diaNodeID += 1;
   newActivity.Id = diaNodeID;

   ShapeNode newActivity1 = diagram.Factory.CreateShapeNode(defaultPosition, Shapes.Decision);
   newActivity.LayoutTraits[WorkflowItemId] = "Activity";

   CreateLink(origin, newActivity, true, oldLogicID);
   CreateLink(newActivity, newActivity1, true, oldLogicID);
   CreateLink (newActivity1,dest ,true,"ControlFlow");
   LayoutDiagram();

   view.BeginEdit(newActivity);
}

When I drag a new decision node after activity


private void CreateDecision(DiagramLink link)
{
  ShapeNode origin = link.Origin as ShapeNode;
  ShapeNode dest = link.Destination as ShapeNode;

  string oldLogicID = link.LayoutTraits[Connector].ToString();
  diagram.Links.Remove(link);
  ShapeNode newActivity = diagram.Factory.CreateShapeNode(defaultPosition, Shapes.Decision);
  newActivity.LayoutTraits[WorkflowItemId] = "Activity";
  diaNodeID += 1;
  newActivity.Id = diaNodeID;

  CreateLink(origin, newActivity, true, oldLogicID);
  CreateLink(newActivity, dest, true, "ControlFlow");
  LayoutDiagram();
  view.BeginEdit(newActivity);
}

New decision node created near old decision node.But this code is creating a new decision node above the old decision node. I don’t have this output.

private void CreateProcess(DiagramLink link)
{
   DiagramLink lastLink = diagram.Links[diagram.Links.Count - 1];
   CreateIfElseNew(lastLink);
   DiagramLink trueLink = diagram.Links[diagram.Links.Count - 3];
   DiagramLink falseLink = diagram.Links[diagram.Links.Count - 2];
   CreateActivityNew(trueLink);
   CreateActivityNew(falseLink);
}

private void CreateIfElseNew(DiagramLink link)
{
   ShapeNode origin = link.Origin as ShapeNode;
   ShapeNode dest = link.Destination as ShapeNode;

   string oldLogicID = link.LayoutTraits[Connector].ToString();
   diagram.Links.Remove(link);

   ShapeNode decision = diagram.Factory.CreateShapeNode(defaultPosition, Shapes.Process);
   decision.Text = "Condition";
   decision.LayoutTraits[WorkflowItemId] = "IfElse";
   decision.LayoutTraits[PairStart] = diagram.Tag;

   ShapeNode endIf = diagram.Factory.CreateShapeNode(smallSize, Shapes.Ellipse);
   endIf.Text = "";
   endIf.LayoutTraits[PairEnd] = diagram.Tag;

   CreateLink(origin, decision, true, oldLogicID);
   CreateLink(decision, endIf, true, "Yes");
   CreateLink(decision, endIf, true, "No");
   CreateLink(endIf, dest, true, "ControlFlow");

   LayoutDiagram();
   diagram.Tag = (int)diagram.Tag + 1;
}

Its not get the proper output. This code is creating a two new decision node but not move the earlier decision node to left hand side (shown in above diagram). & it’s creating only two decision nodes but some times I have to create one or two or more… decision node. It depends on the condition.
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: How can I add multiple decisions nodes to the
Reply #3 - Jul 27th, 2011 at 6:45am
Print Post  
You have to modify the logic to match your specific needs. Try the following:

Code
Select All
private void CreateActivity(DiagramLink link)
{
      ShapeNode origin = link.Origin as ShapeNode;
      ShapeNode dest = link.Destination as ShapeNode;

      string oldLogicID = link.LayoutTraits[Connector].ToString();
      //diagram.Links.Remove(link);

      ShapeNode newActivity = diagram.Factory.CreateShapeNode(defaultPosition, Shapes.Process);
      newActivity.LayoutTraits[WorkflowItemId] = "Activity";

      CreateLink(origin, newActivity, true, oldLogicID);
      //CreateLink(newActivity, dest, true, "ControlFlow");
} 


However, I'm not sure that the layout implemented in the WorkflowDesigner sample can handle the resulting structure. You may have to try some of the built-in layouts, such as TreeLayout or FlowchartLayout:

Code
Select All
TreeLayout l = new TreeLayout();
l.LinkStyle = TreeLayoutLinkType.Cascading3;
l.Arrange(diagram); 


I hope this helps.

Regards,
Meppy
  
Back to top
 
IP Logged
 
deepak
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 19
Joined: Jun 29th, 2011
Re: How can I add multiple decisions nodes to the
Reply #4 - Jul 27th, 2011 at 11:15am
Print Post  
It’s not working. Please give me any other suggestion.
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: How can I add multiple decisions nodes to the
Reply #5 - Jul 27th, 2011 at 11:54am
Print Post  
What exactly is not working - it doesn't link the newly created node properly or the subsequent layout does not produce the expected result?

Can you try this sample and see if it behaves as expected:

https://mindfusion.eu/_samples/_sample_WorkflowDesigner.zip

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