Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic WPF- Swimlane implementation (Read 7110 times)
Asha Shaik
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 6
Location: Chennai
Joined: Jun 13th, 2013
WPF- Swimlane implementation
Sep 19th, 2013 at 12:38pm
Print Post  
Hi,
I have parsed and imported an xpdl file .This xpdl file contains swimlanes. Now I want to know in Mindfusion WPF- how to draw swimlanes and how to assign shapenodes to swimlanelayout as same as xpdl input file .Attached a sample xpdl file screenshot
  

Move_Out_Process.jpg (Attachment deleted)
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: WPF- Swimlane implementation
Reply #1 - Sep 19th, 2013 at 1:16pm
Print Post  
Hi,

To show swimlanes, set Diagram.EnableLanes and add Header objects to Diagram.LaneGrid.RowHeaders to create rows in the grid. You can also add to Header.SubHeaders to create sub-lanes. For an example, see the Lanes sample project.

You can assign the lane index to node.LayoutTraits[SwimlaneLayoutTraits.Lane] to enable arranging the diagram using SimlaneLayout.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Asha Shaik
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 6
Location: Chennai
Joined: Jun 13th, 2013
Re: WPF- Swimlane implementation
Reply #2 - Sep 20th, 2013 at 6:20am
Print Post  
Hi,

Thanks for the reply.
But still I want to know how to assign
shapeNode.LayoutTraits[SwimlaneLayoutTraits.Lane]  to swimlanes indexes  - I have only Height,Width,(X,Y) coordinates of shapes and swimlanes.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: WPF- Swimlane implementation
Reply #3 - Sep 20th, 2013 at 6:57am
Print Post  
If all swimlanes have the same height, you can set index = (int)(node.Bounds.Y / laneHeight). If the swimlanes can have varying heights, you will have to loop over the bounding rectangles of all lanes and check which one contains node.Bounds.Location.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Asha Shaik
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 6
Location: Chennai
Joined: Jun 13th, 2013
Re: WPF- Swimlane implementation
Reply #4 - Sep 20th, 2013 at 7:44am
Print Post  
Hi,

Can you help me on how to get bounding rectangles of a lane  for comparision of node.Bounds.Location.

If you can share code for adding nodes to varying height lanes in swimlane layout it is much useful.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: WPF- Swimlane implementation
Reply #5 - Sep 20th, 2013 at 8:19am
Print Post  
Hi,

Check the diagram_NodeCreated handler in ProcessLayout sample project. It shows how to find the swimlane containing a node once you have built the grid.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Asha Shaik
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 6
Location: Chennai
Joined: Jun 13th, 2013
Re: WPF- Swimlane implementation
Reply #6 - Sep 20th, 2013 at 12:30pm
Print Post  
Hi,

I was not able to get the desired output.Below is the code used.
   private void AssignSwimlanes()
        {
            string[] strSwimlaneProperties = new string[30];
            diagDrawModel.EnableLanes = true;
            diagDrawModel.LaneGrid.AllowResizeHeaders = true;
            diagDrawModel.LaneGrid.AllowInplaceEdit = true;
            diagDrawModel.LaneGrid.RowCount = swimlaneEntities.Keys.Count;
//swimlaneEntities is a dictionary holding ID,Name,Height,Width,X,y  values of swimlanes
            //Logic for same height swimlanes
            //foreach (int iKey in swimlaneEntities.Keys)
            //{
            //    strSwimlaneProperties = (string[])swimlaneEntities[iKey];
            //    if (strSwimlaneProperties[1].ToString() != "")
            //    {
            //        diagDrawModel.LaneGrid.RowHeaders.Add(new Header(strSwimlaneProperties[1].ToString()) { Width = Convert.ToInt32(strSwimlaneProperties[3].ToString()), Height = Convert.ToInt32(strSwimlaneProperties[2].ToString()) });
            //    }
            //    //foreach (ShapeNode shpNode in diagDrawModel.Nodes)
            //    //{
            //    //    shpNode.LayoutTraits[SwimlaneLayoutTraits.Lane] = (int)(shpNode.Bounds.Y / Convert.ToInt32(strSwimlaneProperties[2].ToString()));
            //    //}

            //}


            //Logic for varying height swimlanes
            foreach (int iKey in swimlaneEntities.Keys)
            {
                strSwimlaneProperties = (string[])swimlaneEntities[iKey];
                if (strSwimlaneProperties[1].ToString() != "")
                {
                    diagDrawModel.LaneGrid.RowHeaders.Add(new Header(strSwimlaneProperties[1].ToString()) { Width = Convert.ToInt32(strSwimlaneProperties[3].ToString()), Height = Convert.ToInt32(strSwimlaneProperties[2].ToString()) });
                }
            }

                foreach (ShapeNode shpNode in diagDrawModel.Nodes)
                {
                    Rect cellBounds = new Rect();
                    ICell cell = diagDrawModel.LaneGrid.GetCellFromPoint(shpNode.GetCenter(), ref cellBounds);
                    if (cell != null)
                    {
                        int index = diagDrawModel.LaneGrid.GetCellRow(cell);
                        foreach (int iKey1 in swimlaneEntities.Keys)
                        {
                            strSwimlaneProperties = (string[])swimlaneEntities[iKey1];
                           
                        }
                        shpNode.LayoutTraits[SwimlaneLayoutTraits.Lane] = index;
                    }
                }
            
            swimlaneEntities.Clear();
        }

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: WPF- Swimlane implementation
Reply #7 - Sep 20th, 2013 at 1:08pm
Print Post  
The Width you are setting on row Header objects does not specify the width of the whole row, but only its header area. You will have to add a column to the grid too by adding a Header to ColumnHeaders, and set its Width to the desired width of the grid.

Setting RowCount creates a set of empty Header objects automatically, and later you are adding to it, creating twice the number of rows. You should either start from RowCount = 0 and add new headers, or set RowCount to the actual value and do not add headers but modify the ones created by RowCount setter.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Asha Shaik
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 6
Location: Chennai
Joined: Jun 13th, 2013
Re: WPF- Swimlane implementation
Reply #8 - Sep 23rd, 2013 at 6:04am
Print Post  
Hi ,

I have made the changes as you mentioned in mail but still I am not getting desired output. It displays only 4 swimlanes .But while debugging it is adding all the 6 swimlanes.



Can you share any code sample for varying height swimlanes .
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: WPF- Swimlane implementation
Reply #9 - Sep 23rd, 2013 at 6:23am
Print Post  
Hi,

If you are running SwimlaneLayout, it automatically sets the grid's RowCount to the largest lane index assigned to nodes. So if the last lanes of the grid are empty, you will have to add them after layout.

If there are empty lanes in the middle of the grid, they are collapsed to 0 height by default; set CollapseEmptyLanes = false to prevent that. You might also want to set the KeepLaneSizes property to preserve the heights imported from your xpdl files.

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