/// <summary>
        /// adds an element to the diagram
        /// </summary>
        /// <param name="element">the element to add</param>
        /// <returns>the new diagramElement</returns>
        public UML.Diagrams.DiagramElement addToDiagram(UML.Classes.Kernel.Element element)
        {
            UML.Diagrams.DiagramElement diagramElement = null;
            if (element != null)
            {
                //first check whether this element is not already added to this diagram
                diagramElement = this.getDiagramElement(element);
                if (diagramElement == null)
                {
                    if (element is EA.ElementWrapper)
                    {
                        //first save the diagram to make sure we don't lose any unsaved changes
                        this.model.saveOpenedDiagram(this);
                        global::EA.DiagramObject newDiagramObject = this.wrappedDiagram.DiagramObjects.AddNew("", "") as global::EA.DiagramObject;
                        diagramElement         = ((Factory)this.model.factory).createDiagramElement(newDiagramObject);
                        diagramElement.element = element;
                        //save the element diagramObject
                        ((DiagramObjectWrapper)diagramElement).save();
                        // now refresh to make sure we see the new element on the diagram
                        this.reFresh();
                    }

                    else if (!(element.owner is UML.Classes.Kernel.Package))
                    {
                        diagramElement = this.addToDiagram(element.owner);
                    }
                }
            }
            return(diagramElement);
        }
Пример #2
0
        internal bool isContainedElement(ElementWrapper elementWrapper)
        {
            if (elementWrapper == null)
            {
                return(false);
            }

            // The element in question must be a direct child of the regions owning element
            if (elementWrapper.wrappedElement.ParentID != redefinedElement.wrappedElement.ElementID)
            {
                return(false);
            }

            if (partition != null)
            {
                // Check if the element in question resides inside the graphical representation of this region
                //--------------------------------------------------------------------------------------------
                if (masterDiagram != null)
                {
                    // Get the element in question's graphical representation from the master diagram
                    global::EA.DiagramObject elementDiagramObject = getMasterDiagramObject(elementWrapper);
                    if (elementDiagramObject != null)
                    {
                        System.Drawing.Rectangle elementRectangle =
                            new System.Drawing.Rectangle
                                (elementDiagramObject.left
                                , System.Math.Abs(elementDiagramObject.top)
                                , elementDiagramObject.right - elementDiagramObject.left
                                , System.Math.Abs(elementDiagramObject.bottom) - System.Math.Abs(elementDiagramObject.top)
                                );
                        // Get the owning elements graphical region representation from the master diagram
                        global::EA.DiagramObject owningElementDiagramObject = getMasterDiagramObject(redefinedElement);
                        if (owningElementDiagramObject != null)
                        {
                            int x      = owningElementDiagramObject.left;
                            int y      = System.Math.Abs(owningElementDiagramObject.top) + getRegionTopOffset(partition);
                            int width  = owningElementDiagramObject.right - x;
                            int height = partition.Size;
                            System.Drawing.Rectangle regionRectangle = new System.Drawing.Rectangle(x, y, width, height);
                            if (regionRectangle.Contains(elementRectangle))
                            {
                                return(true);
                            }
                        }
                    }
                }
            }
            else
            {
                return(true);
            }
            return(false);
        }
Пример #3
0
 public UML.Diagrams.DiagramElement createDiagramElement
     (global::EA.DiagramObject objectToWrap)
 {
     return(new DiagramObjectWrapper(this.model as Model, objectToWrap));
 }
 public DiagramObjectWrapper(Model model,
                             global::EA.DiagramObject diagramObject)
 {
     this.wrappedDiagramObject = diagramObject;
     this.model = model;
 }