protected internal virtual double CalculateXCoordinate(IBounds boundaryEventBounds) { var attachedToElement = FindBpmnShape(element); double x = 0; if (attachedToElement != null) { var attachedToBounds = attachedToElement.Bounds; ICollection <IBoundaryEvent> boundaryEvents = element.ParentElement.GetChildElementsByType <IBoundaryEvent>(typeof(IBoundaryEvent)); ICollection <IBoundaryEvent> attachedBoundaryEvents = new List <IBoundaryEvent>(); var iterator = boundaryEvents.GetEnumerator(); while (iterator.MoveNext()) { var tmp = iterator.Current; if (tmp.AttachedTo.Equals(element)) { attachedBoundaryEvents.Add(tmp); } } var attachedToX = attachedToBounds.GetX() .Value; var attachedToWidth = attachedToBounds.GetWidth() .Value; var boundaryWidth = boundaryEventBounds.GetWidth() .Value; switch (attachedBoundaryEvents.Count) { case 2: { x = attachedToX + attachedToWidth / 2 + boundaryWidth / 2; break; } case 3: { x = attachedToX + attachedToWidth / 2 - 1.5 * boundaryWidth; break; } default: { x = attachedToX + attachedToWidth / 2 - boundaryWidth / 2; break; } } } return(x); }
protected internal virtual void ResizeSubProcess(IBpmnShape innerShape) { IBaseElement innerElement = innerShape.BpmnElement; IBounds innerShapeBounds = innerShape.Bounds; IModelElementInstance parent = innerElement.ParentElement; while (parent is ISubProcess) { IBpmnShape subProcessShape = FindBpmnShape((ISubProcess)parent); if (subProcessShape != null) { IBounds subProcessBounds = subProcessShape.Bounds; double innerX = innerShapeBounds.GetX().Value; double innerWidth = innerShapeBounds.GetWidth().Value; double innerY = innerShapeBounds.GetY().Value; double innerHeight = innerShapeBounds.GetHeight().Value; double subProcessY = subProcessBounds.GetY().Value; double subProcessHeight = subProcessBounds.GetHeight().Value; double subProcessX = subProcessBounds.GetX().Value; double subProcessWidth = subProcessBounds.GetWidth().Value; double tmpWidth = innerX + innerWidth + Space; double tmpHeight = innerY + innerHeight + Space; if (innerY == subProcessY) { subProcessBounds.SetY(subProcessY - Space); subProcessBounds.SetHeight(subProcessHeight + Space); } if (tmpWidth >= subProcessX + subProcessWidth) { double newWidth = tmpWidth - subProcessX; subProcessBounds.SetWidth(newWidth); } if (tmpHeight >= subProcessY + subProcessHeight) { double newHeight = tmpHeight - subProcessY; subProcessBounds.SetHeight(newHeight); } innerElement = (ISubProcess)parent; innerShapeBounds = subProcessBounds; parent = innerElement.ParentElement; } else { break; } } }