Exemplo n.º 1
0
        private static ShapeElement GetShapeElement(this ModelElement element)
        {
            // Get the first shape
            // If the model element is in a compartment the result will be null

            return(element.GetFirstShapeElement() ?? element.GetCompartmentElementFirstParentElement()?.GetFirstShapeElement());
        }
Exemplo n.º 2
0
        public static ShapeElement GetShapeElement(this ModelElement element)
        {
            // If the model element is in a compartment the result will be null
            ShapeElement shape = PresentationViewsSubject.GetPresentation(element).OfType <ShapeElement>().FirstOrDefault();

            if (shape == null)
            {
                // If the element is in a compartment, try to get the parent model element to select that
                ModelElement parentElement = element.GetCompartmentElementFirstParentElement();

                if (parentElement != null)
                {
                    shape = PresentationViewsSubject.GetPresentation(parentElement).OfType <ShapeElement>().FirstOrDefault();
                }
            }

            return(shape);
        }
        private static ShapeElement GetShapeElement(this ModelElement element, Diagram diagram = null)
        {
            ShapeElement result = null;

            // Get the shape on the diagram. If not specified, pick the current one
            if (diagram == null)
            {
                diagram = EFModel.ModelRoot.GetCurrentDiagram();
            }

            if (diagram != null)
            {
                result = diagram.Store.GetAll <ShapeElement>().FirstOrDefault(x => x.ModelElement == element && x.Diagram == diagram);

                // If the model element is in a compartment the result should be null? Check for Compartment type just in case
                if (result is Compartment)
                {
                    ModelElement parentElement = element.GetCompartmentElementFirstParentElement();
                    result = parentElement?.GetShapeElement(diagram);
                }
            }

            return(result);
        }