/// <summary>
        /// Parse all bpmn shapes and bpmn edges and their associations and attributes from one <see cref="BpmnPlane"/>
        /// </summary>
        /// <param name="xNode">The XML node to start with</param>
        private BpmnPlane BuildPlane(XElement xNode)
        {
            var plane = new BpmnPlane(xNode, Elements);

            if (plane.Element == null)
            {
                return(null);
            }

            // All Shapes
            foreach (var xChild in BpmnNM.GetElements(xNode, BpmnNM.BpmnDi, BpmnDiConstants.BpmnShapeElement))
            {
                var shape = new BpmnShape(xChild, Elements);
                if (shape.Element != null)
                {
                    plane.AddShape(shape);
                }
                else
                {
                    Messages.Add("Error in parsing shape " + (shape.Id) + ", could not find corresponding BPMNElement.");
                    continue;
                }

                // Shapes usually define their bounds
                shape.AddBounds(BpmnNM.GetElement(xChild, BpmnNM.Dc, BpmnDiConstants.BoundsElement));

                // Shapes can have a BPMNLabel as child
                var bpmnLabel = BpmnNM.GetElement(xChild, BpmnNM.BpmnDi, BpmnDiConstants.BpmnLabelElement);
                if (bpmnLabel != null)
                {
                    // Label bounds
                    var bounds = BpmnNM.GetElement(bpmnLabel, BpmnNM.Dc, BpmnDiConstants.BoundsElement);
                    shape.AddLabel(bounds);
                    // BpmnLabelStyle
                    shape.LabelStyle = BpmnNM.GetAttributeValue(bpmnLabel, BpmnNM.BpmnDi, BpmnDiConstants.LabelStyleAttribute);
                }
            }

            foreach (var xChild in BpmnNM.GetElements(xNode, BpmnNM.BpmnDi, BpmnDiConstants.BpmnEdgeElement))
            {
                var edge = new BpmnEdge(xChild, Elements);
                if (edge.Element != null)
                {
                    plane.AddEdge(edge);
                }
                else
                {
                    Messages.Add("Error in parsing edge " + (edge.Id) + ", could not find corresponding BPMNElement.");
                    continue;
                }

                // Edges define 2 or more Waypoints
                foreach (var waypoint in BpmnNM.GetElements(xChild, BpmnNM.Di, BpmnDiConstants.WaypointElement))
                {
                    edge.AddWayPoint(waypoint);
                }

                // Edges can have a BPMNLabel as child
                var bpmnLabel = BpmnNM.GetElement(xChild, BpmnNM.BpmnDi, BpmnDiConstants.BpmnLabelElement);
                if (bpmnLabel != null)
                {
                    // Label bounds
                    var bounds = BpmnNM.GetElement(bpmnLabel, BpmnNM.Dc, BpmnDiConstants.BoundsElement);
                    edge.AddLabel(bounds);
                    // BpmnLabelStyle
                    edge.LabelStyle = BpmnNM.GetAttributeValue(bpmnLabel, BpmnNM.BpmnDi, BpmnDiConstants.LabelStyleAttribute);
                }
            }
            return(plane);
        }
Example #2
0
 /// <summary>
 /// Adds a new <see cref="BpmnShape"/> to this planes list of shapes.
 /// </summary>
 /// <param name="shape">Shape to add</param>
 public void AddShape(BpmnShape shape)
 {
     ListOfShapes.Add(shape);
 }