public void AddParallelGateway(string id, Boolean converging) { if (!IsIdInUse(id)) { ParallelGateway parallelGateway = new ParallelGateway { id = id, gatewayDirection = (converging ? "Converging" : "Diverging") }; trail.process.parallelGateways.Add(parallelGateway); BPMNShape bPMNShape = new BPMNShape { id = id + "_shape", bpmnElement = id }; bPMNShape.bounds.X = placeX + ""; bPMNShape.bounds.Y = placeY + ""; bPMNShape.bounds.Width = GHW + ""; bPMNShape.bounds.Height = GHW + ""; trail.diagram.bpmnPlane.bpmnShapes.Add(bPMNShape); UpdatePlacement(); } else { throw new Exception("Id in use."); } }
public void RemoveEventWithSequences(string eventId) { if (StartEventExists(eventId)) { StartEvent se = GetStartEvent(eventId); RemoveEventOutGoing(se.outgoing); trail.process.startEvents.RemoveAll(y => y.id.Equals(se.id)); trail.diagram.bpmnPlane.bpmnShapes.RemoveAll(y => y.id.Equals(se.id + "_shape")); } if (EndEventExists(eventId)) { EndEvent ee = GetEndEvent(eventId); RemoveEventInGoing(ee.incoming); trail.process.endEvents.RemoveAll(y => y.id.Equals(ee.id)); trail.diagram.bpmnPlane.bpmnShapes.RemoveAll(y => y.id.Equals(ee.id + "_shape")); } if (TaskExists(eventId)) { Task task = GetTask(eventId); RemoveEventOutGoing(task.outgoing); RemoveEventInGoing(task.incoming); trail.process.tasks.RemoveAll(y => y.id.Equals(task.id)); trail.diagram.bpmnPlane.bpmnShapes.RemoveAll(y => y.id.Equals(task.id + "_shape")); } if (ParallelGatewayExists(eventId)) { ParallelGateway pg = GetParallelGateWay(eventId); RemoveEventOutGoing(pg.outgoing); RemoveEventInGoing(pg.incoming); trail.process.parallelGateways.RemoveAll(y => y.id.Equals(pg.id)); trail.diagram.bpmnPlane.bpmnShapes.RemoveAll(y => y.id.Equals(pg.id + "_shape")); } if (ExclusiveGatewayExists(eventId)) { ExclusiveGateway eg = GetExclusiveGateWay(eventId); RemoveEventOutGoing(eg.outgoing); RemoveEventInGoing(eg.incoming); trail.process.exclusiveGateways.RemoveAll(y => y.id.Equals(eg.id)); trail.diagram.bpmnPlane.bpmnShapes.RemoveAll(y => y.id.Equals(eg.id + "_shape")); } }
public void AddSequenceFlow(string id, string sourceId, string targetId) { if (!trail.process.sequenceFlows.Exists(seq => seq.sourceRef.Equals(sourceId) && seq.targetRef.Equals(targetId) && seq.id.Equals(id))) { SequenceFlow sequenceFlow = new SequenceFlow { id = id, sourceRef = sourceId, targetRef = targetId }; trail.process.sequenceFlows.Add(sequenceFlow); string sourceType = ""; string targetType = ""; int x_target = 0, x_source = 0, y_target = 0, y_source = 0; Bounds b; if (StartEventExists(sourceId)) { StartEvent se = GetStartEvent(sourceId); se.outgoing.Add(id); sourceType = "se"; b = trail.diagram.bpmnPlane.bpmnShapes.Find(x => x.id.Equals(se.id + "_shape")).bounds; x_source = int.Parse(b.X); y_source = int.Parse(b.Y); } else if (StartEventExists(targetId)) { Console.Write("Cannot target start events"); } if (EndEventExists(targetId)) { EndEvent ee = GetEndEvent(targetId); ee.incoming.Add(id); targetType = "se"; b = trail.diagram.bpmnPlane.bpmnShapes.Find(x => x.id.Equals(ee.id + "_shape")).bounds; x_target = int.Parse(b.X); y_target = int.Parse(b.Y); } else if (EndEventExists(sourceId)) { Console.Write("Cannot use end events as source"); } if (TaskExists(sourceId)) { Task task = GetTask(sourceId); task.outgoing.Add(id); sourceType = "task"; b = trail.diagram.bpmnPlane.bpmnShapes.Find(x => x.id.Equals(task.id + "_shape")).bounds; x_source = int.Parse(b.X); y_source = int.Parse(b.Y); } else if (TaskExists(targetId)) { Task task = GetTask(targetId); task.incoming.Add(id); targetType = "task"; b = trail.diagram.bpmnPlane.bpmnShapes.Find(x => x.id.Equals(task.id + "_shape")).bounds; x_target = int.Parse(b.X); y_target = int.Parse(b.Y); } if (ParallelGatewayExists(sourceId)) { ParallelGateway par = GetParallelGateWay(sourceId); par.outgoing.Add(id); sourceType = "gate"; b = trail.diagram.bpmnPlane.bpmnShapes.Find(x => x.id.Equals(par.id + "_shape")).bounds; x_source = int.Parse(b.X); y_source = int.Parse(b.Y); } else if (ParallelGatewayExists(targetId)) { ParallelGateway par = GetParallelGateWay(targetId); par.incoming.Add(id); targetType = "gate"; b = trail.diagram.bpmnPlane.bpmnShapes.Find(x => x.id.Equals(par.id + "_shape")).bounds; x_target = int.Parse(b.X); y_target = int.Parse(b.Y); } if (ExclusiveGatewayExists(sourceId)) { ExclusiveGateway exc = GetExclusiveGateWay(sourceId); exc.outgoing.Add(id); sourceType = "gate"; b = trail.diagram.bpmnPlane.bpmnShapes.Find(x => x.id.Equals(exc.id + "_shape")).bounds; x_source = int.Parse(b.X); y_source = int.Parse(b.Y); } else if (ExclusiveGatewayExists(targetId)) { ExclusiveGateway exc = GetExclusiveGateWay(targetId); exc.incoming.Add(id); targetType = "gate"; b = trail.diagram.bpmnPlane.bpmnShapes.Find(x => x.id.Equals(exc.id + "_shape")).bounds; x_target = int.Parse(b.X); y_target = int.Parse(b.Y); } BPMNEdge bPMNEdge = new BPMNEdge { id = id + "_edge", bpmnElement = id }; Waypoint first = new Waypoint { X = "0", Y = "0" }; Waypoint second = new Waypoint { X = "0", Y = "0" }; switch (sourceType) { case "se": first.Y = SEHW / 2 + y_source + ""; first.X = x_source + ""; break; case "task": first.Y = TH / 2 + y_source + ""; first.X = x_source + ""; break; case "gate": first.Y = GHW / 2 + y_source + ""; first.X = x_source + ""; break; default: break; } switch (targetType) { case "se": second.Y = SEHW / 2 + y_target + ""; second.X = SEHW + x_target + ""; break; case "task": second.Y = TH / 2 + y_target + ""; second.X = TW + x_target + ""; break; case "gate": second.Y = GHW / 2 + y_target + ""; second.X = GHW + x_target + ""; break; default: break; } bPMNEdge.waypoint.Add(first); bPMNEdge.waypoint.Add(second); trail.diagram.bpmnPlane.bpmnEdges.Add(bPMNEdge); } }