コード例 #1
0
        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;
                }
            }
        }
コード例 #2
0
        public virtual IBpmnShape CreateBpmnShape(IFlowNode node)
        {
            IBpmnPlane bpmnPlane = FindBpmnPlane();

            if (bpmnPlane != null)
            {
                IBpmnShape bpmnShape = CreateInstance <IBpmnShape>(typeof(IBpmnShape));
                bpmnShape.BpmnElement = node;
                IBounds nodeBounds = CreateInstance <IBounds>(typeof(IBounds));

                if (node is ISubProcess)
                {
                    bpmnShape.Expanded = true;
                    nodeBounds.SetWidth(350);
                    nodeBounds.SetHeight(200);
                }
                else if (node is IActivity)
                {
                    nodeBounds.SetWidth(100);
                    nodeBounds.SetHeight(80);
                }
                else if (node is IEvent)
                {
                    nodeBounds.SetWidth(36);
                    nodeBounds.SetHeight(36);
                }
                else if (node is IGateway)
                {
                    nodeBounds.SetWidth(50);
                    nodeBounds.SetHeight(50);
                }

                nodeBounds.SetX(0);
                nodeBounds.SetY(0);

                bpmnShape.AddChildElement(nodeBounds);
                bpmnPlane.AddChildElement(bpmnShape);

                return(bpmnShape);
            }
            return(null);
        }
コード例 #3
0
        public virtual StartEventBuilder StartEvent(string id)
        {
            IStartEvent start = SubProcessBuilder.CreateChild <IStartEvent>(typeof(IStartEvent), id);

            IBpmnShape startShape      = SubProcessBuilder.CreateBpmnShape(start);
            IBpmnShape subProcessShape = SubProcessBuilder.FindBpmnShape(SubProcessBuilder.element);

            if (subProcessShape != null)
            {
                IBounds subProcessBounds = subProcessShape.Bounds;
                IBounds startBounds      = startShape.Bounds;

                double subProcessX      = subProcessBounds.GetX().Value;
                double subProcessY      = subProcessBounds.GetY().Value;
                double subProcessHeight = subProcessBounds.GetHeight().Value;
                double startHeight      = startBounds.GetHeight().Value;

                startBounds.SetX(subProcessX);
                startBounds.SetY(subProcessY + subProcessHeight / 2 - startHeight / 2);
            }

            return(start.Builder <StartEventBuilder, IStartEvent>());
        }