/// <summary> /// Returns the edge an embedded element is bound to (left, right, top, bottom) /// </summary> /// <param name="obj"></param> /// <param name="rep"></param> /// <returns></returns> public static EmbeddedPosition Edge(this EA.DiagramObject obj, EA.Repository rep) { EA.Element el = rep.GetElementByID(obj.ElementID); EA.Element elParent = el.GetParentOfEmbedded(rep); if (elParent == null) { return(EmbeddedPosition.Undefined); } // for Required/Required Interface use the owning Port for the position if (el.Type == "ProvidedInterface" || el.Type == "RequiredInterface") { if (el.ParentID == 0) { return(EmbeddedPosition.Undefined); } el = rep.GetElementByID(el.ParentID); } EA.Diagram dia = rep.GetDiagramByID(obj.DiagramID); EA.DiagramObject objParent = dia.GetDiagramObjectByID(elParent.ElementID, ""); EA.DiagramObject objFirstEmbedded = dia.GetDiagramObjectByID(el.ElementID, ""); if (objParent == null) { return(EmbeddedPosition.Undefined); } int horicontalCenter = objFirstEmbedded.left + (objFirstEmbedded.right - objFirstEmbedded.left) / 2; int verticalCenter = objFirstEmbedded.top - (objFirstEmbedded.top - objFirstEmbedded.bottom) / 2; if (horicontalCenter < objParent.left + 10 && horicontalCenter > objParent.left - 10) { return(EmbeddedPosition.Left); } if (horicontalCenter < objParent.right + 10 && horicontalCenter > objParent.right - 10) { return(EmbeddedPosition.Right); } if (verticalCenter < objParent.top + 10 && verticalCenter > objParent.top - 10) { return(EmbeddedPosition.Top); } if (verticalCenter < objParent.bottom + 10 && verticalCenter > objParent.bottom - 10) { return(EmbeddedPosition.Bottom); } return(EmbeddedPosition.Undefined); }
public void DrawDiagram(int parentDiagramID, int lifeCycleDiagramID) { EAAPI.Element parentElement = eaRepo.GetElementByID(parentDiagramID); EAAPI.Diagram lifeCycleDiagram = eaRepo.GetDiagramByID(lifeCycleDiagramID); EAAPI.Package parentPackage = eaRepo.GetPackageByID(lifeCycleDiagram.PackageID); // convert to Dictionary so it is easier to lookup. Dictionary <String, EAAPI.Element> elements = ConvertEAElementsToDictionary(parentPackage.Elements); AddOrUpdateElements(parentPackage, parentElement, lifeCycleDiagram, ref elements); AddOrUpdateElementsOnDiagram(parentElement, lifeCycleDiagram, ref elements); FixDiagramObjectsSequence(lifeCycleDiagram, elements); lifeCycleDiagram.Update(); }